Completed
Branch FET/10766/extract-activation-d... (f6eee0)
by
unknown
75:38 queued 68:03
created
admin_pages/registrations/EE_Registrations_List_Table.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@
 block discarded – undo
227 227
      *    _get_table_filters
228 228
      *
229 229
      * @access protected
230
-     * @return array
230
+     * @return string[]
231 231
      */
232 232
     protected function _get_table_filters()
233 233
     {
Please login to merge, or discard this patch.
Indentation   +926 added lines, -926 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\exceptions\InvalidInterfaceException;
4 4
 
5 5
 if (! defined('EVENT_ESPRESSO_VERSION')) {
6
-    exit('No direct script access allowed');
6
+	exit('No direct script access allowed');
7 7
 }
8 8
 
9 9
 
@@ -28,1006 +28,1006 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    /**
32
-     * @var array
33
-     */
34
-    private $_status;
31
+	/**
32
+	 * @var array
33
+	 */
34
+	private $_status;
35 35
 
36 36
 
37
-    /**
38
-     * An array of transaction details for the related transaction to the registration being processed.
39
-     * This is set via the _set_related_details method.
40
-     *
41
-     * @var array
42
-     */
43
-    protected $_transaction_details = array();
37
+	/**
38
+	 * An array of transaction details for the related transaction to the registration being processed.
39
+	 * This is set via the _set_related_details method.
40
+	 *
41
+	 * @var array
42
+	 */
43
+	protected $_transaction_details = array();
44 44
 
45 45
 
46
-    /**
47
-     * An array of event details for the related event to the registration being processed.
48
-     * This is set via the _set_related_details method.
49
-     *
50
-     * @var array
51
-     */
52
-    protected $_event_details = array();
46
+	/**
47
+	 * An array of event details for the related event to the registration being processed.
48
+	 * This is set via the _set_related_details method.
49
+	 *
50
+	 * @var array
51
+	 */
52
+	protected $_event_details = array();
53 53
 
54 54
 
55
-    /**
56
-     * @param \Registrations_Admin_Page $admin_page
57
-     */
58
-    public function __construct(Registrations_Admin_Page $admin_page)
59
-    {
60
-        if (! empty($_GET['event_id'])) {
61
-            $extra_query_args = array();
62
-            foreach ($admin_page->get_views() as $key => $view_details) {
63
-                $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
64
-            }
65
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
66
-        }
67
-        parent::__construct($admin_page);
68
-        $this->_status = $this->_admin_page->get_registration_status_array();
69
-    }
55
+	/**
56
+	 * @param \Registrations_Admin_Page $admin_page
57
+	 */
58
+	public function __construct(Registrations_Admin_Page $admin_page)
59
+	{
60
+		if (! empty($_GET['event_id'])) {
61
+			$extra_query_args = array();
62
+			foreach ($admin_page->get_views() as $key => $view_details) {
63
+				$extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
64
+			}
65
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
66
+		}
67
+		parent::__construct($admin_page);
68
+		$this->_status = $this->_admin_page->get_registration_status_array();
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     *    _setup_data
74
-     *
75
-     * @access protected
76
-     * @return void
77
-     */
78
-    protected function _setup_data()
79
-    {
80
-        $this->_data = $this->_admin_page->get_registrations($this->_per_page);
81
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
82
-    }
72
+	/**
73
+	 *    _setup_data
74
+	 *
75
+	 * @access protected
76
+	 * @return void
77
+	 */
78
+	protected function _setup_data()
79
+	{
80
+		$this->_data = $this->_admin_page->get_registrations($this->_per_page);
81
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
82
+	}
83 83
 
84 84
 
85
-    /**
86
-     *    _set_properties
87
-     *
88
-     * @access protected
89
-     * @return void
90
-     */
91
-    protected function _set_properties()
92
-    {
93
-        $this->_wp_list_args = array(
94
-            'singular' => __('registration', 'event_espresso'),
95
-            'plural'   => __('registrations', 'event_espresso'),
96
-            'ajax'     => true,
97
-            'screen'   => $this->_admin_page->get_current_screen()->id,
98
-        );
99
-        $ID_column_name = __('ID', 'event_espresso');
100
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
101
-        $ID_column_name .= __('Registrant Name', 'event_espresso');
102
-        $ID_column_name .= '</span> ';
103
-        if (isset($_GET['event_id'])) {
104
-            $this->_columns = array(
105
-                'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
106
-                '_REG_ID'          => $ID_column_name,
107
-                'ATT_fname'        => __('Name', 'event_espresso'),
108
-                'ATT_email'        => __('Email', 'event_espresso'),
109
-                '_REG_date'        => __('Reg Date', 'event_espresso'),
110
-                'PRC_amount'       => __('TKT Price', 'event_espresso'),
111
-                '_REG_final_price' => __('Final Price', 'event_espresso'),
112
-                'TXN_total'        => __('Total Txn', 'event_espresso'),
113
-                'TXN_paid'         => __('Paid', 'event_espresso'),
114
-                'actions'          => __('Actions', 'event_espresso'),
115
-            );
116
-            $this->_bottom_buttons = array(
117
-                'report' => array(
118
-                    'route'         => 'registrations_report',
119
-                    'extra_request' => array(
120
-                        'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
121
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
122
-                    ),
123
-                ),
124
-            );
125
-        } else {
126
-            $this->_columns = array(
127
-                'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
128
-                '_REG_ID'          => $ID_column_name,
129
-                'ATT_fname'        => __('Name', 'event_espresso'),
130
-                '_REG_date'        => __('TXN Date', 'event_espresso'),
131
-                'event_name'       => __('Event', 'event_espresso'),
132
-                'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
133
-                '_REG_final_price' => __('Price', 'event_espresso'),
134
-                '_REG_paid'        => __('Paid', 'event_espresso'),
135
-                'actions'          => __('Actions', 'event_espresso'),
136
-            );
137
-            $this->_bottom_buttons = array(
138
-                'report_all' => array(
139
-                    'route'         => 'registrations_report',
140
-                    'extra_request' => array(
141
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
142
-                    ),
143
-                ),
144
-            );
145
-        }
146
-        $this->_bottom_buttons['report_filtered'] = array(
147
-            'route'         => 'registrations_report',
148
-            'extra_request' => array(
149
-                'use_filters' => true,
150
-                'filters'     => array_diff_key($this->_req_data, array_flip(array(
151
-                    'page',
152
-                    'action',
153
-                    'default_nonce',
154
-                ))),
155
-                'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
156
-            ),
157
-        );
158
-        $this->_primary_column = '_REG_ID';
159
-        $this->_sortable_columns = array(
160
-            '_REG_date'     => array('_REG_date' => true),   //true means its already sorted
161
-            /**
162
-             * Allows users to change the default sort if they wish.
163
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
164
-             * name.
165
-             */
166
-            'ATT_fname'     => array(
167
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
168
-                true,
169
-                $this,
170
-            )
171
-                ? array('ATT_lname' => false)
172
-                : array('ATT_fname' => false),
173
-            'event_name'    => array('event_name' => false),
174
-            'DTT_EVT_start' => array('DTT_EVT_start' => false),
175
-            '_REG_ID'       => array('_REG_ID' => false),
176
-        );
177
-        $this->_hidden_columns = array();
178
-    }
85
+	/**
86
+	 *    _set_properties
87
+	 *
88
+	 * @access protected
89
+	 * @return void
90
+	 */
91
+	protected function _set_properties()
92
+	{
93
+		$this->_wp_list_args = array(
94
+			'singular' => __('registration', 'event_espresso'),
95
+			'plural'   => __('registrations', 'event_espresso'),
96
+			'ajax'     => true,
97
+			'screen'   => $this->_admin_page->get_current_screen()->id,
98
+		);
99
+		$ID_column_name = __('ID', 'event_espresso');
100
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
101
+		$ID_column_name .= __('Registrant Name', 'event_espresso');
102
+		$ID_column_name .= '</span> ';
103
+		if (isset($_GET['event_id'])) {
104
+			$this->_columns = array(
105
+				'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
106
+				'_REG_ID'          => $ID_column_name,
107
+				'ATT_fname'        => __('Name', 'event_espresso'),
108
+				'ATT_email'        => __('Email', 'event_espresso'),
109
+				'_REG_date'        => __('Reg Date', 'event_espresso'),
110
+				'PRC_amount'       => __('TKT Price', 'event_espresso'),
111
+				'_REG_final_price' => __('Final Price', 'event_espresso'),
112
+				'TXN_total'        => __('Total Txn', 'event_espresso'),
113
+				'TXN_paid'         => __('Paid', 'event_espresso'),
114
+				'actions'          => __('Actions', 'event_espresso'),
115
+			);
116
+			$this->_bottom_buttons = array(
117
+				'report' => array(
118
+					'route'         => 'registrations_report',
119
+					'extra_request' => array(
120
+						'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
121
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
122
+					),
123
+				),
124
+			);
125
+		} else {
126
+			$this->_columns = array(
127
+				'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
128
+				'_REG_ID'          => $ID_column_name,
129
+				'ATT_fname'        => __('Name', 'event_espresso'),
130
+				'_REG_date'        => __('TXN Date', 'event_espresso'),
131
+				'event_name'       => __('Event', 'event_espresso'),
132
+				'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
133
+				'_REG_final_price' => __('Price', 'event_espresso'),
134
+				'_REG_paid'        => __('Paid', 'event_espresso'),
135
+				'actions'          => __('Actions', 'event_espresso'),
136
+			);
137
+			$this->_bottom_buttons = array(
138
+				'report_all' => array(
139
+					'route'         => 'registrations_report',
140
+					'extra_request' => array(
141
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
142
+					),
143
+				),
144
+			);
145
+		}
146
+		$this->_bottom_buttons['report_filtered'] = array(
147
+			'route'         => 'registrations_report',
148
+			'extra_request' => array(
149
+				'use_filters' => true,
150
+				'filters'     => array_diff_key($this->_req_data, array_flip(array(
151
+					'page',
152
+					'action',
153
+					'default_nonce',
154
+				))),
155
+				'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
156
+			),
157
+		);
158
+		$this->_primary_column = '_REG_ID';
159
+		$this->_sortable_columns = array(
160
+			'_REG_date'     => array('_REG_date' => true),   //true means its already sorted
161
+			/**
162
+			 * Allows users to change the default sort if they wish.
163
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
164
+			 * name.
165
+			 */
166
+			'ATT_fname'     => array(
167
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
168
+				true,
169
+				$this,
170
+			)
171
+				? array('ATT_lname' => false)
172
+				: array('ATT_fname' => false),
173
+			'event_name'    => array('event_name' => false),
174
+			'DTT_EVT_start' => array('DTT_EVT_start' => false),
175
+			'_REG_ID'       => array('_REG_ID' => false),
176
+		);
177
+		$this->_hidden_columns = array();
178
+	}
179 179
 
180 180
 
181
-    /**
182
-     * This simply sets up the row class for the table rows.
183
-     * Allows for easier overriding of child methods for setting up sorting.
184
-     *
185
-     * @param  EE_Registration $item the current item
186
-     * @return string
187
-     */
188
-    protected function _get_row_class($item)
189
-    {
190
-        $class = parent::_get_row_class($item);
191
-        //add status class
192
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
193
-        if ($this->_has_checkbox_column) {
194
-            $class .= ' has-checkbox-column';
195
-        }
196
-        return $class;
197
-    }
181
+	/**
182
+	 * This simply sets up the row class for the table rows.
183
+	 * Allows for easier overriding of child methods for setting up sorting.
184
+	 *
185
+	 * @param  EE_Registration $item the current item
186
+	 * @return string
187
+	 */
188
+	protected function _get_row_class($item)
189
+	{
190
+		$class = parent::_get_row_class($item);
191
+		//add status class
192
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
193
+		if ($this->_has_checkbox_column) {
194
+			$class .= ' has-checkbox-column';
195
+		}
196
+		return $class;
197
+	}
198 198
 
199 199
 
200
-    /**
201
-     * Set the $_transaction_details property if not set yet.
202
-     *
203
-     * @param EE_Registration $registration
204
-     * @throws EE_Error
205
-     * @throws InvalidArgumentException
206
-     * @throws ReflectionException
207
-     * @throws InvalidDataTypeException
208
-     * @throws InvalidInterfaceException
209
-     */
210
-    protected function _set_related_details(EE_Registration $registration)
211
-    {
212
-        $transaction = $registration->get_first_related('Transaction');
213
-        $status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
214
-            : EEM_Transaction::failed_status_code;
215
-        $this->_transaction_details = array(
216
-            'transaction' => $transaction,
217
-            'status'      => $status,
218
-            'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
219
-            'title_attr'  => sprintf(
220
-                __('View Transaction Details (%s)', 'event_espresso'),
221
-                EEH_Template::pretty_status($status, false, 'sentence')
222
-            ),
223
-        );
224
-        try {
225
-            $event = $registration->event();
226
-        } catch (EntityNotFoundException $e) {
227
-            $event = null;
228
-        }
229
-        $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
230
-        $this->_event_details = array(
231
-            'event'      => $event,
232
-            'status'     => $status,
233
-            'id'         => $event instanceof EE_Event ? $event->ID() : 0,
234
-            'title_attr' => sprintf(
235
-                __('Edit Event (%s)', 'event_espresso'),
236
-                EEH_Template::pretty_status($status, false, 'sentence')
237
-            ),
238
-        );
239
-    }
200
+	/**
201
+	 * Set the $_transaction_details property if not set yet.
202
+	 *
203
+	 * @param EE_Registration $registration
204
+	 * @throws EE_Error
205
+	 * @throws InvalidArgumentException
206
+	 * @throws ReflectionException
207
+	 * @throws InvalidDataTypeException
208
+	 * @throws InvalidInterfaceException
209
+	 */
210
+	protected function _set_related_details(EE_Registration $registration)
211
+	{
212
+		$transaction = $registration->get_first_related('Transaction');
213
+		$status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
214
+			: EEM_Transaction::failed_status_code;
215
+		$this->_transaction_details = array(
216
+			'transaction' => $transaction,
217
+			'status'      => $status,
218
+			'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
219
+			'title_attr'  => sprintf(
220
+				__('View Transaction Details (%s)', 'event_espresso'),
221
+				EEH_Template::pretty_status($status, false, 'sentence')
222
+			),
223
+		);
224
+		try {
225
+			$event = $registration->event();
226
+		} catch (EntityNotFoundException $e) {
227
+			$event = null;
228
+		}
229
+		$status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
230
+		$this->_event_details = array(
231
+			'event'      => $event,
232
+			'status'     => $status,
233
+			'id'         => $event instanceof EE_Event ? $event->ID() : 0,
234
+			'title_attr' => sprintf(
235
+				__('Edit Event (%s)', 'event_espresso'),
236
+				EEH_Template::pretty_status($status, false, 'sentence')
237
+			),
238
+		);
239
+	}
240 240
 
241 241
 
242
-    /**
243
-     *    _get_table_filters
244
-     *
245
-     * @access protected
246
-     * @return array
247
-     */
248
-    protected function _get_table_filters()
249
-    {
250
-        $filters = array();
251
-        //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
252
-        // methods.
253
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
254
-        $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
255
-        $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
256
-        $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
257
-        $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
258
-        $status = array();
259
-        $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
260
-        foreach ($this->_status as $key => $value) {
261
-            $status[] = array('id' => $key, 'text' => $value);
262
-        }
263
-        if ($this->_view !== 'incomplete') {
264
-            $filters[] = EEH_Form_Fields::select_input(
265
-                '_reg_status',
266
-                $status,
267
-                isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
268
-                    : ''
269
-            );
270
-        }
271
-        if (isset($this->_req_data['event_id'])) {
272
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
273
-        }
274
-        return $filters;
275
-    }
242
+	/**
243
+	 *    _get_table_filters
244
+	 *
245
+	 * @access protected
246
+	 * @return array
247
+	 */
248
+	protected function _get_table_filters()
249
+	{
250
+		$filters = array();
251
+		//todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
252
+		// methods.
253
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
254
+		$cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
255
+		$reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
256
+		$filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
257
+		$filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
258
+		$status = array();
259
+		$status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
260
+		foreach ($this->_status as $key => $value) {
261
+			$status[] = array('id' => $key, 'text' => $value);
262
+		}
263
+		if ($this->_view !== 'incomplete') {
264
+			$filters[] = EEH_Form_Fields::select_input(
265
+				'_reg_status',
266
+				$status,
267
+				isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
268
+					: ''
269
+			);
270
+		}
271
+		if (isset($this->_req_data['event_id'])) {
272
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
273
+		}
274
+		return $filters;
275
+	}
276 276
 
277 277
 
278
-    /**
279
-     *    _add_view_counts
280
-     *
281
-     * @access protected
282
-     * @return void
283
-     * @throws EE_Error
284
-     * @throws InvalidArgumentException
285
-     * @throws InvalidDataTypeException
286
-     * @throws InvalidInterfaceException
287
-     */
288
-    protected function _add_view_counts()
289
-    {
290
-        $this->_views['all']['count'] = $this->_total_registrations();
291
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
292
-        $this->_views['today']['count'] = $this->_total_registrations_today();
293
-        if (EE_Registry::instance()->CAP->current_user_can(
294
-            'ee_delete_registrations',
295
-            'espresso_registrations_trash_registrations'
296
-        )) {
297
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
298
-            $this->_views['trash']['count'] = $this->_total_registrations('trash');
299
-        }
300
-    }
278
+	/**
279
+	 *    _add_view_counts
280
+	 *
281
+	 * @access protected
282
+	 * @return void
283
+	 * @throws EE_Error
284
+	 * @throws InvalidArgumentException
285
+	 * @throws InvalidDataTypeException
286
+	 * @throws InvalidInterfaceException
287
+	 */
288
+	protected function _add_view_counts()
289
+	{
290
+		$this->_views['all']['count'] = $this->_total_registrations();
291
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
292
+		$this->_views['today']['count'] = $this->_total_registrations_today();
293
+		if (EE_Registry::instance()->CAP->current_user_can(
294
+			'ee_delete_registrations',
295
+			'espresso_registrations_trash_registrations'
296
+		)) {
297
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
298
+			$this->_views['trash']['count'] = $this->_total_registrations('trash');
299
+		}
300
+	}
301 301
 
302 302
 
303
-    /**
304
-     * _total_registrations
305
-     *
306
-     * @access protected
307
-     * @param string $view
308
-     * @return int
309
-     * @throws EE_Error
310
-     * @throws InvalidArgumentException
311
-     * @throws InvalidDataTypeException
312
-     * @throws InvalidInterfaceException
313
-     */
314
-    protected function _total_registrations($view = '')
315
-    {
316
-        $_where = array();
317
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
318
-        if ($EVT_ID) {
319
-            $_where['EVT_ID'] = $EVT_ID;
320
-        }
321
-        switch ($view) {
322
-            case 'trash':
323
-                return EEM_Registration::instance()->count_deleted(array($_where));
324
-                break;
325
-            case 'incomplete':
326
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
327
-                break;
328
-            default:
329
-                $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
330
-        }
331
-        return EEM_Registration::instance()->count(array($_where));
332
-    }
303
+	/**
304
+	 * _total_registrations
305
+	 *
306
+	 * @access protected
307
+	 * @param string $view
308
+	 * @return int
309
+	 * @throws EE_Error
310
+	 * @throws InvalidArgumentException
311
+	 * @throws InvalidDataTypeException
312
+	 * @throws InvalidInterfaceException
313
+	 */
314
+	protected function _total_registrations($view = '')
315
+	{
316
+		$_where = array();
317
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
318
+		if ($EVT_ID) {
319
+			$_where['EVT_ID'] = $EVT_ID;
320
+		}
321
+		switch ($view) {
322
+			case 'trash':
323
+				return EEM_Registration::instance()->count_deleted(array($_where));
324
+				break;
325
+			case 'incomplete':
326
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
327
+				break;
328
+			default:
329
+				$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
330
+		}
331
+		return EEM_Registration::instance()->count(array($_where));
332
+	}
333 333
 
334 334
 
335
-    /**
336
-     * _total_registrations_this_month
337
-     *
338
-     * @access protected
339
-     * @return int
340
-     * @throws EE_Error
341
-     * @throws InvalidArgumentException
342
-     * @throws InvalidDataTypeException
343
-     * @throws InvalidInterfaceException
344
-     */
345
-    protected function _total_registrations_this_month()
346
-    {
347
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
348
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
349
-        $this_year_r = date('Y', current_time('timestamp'));
350
-        $time_start = ' 00:00:00';
351
-        $time_end = ' 23:59:59';
352
-        $this_month_r = date('m', current_time('timestamp'));
353
-        $days_this_month = date('t', current_time('timestamp'));
354
-        //setup date query.
355
-        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
356
-            'REG_date',
357
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
358
-            'Y-m-d H:i:s'
359
-        );
360
-        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
361
-            'REG_date',
362
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
363
-            'Y-m-d H:i:s'
364
-        );
365
-        $_where['REG_date'] = array(
366
-            'BETWEEN',
367
-            array(
368
-                $beginning_string,
369
-                $end_string,
370
-            ),
371
-        );
372
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
373
-        return EEM_Registration::instance()->count(array($_where));
374
-    }
335
+	/**
336
+	 * _total_registrations_this_month
337
+	 *
338
+	 * @access protected
339
+	 * @return int
340
+	 * @throws EE_Error
341
+	 * @throws InvalidArgumentException
342
+	 * @throws InvalidDataTypeException
343
+	 * @throws InvalidInterfaceException
344
+	 */
345
+	protected function _total_registrations_this_month()
346
+	{
347
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
348
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
349
+		$this_year_r = date('Y', current_time('timestamp'));
350
+		$time_start = ' 00:00:00';
351
+		$time_end = ' 23:59:59';
352
+		$this_month_r = date('m', current_time('timestamp'));
353
+		$days_this_month = date('t', current_time('timestamp'));
354
+		//setup date query.
355
+		$beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
356
+			'REG_date',
357
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
358
+			'Y-m-d H:i:s'
359
+		);
360
+		$end_string = EEM_Registration::instance()->convert_datetime_for_query(
361
+			'REG_date',
362
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
363
+			'Y-m-d H:i:s'
364
+		);
365
+		$_where['REG_date'] = array(
366
+			'BETWEEN',
367
+			array(
368
+				$beginning_string,
369
+				$end_string,
370
+			),
371
+		);
372
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
373
+		return EEM_Registration::instance()->count(array($_where));
374
+	}
375 375
 
376 376
 
377
-    /**
378
-     * _total_registrations_today
379
-     *
380
-     * @access protected
381
-     * @return int
382
-     * @throws EE_Error
383
-     * @throws InvalidArgumentException
384
-     * @throws InvalidDataTypeException
385
-     * @throws InvalidInterfaceException
386
-     */
387
-    protected function _total_registrations_today()
388
-    {
389
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
390
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
391
-        $current_date = date('Y-m-d', current_time('timestamp'));
392
-        $time_start = ' 00:00:00';
393
-        $time_end = ' 23:59:59';
394
-        $_where['REG_date'] = array(
395
-            'BETWEEN',
396
-            array(
397
-                EEM_Registration::instance()->convert_datetime_for_query(
398
-                    'REG_date',
399
-                    $current_date . $time_start,
400
-                    'Y-m-d H:i:s'
401
-                ),
402
-                EEM_Registration::instance()->convert_datetime_for_query(
403
-                    'REG_date',
404
-                    $current_date . $time_end,
405
-                    'Y-m-d H:i:s'
406
-                ),
407
-            ),
408
-        );
409
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
410
-        return EEM_Registration::instance()->count(array($_where));
411
-    }
377
+	/**
378
+	 * _total_registrations_today
379
+	 *
380
+	 * @access protected
381
+	 * @return int
382
+	 * @throws EE_Error
383
+	 * @throws InvalidArgumentException
384
+	 * @throws InvalidDataTypeException
385
+	 * @throws InvalidInterfaceException
386
+	 */
387
+	protected function _total_registrations_today()
388
+	{
389
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
390
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
391
+		$current_date = date('Y-m-d', current_time('timestamp'));
392
+		$time_start = ' 00:00:00';
393
+		$time_end = ' 23:59:59';
394
+		$_where['REG_date'] = array(
395
+			'BETWEEN',
396
+			array(
397
+				EEM_Registration::instance()->convert_datetime_for_query(
398
+					'REG_date',
399
+					$current_date . $time_start,
400
+					'Y-m-d H:i:s'
401
+				),
402
+				EEM_Registration::instance()->convert_datetime_for_query(
403
+					'REG_date',
404
+					$current_date . $time_end,
405
+					'Y-m-d H:i:s'
406
+				),
407
+			),
408
+		);
409
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
410
+		return EEM_Registration::instance()->count(array($_where));
411
+	}
412 412
 
413 413
 
414
-    /**
415
-     * column_cb
416
-     *
417
-     * @access public
418
-     * @param \EE_Registration $item
419
-     * @return string
420
-     * @throws EE_Error
421
-     * @throws InvalidArgumentException
422
-     * @throws InvalidDataTypeException
423
-     * @throws InvalidInterfaceException
424
-     * @throws ReflectionException
425
-     */
426
-    public function column_cb($item)
427
-    {
428
-        /** checkbox/lock **/
429
-        $transaction = $item->get_first_related('Transaction');
430
-        $payment_count = $transaction instanceof EE_Transaction
431
-            ? $transaction->count_related('Payment')
432
-            : 0;
433
-        return $payment_count > 0
434
-               || ! EE_Registry::instance()->CAP->current_user_can(
435
-                   'ee_edit_registration',
436
-                   'registration_list_table_checkbox_input',
437
-                   $item->ID()
438
-               )
439
-            ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
440
-              . '<span class="ee-lock-icon"></span>'
441
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
442
-    }
414
+	/**
415
+	 * column_cb
416
+	 *
417
+	 * @access public
418
+	 * @param \EE_Registration $item
419
+	 * @return string
420
+	 * @throws EE_Error
421
+	 * @throws InvalidArgumentException
422
+	 * @throws InvalidDataTypeException
423
+	 * @throws InvalidInterfaceException
424
+	 * @throws ReflectionException
425
+	 */
426
+	public function column_cb($item)
427
+	{
428
+		/** checkbox/lock **/
429
+		$transaction = $item->get_first_related('Transaction');
430
+		$payment_count = $transaction instanceof EE_Transaction
431
+			? $transaction->count_related('Payment')
432
+			: 0;
433
+		return $payment_count > 0
434
+			   || ! EE_Registry::instance()->CAP->current_user_can(
435
+				   'ee_edit_registration',
436
+				   'registration_list_table_checkbox_input',
437
+				   $item->ID()
438
+			   )
439
+			? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
440
+			  . '<span class="ee-lock-icon"></span>'
441
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
442
+	}
443 443
 
444 444
 
445
-    /**
446
-     * column__REG_ID
447
-     *
448
-     * @access public
449
-     * @param \EE_Registration $item
450
-     * @return string
451
-     * @throws EE_Error
452
-     * @throws InvalidArgumentException
453
-     * @throws InvalidDataTypeException
454
-     * @throws InvalidInterfaceException
455
-     * @throws ReflectionException
456
-     */
457
-    public function column__REG_ID(EE_Registration $item)
458
-    {
459
-        $attendee = $item->attendee();
460
-        $content = $item->ID();
461
-        $content .= '<div class="show-on-mobile-view-only">';
462
-        $content .= '<br>';
463
-        $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
464
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
465
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
466
-        $content .= '</div>';
467
-        return $content;
468
-    }
445
+	/**
446
+	 * column__REG_ID
447
+	 *
448
+	 * @access public
449
+	 * @param \EE_Registration $item
450
+	 * @return string
451
+	 * @throws EE_Error
452
+	 * @throws InvalidArgumentException
453
+	 * @throws InvalidDataTypeException
454
+	 * @throws InvalidInterfaceException
455
+	 * @throws ReflectionException
456
+	 */
457
+	public function column__REG_ID(EE_Registration $item)
458
+	{
459
+		$attendee = $item->attendee();
460
+		$content = $item->ID();
461
+		$content .= '<div class="show-on-mobile-view-only">';
462
+		$content .= '<br>';
463
+		$content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
464
+		$content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
465
+		$content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
466
+		$content .= '</div>';
467
+		return $content;
468
+	}
469 469
 
470 470
 
471
-    /**
472
-     * column__REG_date
473
-     *
474
-     * @access public
475
-     * @param \EE_Registration $item
476
-     * @return string
477
-     * @throws EE_Error
478
-     * @throws InvalidArgumentException
479
-     * @throws InvalidDataTypeException
480
-     * @throws InvalidInterfaceException
481
-     * @throws ReflectionException
482
-     */
483
-    public function column__REG_date(EE_Registration $item)
484
-    {
485
-        $this->_set_related_details($item);
486
-        //Build row actions
487
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
488
-            'action' => 'view_transaction',
489
-            'TXN_ID' => $this->_transaction_details['id'],
490
-        ), TXN_ADMIN_URL);
491
-        $view_link = EE_Registry::instance()->CAP->current_user_can(
492
-            'ee_read_transaction',
493
-            'espresso_transactions_view_transaction'
494
-        )
495
-            ? '<a class="ee-status-color-'
496
-                . $this->_transaction_details['status']
497
-                . '" href="'
498
-                . $view_lnk_url
499
-                . '" title="'
500
-                . esc_attr($this->_transaction_details['title_attr'])
501
-                . '">'
502
-                . $item->get_i18n_datetime('REG_date')
503
-                . '</a>' : $item->get_i18n_datetime('REG_date');
504
-        $view_link .= '<br><span class="ee-status-text-small">'
505
-                      . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
506
-                      . '</span>';
507
-        return $view_link;
508
-    }
471
+	/**
472
+	 * column__REG_date
473
+	 *
474
+	 * @access public
475
+	 * @param \EE_Registration $item
476
+	 * @return string
477
+	 * @throws EE_Error
478
+	 * @throws InvalidArgumentException
479
+	 * @throws InvalidDataTypeException
480
+	 * @throws InvalidInterfaceException
481
+	 * @throws ReflectionException
482
+	 */
483
+	public function column__REG_date(EE_Registration $item)
484
+	{
485
+		$this->_set_related_details($item);
486
+		//Build row actions
487
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
488
+			'action' => 'view_transaction',
489
+			'TXN_ID' => $this->_transaction_details['id'],
490
+		), TXN_ADMIN_URL);
491
+		$view_link = EE_Registry::instance()->CAP->current_user_can(
492
+			'ee_read_transaction',
493
+			'espresso_transactions_view_transaction'
494
+		)
495
+			? '<a class="ee-status-color-'
496
+				. $this->_transaction_details['status']
497
+				. '" href="'
498
+				. $view_lnk_url
499
+				. '" title="'
500
+				. esc_attr($this->_transaction_details['title_attr'])
501
+				. '">'
502
+				. $item->get_i18n_datetime('REG_date')
503
+				. '</a>' : $item->get_i18n_datetime('REG_date');
504
+		$view_link .= '<br><span class="ee-status-text-small">'
505
+					  . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
506
+					  . '</span>';
507
+		return $view_link;
508
+	}
509 509
 
510 510
 
511
-    /**
512
-     * column_event_name
513
-     *
514
-     * @access public
515
-     * @param \EE_Registration $item
516
-     * @return string
517
-     * @throws EE_Error
518
-     * @throws InvalidArgumentException
519
-     * @throws InvalidDataTypeException
520
-     * @throws InvalidInterfaceException
521
-     * @throws ReflectionException
522
-     */
523
-    public function column_event_name(EE_Registration $item)
524
-    {
525
-        $this->_set_related_details($item);
526
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
527
-        $EVT_ID = $item->event_ID();
528
-        $event_name = $item->event_name();
529
-        $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
530
-        $event_name = wp_trim_words($event_name, 30, '...');
531
-        if ($EVT_ID) {
532
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
533
-                array('action' => 'edit', 'post' => $EVT_ID),
534
-                EVENTS_ADMIN_URL
535
-            );
536
-            $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
537
-                ? '<a class="ee-status-color-'
538
-                  . $this->_event_details['status']
539
-                  . '" href="'
540
-                  . $edit_event_url
541
-                  . '" title="'
542
-                  . esc_attr($this->_event_details['title_attr'])
543
-                  . '">'
544
-                  . $event_name
545
-                  . '</a>' : $event_name;
546
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
547
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
548
-            $actions['event_filter'] .= sprintf(
549
-                esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
550
-                $event_name
551
-            );
552
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
553
-        } else {
554
-            $edit_event = $event_name;
555
-            $actions['event_filter'] = '';
556
-        }
557
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
558
-    }
511
+	/**
512
+	 * column_event_name
513
+	 *
514
+	 * @access public
515
+	 * @param \EE_Registration $item
516
+	 * @return string
517
+	 * @throws EE_Error
518
+	 * @throws InvalidArgumentException
519
+	 * @throws InvalidDataTypeException
520
+	 * @throws InvalidInterfaceException
521
+	 * @throws ReflectionException
522
+	 */
523
+	public function column_event_name(EE_Registration $item)
524
+	{
525
+		$this->_set_related_details($item);
526
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
527
+		$EVT_ID = $item->event_ID();
528
+		$event_name = $item->event_name();
529
+		$event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
530
+		$event_name = wp_trim_words($event_name, 30, '...');
531
+		if ($EVT_ID) {
532
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
533
+				array('action' => 'edit', 'post' => $EVT_ID),
534
+				EVENTS_ADMIN_URL
535
+			);
536
+			$edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
537
+				? '<a class="ee-status-color-'
538
+				  . $this->_event_details['status']
539
+				  . '" href="'
540
+				  . $edit_event_url
541
+				  . '" title="'
542
+				  . esc_attr($this->_event_details['title_attr'])
543
+				  . '">'
544
+				  . $event_name
545
+				  . '</a>' : $event_name;
546
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
547
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
548
+			$actions['event_filter'] .= sprintf(
549
+				esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
550
+				$event_name
551
+			);
552
+			$actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
553
+		} else {
554
+			$edit_event = $event_name;
555
+			$actions['event_filter'] = '';
556
+		}
557
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
558
+	}
559 559
 
560 560
 
561
-    /**
562
-     * column_DTT_EVT_start
563
-     *
564
-     * @access public
565
-     * @param \EE_Registration $item
566
-     * @return string
567
-     * @throws EE_Error
568
-     * @throws InvalidArgumentException
569
-     * @throws InvalidDataTypeException
570
-     * @throws InvalidInterfaceException
571
-     * @throws ReflectionException
572
-     */
573
-    public function column_DTT_EVT_start(EE_Registration $item)
574
-    {
575
-        $datetime_strings = array();
576
-        $ticket = $item->ticket(true);
577
-        if ($ticket instanceof EE_Ticket) {
578
-            $remove_defaults = array('default_where_conditions' => 'none');
579
-            $datetimes = $ticket->datetimes($remove_defaults);
580
-            foreach ($datetimes as $datetime) {
581
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
582
-            }
583
-            return $this->generateDisplayForDatetimes($datetime_strings);
584
-        }
585
-        return __('There is no ticket on this registration', 'event_espresso');
586
-    }
561
+	/**
562
+	 * column_DTT_EVT_start
563
+	 *
564
+	 * @access public
565
+	 * @param \EE_Registration $item
566
+	 * @return string
567
+	 * @throws EE_Error
568
+	 * @throws InvalidArgumentException
569
+	 * @throws InvalidDataTypeException
570
+	 * @throws InvalidInterfaceException
571
+	 * @throws ReflectionException
572
+	 */
573
+	public function column_DTT_EVT_start(EE_Registration $item)
574
+	{
575
+		$datetime_strings = array();
576
+		$ticket = $item->ticket(true);
577
+		if ($ticket instanceof EE_Ticket) {
578
+			$remove_defaults = array('default_where_conditions' => 'none');
579
+			$datetimes = $ticket->datetimes($remove_defaults);
580
+			foreach ($datetimes as $datetime) {
581
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
582
+			}
583
+			return $this->generateDisplayForDatetimes($datetime_strings);
584
+		}
585
+		return __('There is no ticket on this registration', 'event_espresso');
586
+	}
587 587
 
588 588
 
589
-    /**
590
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
591
-     *
592
-     * @param array $datetime_strings
593
-     * @return string
594
-     */
595
-    public function generateDisplayForDateTimes(array $datetime_strings)
596
-    {
597
-        $content = '<div class="ee-registration-event-datetimes-container">';
598
-        $expand_toggle = count($datetime_strings) > 1
599
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
600
-              . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
601
-            : '';
602
-        //get first item for initial visibility
603
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
604
-        $content .= $expand_toggle;
605
-        if ($datetime_strings) {
606
-            $content .= '<div style="clear:both"></div>';
607
-            $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
608
-            $content .= implode("<br />", $datetime_strings);
609
-            $content .= '</div>';
610
-        }
611
-        $content .= '</div>';
612
-        return $content;
613
-    }
589
+	/**
590
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
591
+	 *
592
+	 * @param array $datetime_strings
593
+	 * @return string
594
+	 */
595
+	public function generateDisplayForDateTimes(array $datetime_strings)
596
+	{
597
+		$content = '<div class="ee-registration-event-datetimes-container">';
598
+		$expand_toggle = count($datetime_strings) > 1
599
+			? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
600
+			  . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
601
+			: '';
602
+		//get first item for initial visibility
603
+		$content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
604
+		$content .= $expand_toggle;
605
+		if ($datetime_strings) {
606
+			$content .= '<div style="clear:both"></div>';
607
+			$content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
608
+			$content .= implode("<br />", $datetime_strings);
609
+			$content .= '</div>';
610
+		}
611
+		$content .= '</div>';
612
+		return $content;
613
+	}
614 614
 
615 615
 
616
-    /**
617
-     * column_ATT_fname
618
-     *
619
-     * @access public
620
-     * @param \EE_Registration $item
621
-     * @return string
622
-     * @throws EE_Error
623
-     * @throws InvalidArgumentException
624
-     * @throws InvalidDataTypeException
625
-     * @throws InvalidInterfaceException
626
-     * @throws ReflectionException
627
-     */
628
-    public function column_ATT_fname(EE_Registration $item)
629
-    {
630
-        $attendee = $item->attendee();
631
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
632
-            'action'  => 'view_registration',
633
-            '_REG_ID' => $item->ID(),
634
-        ), REG_ADMIN_URL);
635
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
636
-        $link = EE_Registry::instance()->CAP->current_user_can(
637
-            'ee_read_registration',
638
-            'espresso_registrations_view_registration',
639
-            $item->ID()
640
-        )
641
-            ? '<a href="'
642
-               . $edit_lnk_url
643
-               . '" title="'
644
-               . esc_attr__('View Registration Details', 'event_espresso')
645
-               . '">'
646
-               . $attendee_name
647
-               . '</a>' : $attendee_name;
648
-        $link .= $item->count() === 1
649
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
650
-        $t = $item->get_first_related('Transaction');
651
-        $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
652
-        //append group count to name
653
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
654
-        //append reg_code
655
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
656
-        //reg status text for accessibility
657
-        $link .= '<br><span class="ee-status-text-small">'
658
-                 . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
659
-                 . '</span>';
660
-        //trash/restore/delete actions
661
-        $actions = array();
662
-        if ($this->_view !== 'trash'
663
-            && $payment_count === 0
664
-            && EE_Registry::instance()->CAP->current_user_can(
665
-                'ee_delete_registration',
666
-                'espresso_registrations_trash_registrations',
667
-                $item->ID()
668
-            )) {
669
-            $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
670
-                'action'  => 'trash_registrations',
671
-                '_REG_ID' => $item->ID(),
672
-            ), REG_ADMIN_URL);
673
-            $actions['trash'] = '<a href="'
674
-                                . $trash_lnk_url
675
-                                . '" title="'
676
-                                . esc_attr__('Trash Registration', 'event_espresso')
677
-                                . '">' . __('Trash', 'event_espresso') . '</a>';
678
-        } elseif ($this->_view === 'trash') {
679
-            // restore registration link
680
-            if (EE_Registry::instance()->CAP->current_user_can(
681
-                'ee_delete_registration',
682
-                'espresso_registrations_restore_registrations',
683
-                $item->ID()
684
-            )) {
685
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
686
-                    'action'  => 'restore_registrations',
687
-                    '_REG_ID' => $item->ID(),
688
-                ), REG_ADMIN_URL);
689
-                $actions['restore'] = '<a href="'
690
-                                      . $restore_lnk_url
691
-                                      . '" title="'
692
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
693
-                                      . __('Restore', 'event_espresso') . '</a>';
694
-            }
695
-            if (EE_Registry::instance()->CAP->current_user_can(
696
-                'ee_delete_registration',
697
-                'espresso_registrations_ee_delete_registrations',
698
-                $item->ID()
699
-            )) {
700
-                $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
701
-                    'action'  => 'delete_registrations',
702
-                    '_REG_ID' => $item->ID(),
703
-                ), REG_ADMIN_URL);
704
-                $actions['delete'] = '<a href="'
705
-                                     . $delete_lnk_url
706
-                                     . '" title="'
707
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
708
-                                     . '">'
709
-                                     . __('Delete', 'event_espresso')
710
-                                     . '</a>';
711
-            }
712
-        }
713
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
714
-    }
616
+	/**
617
+	 * column_ATT_fname
618
+	 *
619
+	 * @access public
620
+	 * @param \EE_Registration $item
621
+	 * @return string
622
+	 * @throws EE_Error
623
+	 * @throws InvalidArgumentException
624
+	 * @throws InvalidDataTypeException
625
+	 * @throws InvalidInterfaceException
626
+	 * @throws ReflectionException
627
+	 */
628
+	public function column_ATT_fname(EE_Registration $item)
629
+	{
630
+		$attendee = $item->attendee();
631
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
632
+			'action'  => 'view_registration',
633
+			'_REG_ID' => $item->ID(),
634
+		), REG_ADMIN_URL);
635
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
636
+		$link = EE_Registry::instance()->CAP->current_user_can(
637
+			'ee_read_registration',
638
+			'espresso_registrations_view_registration',
639
+			$item->ID()
640
+		)
641
+			? '<a href="'
642
+			   . $edit_lnk_url
643
+			   . '" title="'
644
+			   . esc_attr__('View Registration Details', 'event_espresso')
645
+			   . '">'
646
+			   . $attendee_name
647
+			   . '</a>' : $attendee_name;
648
+		$link .= $item->count() === 1
649
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
650
+		$t = $item->get_first_related('Transaction');
651
+		$payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
652
+		//append group count to name
653
+		$link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
654
+		//append reg_code
655
+		$link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
656
+		//reg status text for accessibility
657
+		$link .= '<br><span class="ee-status-text-small">'
658
+				 . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
659
+				 . '</span>';
660
+		//trash/restore/delete actions
661
+		$actions = array();
662
+		if ($this->_view !== 'trash'
663
+			&& $payment_count === 0
664
+			&& EE_Registry::instance()->CAP->current_user_can(
665
+				'ee_delete_registration',
666
+				'espresso_registrations_trash_registrations',
667
+				$item->ID()
668
+			)) {
669
+			$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
670
+				'action'  => 'trash_registrations',
671
+				'_REG_ID' => $item->ID(),
672
+			), REG_ADMIN_URL);
673
+			$actions['trash'] = '<a href="'
674
+								. $trash_lnk_url
675
+								. '" title="'
676
+								. esc_attr__('Trash Registration', 'event_espresso')
677
+								. '">' . __('Trash', 'event_espresso') . '</a>';
678
+		} elseif ($this->_view === 'trash') {
679
+			// restore registration link
680
+			if (EE_Registry::instance()->CAP->current_user_can(
681
+				'ee_delete_registration',
682
+				'espresso_registrations_restore_registrations',
683
+				$item->ID()
684
+			)) {
685
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
686
+					'action'  => 'restore_registrations',
687
+					'_REG_ID' => $item->ID(),
688
+				), REG_ADMIN_URL);
689
+				$actions['restore'] = '<a href="'
690
+									  . $restore_lnk_url
691
+									  . '" title="'
692
+									  . esc_attr__('Restore Registration', 'event_espresso') . '">'
693
+									  . __('Restore', 'event_espresso') . '</a>';
694
+			}
695
+			if (EE_Registry::instance()->CAP->current_user_can(
696
+				'ee_delete_registration',
697
+				'espresso_registrations_ee_delete_registrations',
698
+				$item->ID()
699
+			)) {
700
+				$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
701
+					'action'  => 'delete_registrations',
702
+					'_REG_ID' => $item->ID(),
703
+				), REG_ADMIN_URL);
704
+				$actions['delete'] = '<a href="'
705
+									 . $delete_lnk_url
706
+									 . '" title="'
707
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
708
+									 . '">'
709
+									 . __('Delete', 'event_espresso')
710
+									 . '</a>';
711
+			}
712
+		}
713
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
714
+	}
715 715
 
716 716
 
717
-    /**
718
-     * column_ATT_email
719
-     *
720
-     * @access public
721
-     * @param \EE_Registration $item
722
-     * @return string
723
-     * @throws EE_Error
724
-     * @throws InvalidArgumentException
725
-     * @throws InvalidDataTypeException
726
-     * @throws InvalidInterfaceException
727
-     * @throws ReflectionException
728
-     */
729
-    public function column_ATT_email(EE_Registration $item)
730
-    {
731
-        $attendee = $item->get_first_related('Attendee');
732
-        return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
733
-            : $attendee->email();
734
-    }
717
+	/**
718
+	 * column_ATT_email
719
+	 *
720
+	 * @access public
721
+	 * @param \EE_Registration $item
722
+	 * @return string
723
+	 * @throws EE_Error
724
+	 * @throws InvalidArgumentException
725
+	 * @throws InvalidDataTypeException
726
+	 * @throws InvalidInterfaceException
727
+	 * @throws ReflectionException
728
+	 */
729
+	public function column_ATT_email(EE_Registration $item)
730
+	{
731
+		$attendee = $item->get_first_related('Attendee');
732
+		return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
733
+			: $attendee->email();
734
+	}
735 735
 
736 736
 
737
-    /**
738
-     * column__REG_count
739
-     *
740
-     * @access public
741
-     * @param \EE_Registration $item
742
-     * @return string
743
-     */
744
-    public function column__REG_count(EE_Registration $item)
745
-    {
746
-        return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
747
-    }
737
+	/**
738
+	 * column__REG_count
739
+	 *
740
+	 * @access public
741
+	 * @param \EE_Registration $item
742
+	 * @return string
743
+	 */
744
+	public function column__REG_count(EE_Registration $item)
745
+	{
746
+		return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
747
+	}
748 748
 
749 749
 
750
-    /**
751
-     * column_PRC_amount
752
-     *
753
-     * @access public
754
-     * @param \EE_Registration $item
755
-     * @return string
756
-     * @throws EE_Error
757
-     */
758
-    public function column_PRC_amount(EE_Registration $item)
759
-    {
760
-        $ticket = $item->ticket();
761
-        $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
762
-                                                                              . $ticket->name()
763
-                                                                              . '</span><br />' : '';
764
-        if ($item->final_price() > 0) {
765
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
766
-        } else {
767
-            // free event
768
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
769
-                        . __('free', 'event_espresso')
770
-                        . '</span>';
771
-        }
772
-        return $content;
773
-    }
750
+	/**
751
+	 * column_PRC_amount
752
+	 *
753
+	 * @access public
754
+	 * @param \EE_Registration $item
755
+	 * @return string
756
+	 * @throws EE_Error
757
+	 */
758
+	public function column_PRC_amount(EE_Registration $item)
759
+	{
760
+		$ticket = $item->ticket();
761
+		$content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
762
+																			  . $ticket->name()
763
+																			  . '</span><br />' : '';
764
+		if ($item->final_price() > 0) {
765
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
766
+		} else {
767
+			// free event
768
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
769
+						. __('free', 'event_espresso')
770
+						. '</span>';
771
+		}
772
+		return $content;
773
+	}
774 774
 
775 775
 
776
-    /**
777
-     * column__REG_final_price
778
-     *
779
-     * @access public
780
-     * @param \EE_Registration $item
781
-     * @return string
782
-     * @throws EE_Error
783
-     */
784
-    public function column__REG_final_price(EE_Registration $item)
785
-    {
786
-        $ticket = $item->ticket();
787
-        $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
788
-            ? ''
789
-            : '<span class="TKT_name">'
790
-              . $ticket->name()
791
-              . '</span><br />';
792
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
793
-        return $content;
794
-    }
776
+	/**
777
+	 * column__REG_final_price
778
+	 *
779
+	 * @access public
780
+	 * @param \EE_Registration $item
781
+	 * @return string
782
+	 * @throws EE_Error
783
+	 */
784
+	public function column__REG_final_price(EE_Registration $item)
785
+	{
786
+		$ticket = $item->ticket();
787
+		$content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
788
+			? ''
789
+			: '<span class="TKT_name">'
790
+			  . $ticket->name()
791
+			  . '</span><br />';
792
+		$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
793
+		return $content;
794
+	}
795 795
 
796 796
 
797
-    /**
798
-     * column__REG_paid
799
-     *
800
-     * @access public
801
-     * @param \EE_Registration $item
802
-     * @return string
803
-     * @throws EE_Error
804
-     */
805
-    public function column__REG_paid(EE_Registration $item)
806
-    {
807
-        $payment_method = $item->payment_method();
808
-        $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
809
-            : __('Unknown', 'event_espresso');
810
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
811
-        if ($item->paid() > 0) {
812
-            $content .= '<br><span class="ee-status-text-small">'
813
-                        . sprintf(
814
-                            __('...via %s', 'event_espresso'),
815
-                            $payment_method_name
816
-                        )
817
-                        . '</span>';
818
-        }
819
-        return $content;
820
-    }
797
+	/**
798
+	 * column__REG_paid
799
+	 *
800
+	 * @access public
801
+	 * @param \EE_Registration $item
802
+	 * @return string
803
+	 * @throws EE_Error
804
+	 */
805
+	public function column__REG_paid(EE_Registration $item)
806
+	{
807
+		$payment_method = $item->payment_method();
808
+		$payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
809
+			: __('Unknown', 'event_espresso');
810
+		$content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
811
+		if ($item->paid() > 0) {
812
+			$content .= '<br><span class="ee-status-text-small">'
813
+						. sprintf(
814
+							__('...via %s', 'event_espresso'),
815
+							$payment_method_name
816
+						)
817
+						. '</span>';
818
+		}
819
+		return $content;
820
+	}
821 821
 
822 822
 
823
-    /**
824
-     * column_TXN_total
825
-     *
826
-     * @access public
827
-     * @param \EE_Registration $item
828
-     * @return string
829
-     * @throws EE_Error
830
-     * @throws EntityNotFoundException
831
-     * @throws InvalidArgumentException
832
-     * @throws InvalidDataTypeException
833
-     * @throws InvalidInterfaceException
834
-     */
835
-    public function column_TXN_total(EE_Registration $item)
836
-    {
837
-        if ($item->transaction()) {
838
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
839
-                'action' => 'view_transaction',
840
-                'TXN_ID' => $item->transaction_ID(),
841
-            ), TXN_ADMIN_URL);
842
-            return EE_Registry::instance()->CAP->current_user_can(
843
-                'ee_read_transaction',
844
-                'espresso_transactions_view_transaction',
845
-                $item->transaction_ID()
846
-            )
847
-                ? '<span class="reg-pad-rght"><a class="status-'
848
-                  . $item->transaction()->status_ID()
849
-                  . '" href="'
850
-                  . $view_txn_lnk_url
851
-                  . '"  title="'
852
-                  . esc_attr__('View Transaction', 'event_espresso')
853
-                  . '">'
854
-                  . $item->transaction()->pretty_total()
855
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
856
-        } else {
857
-            return __("None", "event_espresso");
858
-        }
859
-    }
823
+	/**
824
+	 * column_TXN_total
825
+	 *
826
+	 * @access public
827
+	 * @param \EE_Registration $item
828
+	 * @return string
829
+	 * @throws EE_Error
830
+	 * @throws EntityNotFoundException
831
+	 * @throws InvalidArgumentException
832
+	 * @throws InvalidDataTypeException
833
+	 * @throws InvalidInterfaceException
834
+	 */
835
+	public function column_TXN_total(EE_Registration $item)
836
+	{
837
+		if ($item->transaction()) {
838
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
839
+				'action' => 'view_transaction',
840
+				'TXN_ID' => $item->transaction_ID(),
841
+			), TXN_ADMIN_URL);
842
+			return EE_Registry::instance()->CAP->current_user_can(
843
+				'ee_read_transaction',
844
+				'espresso_transactions_view_transaction',
845
+				$item->transaction_ID()
846
+			)
847
+				? '<span class="reg-pad-rght"><a class="status-'
848
+				  . $item->transaction()->status_ID()
849
+				  . '" href="'
850
+				  . $view_txn_lnk_url
851
+				  . '"  title="'
852
+				  . esc_attr__('View Transaction', 'event_espresso')
853
+				  . '">'
854
+				  . $item->transaction()->pretty_total()
855
+				  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
856
+		} else {
857
+			return __("None", "event_espresso");
858
+		}
859
+	}
860 860
 
861 861
 
862
-    /**
863
-     * column_TXN_paid
864
-     *
865
-     * @access public
866
-     * @param \EE_Registration $item
867
-     * @return string
868
-     * @throws EE_Error
869
-     * @throws EntityNotFoundException
870
-     * @throws InvalidArgumentException
871
-     * @throws InvalidDataTypeException
872
-     * @throws InvalidInterfaceException
873
-     */
874
-    public function column_TXN_paid(EE_Registration $item)
875
-    {
876
-        if ($item->count() === 1) {
877
-            $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
878
-            if ($transaction->paid() >= $transaction->total()) {
879
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
880
-            } else {
881
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
882
-                    'action' => 'view_transaction',
883
-                    'TXN_ID' => $item->transaction_ID(),
884
-                ), TXN_ADMIN_URL);
885
-                return EE_Registry::instance()->CAP->current_user_can(
886
-                    'ee_read_transaction',
887
-                    'espresso_transactions_view_transaction',
888
-                    $item->transaction_ID()
889
-                )
890
-                    ? '<span class="reg-pad-rght"><a class="status-'
891
-                      . $transaction->status_ID()
892
-                      . '" href="'
893
-                      . $view_txn_lnk_url
894
-                      . '"  title="'
895
-                      . esc_attr__('View Transaction', 'event_espresso')
896
-                      . '">'
897
-                      . $item->transaction()->pretty_paid()
898
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
899
-            }
900
-        }
901
-        return '&nbsp;';
902
-    }
862
+	/**
863
+	 * column_TXN_paid
864
+	 *
865
+	 * @access public
866
+	 * @param \EE_Registration $item
867
+	 * @return string
868
+	 * @throws EE_Error
869
+	 * @throws EntityNotFoundException
870
+	 * @throws InvalidArgumentException
871
+	 * @throws InvalidDataTypeException
872
+	 * @throws InvalidInterfaceException
873
+	 */
874
+	public function column_TXN_paid(EE_Registration $item)
875
+	{
876
+		if ($item->count() === 1) {
877
+			$transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
878
+			if ($transaction->paid() >= $transaction->total()) {
879
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
880
+			} else {
881
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
882
+					'action' => 'view_transaction',
883
+					'TXN_ID' => $item->transaction_ID(),
884
+				), TXN_ADMIN_URL);
885
+				return EE_Registry::instance()->CAP->current_user_can(
886
+					'ee_read_transaction',
887
+					'espresso_transactions_view_transaction',
888
+					$item->transaction_ID()
889
+				)
890
+					? '<span class="reg-pad-rght"><a class="status-'
891
+					  . $transaction->status_ID()
892
+					  . '" href="'
893
+					  . $view_txn_lnk_url
894
+					  . '"  title="'
895
+					  . esc_attr__('View Transaction', 'event_espresso')
896
+					  . '">'
897
+					  . $item->transaction()->pretty_paid()
898
+					  . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
899
+			}
900
+		}
901
+		return '&nbsp;';
902
+	}
903 903
 
904 904
 
905
-    /**
906
-     * column_actions
907
-     *
908
-     * @access public
909
-     * @param \EE_Registration $item
910
-     * @return string
911
-     * @throws EE_Error
912
-     * @throws InvalidArgumentException
913
-     * @throws InvalidDataTypeException
914
-     * @throws InvalidInterfaceException
915
-     * @throws ReflectionException
916
-     */
917
-    public function column_actions(EE_Registration $item)
918
-    {
919
-        $actions = array();
920
-        $attendee = $item->attendee();
921
-        $this->_set_related_details($item);
922
-        //Build row actions
923
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
924
-            'action'  => 'view_registration',
925
-            '_REG_ID' => $item->ID(),
926
-        ), REG_ADMIN_URL);
927
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
928
-            'action' => 'edit_attendee',
929
-            'post'   => $item->attendee_ID(),
930
-        ), REG_ADMIN_URL);
931
-        // page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
932
-        //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
933
-        $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
934
-            'action'  => 'resend_registration',
935
-            '_REG_ID' => $item->ID(),
936
-        ), REG_ADMIN_URL, true);
937
-        //Build row actions
938
-        $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can(
939
-            'ee_read_registration',
940
-            'espresso_registrations_view_registration',
941
-            $item->ID()
942
-        ) ? '<li><a href="'
943
-            . $view_lnk_url
944
-            . '" title="'
945
-            . esc_attr__('View Registration Details', 'event_espresso')
946
-            . '" class="tiny-text">
905
+	/**
906
+	 * column_actions
907
+	 *
908
+	 * @access public
909
+	 * @param \EE_Registration $item
910
+	 * @return string
911
+	 * @throws EE_Error
912
+	 * @throws InvalidArgumentException
913
+	 * @throws InvalidDataTypeException
914
+	 * @throws InvalidInterfaceException
915
+	 * @throws ReflectionException
916
+	 */
917
+	public function column_actions(EE_Registration $item)
918
+	{
919
+		$actions = array();
920
+		$attendee = $item->attendee();
921
+		$this->_set_related_details($item);
922
+		//Build row actions
923
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
924
+			'action'  => 'view_registration',
925
+			'_REG_ID' => $item->ID(),
926
+		), REG_ADMIN_URL);
927
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
928
+			'action' => 'edit_attendee',
929
+			'post'   => $item->attendee_ID(),
930
+		), REG_ADMIN_URL);
931
+		// page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
932
+		//$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
933
+		$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
934
+			'action'  => 'resend_registration',
935
+			'_REG_ID' => $item->ID(),
936
+		), REG_ADMIN_URL, true);
937
+		//Build row actions
938
+		$actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can(
939
+			'ee_read_registration',
940
+			'espresso_registrations_view_registration',
941
+			$item->ID()
942
+		) ? '<li><a href="'
943
+			. $view_lnk_url
944
+			. '" title="'
945
+			. esc_attr__('View Registration Details', 'event_espresso')
946
+			. '" class="tiny-text">
947 947
 				<div class="dashicons dashicons-clipboard"></div>
948 948
 			</a>
949 949
 			</li>'
950
-            : '';
951
-        $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can(
952
-            'ee_edit_contacts',
953
-            'espresso_registrations_edit_attendee'
954
-        )
955
-                               && $attendee instanceof EE_Attendee
956
-            ? '
950
+			: '';
951
+		$actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can(
952
+			'ee_edit_contacts',
953
+			'espresso_registrations_edit_attendee'
954
+		)
955
+							   && $attendee instanceof EE_Attendee
956
+			? '
957 957
 			<li>
958 958
 			<a href="' . $edit_lnk_url . '" title="'
959
-              . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
959
+			  . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
960 960
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
961 961
 			</a>
962 962
 			</li>' : '';
963
-        $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
964
-                                     && EE_Registry::instance()->CAP->current_user_can(
965
-                                         'ee_send_message',
966
-                                         'espresso_registrations_resend_registration',
967
-                                         $item->ID()
968
-        )
969
-            ? '
963
+		$actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
964
+									 && EE_Registry::instance()->CAP->current_user_can(
965
+										 'ee_send_message',
966
+										 'espresso_registrations_resend_registration',
967
+										 $item->ID()
968
+		)
969
+			? '
970 970
 			<li>
971 971
 			<a href="'
972
-                 . $resend_reg_lnk_url
973
-                 . '" title="'
974
-                 . esc_attr__('Resend Registration Details', 'event_espresso')
975
-                 . '" class="tiny-text">
972
+				 . $resend_reg_lnk_url
973
+				 . '" title="'
974
+				 . esc_attr__('Resend Registration Details', 'event_espresso')
975
+				 . '" class="tiny-text">
976 976
 				<div class="dashicons dashicons-email-alt"></div>
977 977
 			</a>
978 978
 			</li>' : '';
979
-        // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
980
-        $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
981
-            'action' => 'view_transaction',
982
-            'TXN_ID' => $this->_transaction_details['id'],
983
-        ), TXN_ADMIN_URL);
984
-        $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can(
985
-            'ee_read_transaction',
986
-            'espresso_transactions_view_transaction',
987
-            $this->_transaction_details['id']
988
-        )
989
-            ? '
979
+		// page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
980
+		$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
981
+			'action' => 'view_transaction',
982
+			'TXN_ID' => $this->_transaction_details['id'],
983
+		), TXN_ADMIN_URL);
984
+		$actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can(
985
+			'ee_read_transaction',
986
+			'espresso_transactions_view_transaction',
987
+			$this->_transaction_details['id']
988
+		)
989
+			? '
990 990
 			<li>
991 991
 			<a class="ee-status-color-'
992
-               . $this->_transaction_details['status']
993
-               . ' tiny-text" href="'
994
-               . $view_txn_lnk_url
995
-               . '"  title="'
996
-               . $this->_transaction_details['title_attr']
997
-               . '">
992
+			   . $this->_transaction_details['status']
993
+			   . ' tiny-text" href="'
994
+			   . $view_txn_lnk_url
995
+			   . '"  title="'
996
+			   . $this->_transaction_details['title_attr']
997
+			   . '">
998 998
 				<div class="dashicons dashicons-cart"></div>
999 999
 			</a>
1000 1000
 			</li>' : '';
1001
-        //invoice link
1002
-        $actions['dl_invoice_lnk'] = '';
1003
-        $dl_invoice_lnk_url = $item->invoice_url();
1004
-        //only show invoice link if message type is active.
1005
-        if ($attendee instanceof EE_Attendee
1006
-            && $item->is_primary_registrant()
1007
-            && EEH_MSG_Template::is_mt_active('invoice')
1008
-        ) {
1009
-            $actions['dl_invoice_lnk'] = '
1001
+		//invoice link
1002
+		$actions['dl_invoice_lnk'] = '';
1003
+		$dl_invoice_lnk_url = $item->invoice_url();
1004
+		//only show invoice link if message type is active.
1005
+		if ($attendee instanceof EE_Attendee
1006
+			&& $item->is_primary_registrant()
1007
+			&& EEH_MSG_Template::is_mt_active('invoice')
1008
+		) {
1009
+			$actions['dl_invoice_lnk'] = '
1010 1010
 		<li>
1011 1011
 			<a title="'
1012
-                 . esc_attr__('View Transaction Invoice', 'event_espresso')
1013
-                 . '" target="_blank" href="'
1014
-                 . $dl_invoice_lnk_url
1015
-                 . '" class="tiny-text">
1012
+				 . esc_attr__('View Transaction Invoice', 'event_espresso')
1013
+				 . '" target="_blank" href="'
1014
+				 . $dl_invoice_lnk_url
1015
+				 . '" class="tiny-text">
1016 1016
 				<span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
1017 1017
 			</a>
1018 1018
 		</li>';
1019
-        }
1020
-        $actions['filtered_messages_link'] = '';
1021
-        //message list table link (filtered by REG_ID
1022
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
1023
-            $actions['filtered_messages_link'] = '<li>'
1024
-                     . EEH_MSG_Template::get_message_action_link(
1025
-                         'see_notifications_for',
1026
-                         null,
1027
-                         array('_REG_ID' => $item->ID())
1028
-                     ) . '</li>';
1029
-        }
1030
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1031
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1032
-    }
1019
+		}
1020
+		$actions['filtered_messages_link'] = '';
1021
+		//message list table link (filtered by REG_ID
1022
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
1023
+			$actions['filtered_messages_link'] = '<li>'
1024
+					 . EEH_MSG_Template::get_message_action_link(
1025
+						 'see_notifications_for',
1026
+						 null,
1027
+						 array('_REG_ID' => $item->ID())
1028
+					 ) . '</li>';
1029
+		}
1030
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1031
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1032
+	}
1033 1033
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\exceptions\InvalidDataTypeException;
3 3
 use EventEspresso\core\exceptions\InvalidInterfaceException;
4 4
 
5
-if (! defined('EVENT_ESPRESSO_VERSION')) {
5
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
6 6
     exit('No direct script access allowed');
7 7
 }
8 8
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function __construct(Registrations_Admin_Page $admin_page)
59 59
     {
60
-        if (! empty($_GET['event_id'])) {
60
+        if ( ! empty($_GET['event_id'])) {
61 61
             $extra_query_args = array();
62 62
             foreach ($admin_page->get_views() as $key => $view_details) {
63 63
                 $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         );
158 158
         $this->_primary_column = '_REG_ID';
159 159
         $this->_sortable_columns = array(
160
-            '_REG_date'     => array('_REG_date' => true),   //true means its already sorted
160
+            '_REG_date'     => array('_REG_date' => true), //true means its already sorted
161 161
             /**
162 162
              * Allows users to change the default sort if they wish.
163 163
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     {
190 190
         $class = parent::_get_row_class($item);
191 191
         //add status class
192
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
192
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
193 193
         if ($this->_has_checkbox_column) {
194 194
             $class .= ' has-checkbox-column';
195 195
         }
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
         //setup date query.
355 355
         $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
356 356
             'REG_date',
357
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
357
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
358 358
             'Y-m-d H:i:s'
359 359
         );
360 360
         $end_string = EEM_Registration::instance()->convert_datetime_for_query(
361 361
             'REG_date',
362
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
362
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
363 363
             'Y-m-d H:i:s'
364 364
         );
365 365
         $_where['REG_date'] = array(
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
             array(
397 397
                 EEM_Registration::instance()->convert_datetime_for_query(
398 398
                     'REG_date',
399
-                    $current_date . $time_start,
399
+                    $current_date.$time_start,
400 400
                     'Y-m-d H:i:s'
401 401
                 ),
402 402
                 EEM_Registration::instance()->convert_datetime_for_query(
403 403
                     'REG_date',
404
-                    $current_date . $time_end,
404
+                    $current_date.$time_end,
405 405
                     'Y-m-d H:i:s'
406 406
                 ),
407 407
             ),
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
         $content .= '<div class="show-on-mobile-view-only">';
462 462
         $content .= '<br>';
463 463
         $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
464
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
465
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
464
+        $content .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
465
+        $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
466 466
         $content .= '</div>';
467 467
         return $content;
468 468
     }
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
                   . $event_name
545 545
                   . '</a>' : $event_name;
546 546
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
547
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
547
+            $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="';
548 548
             $actions['event_filter'] .= sprintf(
549 549
                 esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
550 550
                 $event_name
551 551
             );
552
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
552
+            $actions['event_filter'] .= '">'.__('View Registrations', 'event_espresso').'</a>';
553 553
         } else {
554 554
             $edit_event = $event_name;
555 555
             $actions['event_filter'] = '';
@@ -596,11 +596,11 @@  discard block
 block discarded – undo
596 596
     {
597 597
         $content = '<div class="ee-registration-event-datetimes-container">';
598 598
         $expand_toggle = count($datetime_strings) > 1
599
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
599
+            ? ' <span title="'.esc_attr__('Click to view all dates', 'event_espresso')
600 600
               . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
601 601
             : '';
602 602
         //get first item for initial visibility
603
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
603
+        $content .= '<div class="left">'.array_shift($datetime_strings).'</div>';
604 604
         $content .= $expand_toggle;
605 605
         if ($datetime_strings) {
606 606
             $content .= '<div style="clear:both"></div>';
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
         $t = $item->get_first_related('Transaction');
651 651
         $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
652 652
         //append group count to name
653
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
653
+        $link .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
654 654
         //append reg_code
655
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
655
+        $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
656 656
         //reg status text for accessibility
657 657
         $link .= '<br><span class="ee-status-text-small">'
658 658
                  . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
                                 . $trash_lnk_url
675 675
                                 . '" title="'
676 676
                                 . esc_attr__('Trash Registration', 'event_espresso')
677
-                                . '">' . __('Trash', 'event_espresso') . '</a>';
677
+                                . '">'.__('Trash', 'event_espresso').'</a>';
678 678
         } elseif ($this->_view === 'trash') {
679 679
             // restore registration link
680 680
             if (EE_Registry::instance()->CAP->current_user_can(
@@ -689,8 +689,8 @@  discard block
 block discarded – undo
689 689
                 $actions['restore'] = '<a href="'
690 690
                                       . $restore_lnk_url
691 691
                                       . '" title="'
692
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
693
-                                      . __('Restore', 'event_espresso') . '</a>';
692
+                                      . esc_attr__('Restore Registration', 'event_espresso').'">'
693
+                                      . __('Restore', 'event_espresso').'</a>';
694 694
             }
695 695
             if (EE_Registry::instance()->CAP->current_user_can(
696 696
                 'ee_delete_registration',
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
                                                                               . $ticket->name()
763 763
                                                                               . '</span><br />' : '';
764 764
         if ($item->final_price() > 0) {
765
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
765
+            $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
766 766
         } else {
767 767
             // free event
768 768
             $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
             : '<span class="TKT_name">'
790 790
               . $ticket->name()
791 791
               . '</span><br />';
792
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
792
+        $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
793 793
         return $content;
794 794
     }
795 795
 
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
         $payment_method = $item->payment_method();
808 808
         $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
809 809
             : __('Unknown', 'event_espresso');
810
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
810
+        $content = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>';
811 811
         if ($item->paid() > 0) {
812 812
             $content .= '<br><span class="ee-status-text-small">'
813 813
                         . sprintf(
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
                   . esc_attr__('View Transaction', 'event_espresso')
853 853
                   . '">'
854 854
                   . $item->transaction()->pretty_total()
855
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
855
+                  . '</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>';
856 856
         } else {
857 857
             return __("None", "event_espresso");
858 858
         }
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
                       . esc_attr__('View Transaction', 'event_espresso')
896 896
                       . '">'
897 897
                       . $item->transaction()->pretty_paid()
898
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
898
+                      . '</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
899 899
             }
900 900
         }
901 901
         return '&nbsp;';
@@ -955,8 +955,8 @@  discard block
 block discarded – undo
955 955
                                && $attendee instanceof EE_Attendee
956 956
             ? '
957 957
 			<li>
958
-			<a href="' . $edit_lnk_url . '" title="'
959
-              . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
958
+			<a href="' . $edit_lnk_url.'" title="'
959
+              . esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text">
960 960
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
961 961
 			</a>
962 962
 			</li>' : '';
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
                          'see_notifications_for',
1026 1026
                          null,
1027 1027
                          array('_REG_ID' => $item->ID())
1028
-                     ) . '</li>';
1028
+                     ).'</li>';
1029 1029
         }
1030 1030
         $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1031 1031
         return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
Please login to merge, or discard this patch.
admin_pages/maintenance/Maintenance_Admin_Page_Init.core.php 2 patches
Indentation   +84 added lines, -84 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
 
@@ -29,91 +29,91 @@  discard block
 block discarded – undo
29 29
 {
30 30
 
31 31
 
32
-    public function __construct()
33
-    {
34
-        //define some page related constants
35
-        define('EE_MAINTENANCE_LABEL', __('Maintenance', 'event_espresso'));
36
-        define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
37
-        define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
38
-        define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance' . DS);
39
-        define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates' . DS);
40
-        define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
41
-        //check that if we're in maintenance mode that we tell the admin that
42
-        add_action('admin_notices', array($this, 'check_maintenance_mode'));
43
-        parent::__construct();
44
-    }
45
-
46
-
47
-
48
-    protected function _set_init_properties()
49
-    {
50
-        $this->label = EE_MAINTENANCE_LABEL;
51
-    }
52
-
53
-
54
-
55
-    protected function _set_menu_map()
56
-    {
57
-        $menu_map = $this->_menu_map();
58
-        $this->_menu_map = EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance
59
-            ? new EE_Admin_Page_Main_Menu($menu_map) : new EE_Admin_Page_Sub_Menu($menu_map);
60
-    }
61
-
62
-
63
-
64
-    protected function _menu_map()
65
-    {
66
-        $map = array(
67
-            'menu_group'              => 'extras',
68
-            'menu_order'              => 30,
69
-            'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
70
-            'parent_slug'             => 'espresso_events',
71
-            'menu_slug'               => EE_MAINTENANCE_PG_SLUG,
72
-            'menu_label'              => EE_MAINTENANCE_LABEL,
73
-            'capability'              => 'manage_options',
74
-            'maintenance_mode_parent' => EE_MAINTENANCE_PG_SLUG,
75
-            'admin_init_page'         => $this,
76
-        );
77
-        if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
78
-            $map['menu_group'] = 'main';
79
-            $map['subtitle'] = EE_MAINTENANCE_LABEL;
80
-            $map['menu_label'] = __('Event Espresso', 'event_espresso');
81
-        }
82
-        return $map;
83
-    }
84
-
85
-
86
-
87
-    /**
88
-     * Checks if we're in maintenance mode, and if so we notify the admin adn tell them how to take the site OUT of
89
-     * maintenance mode
90
-     */
91
-    public function check_maintenance_mode()
92
-    {
93
-        $notice = '';
94
-        $maintenance_page_url = '';
95
-        if (EE_Maintenance_Mode::instance()->level()) {
96
-            $maintenance_page_url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_MAINTENANCE_ADMIN_URL);
97
-            switch (EE_Maintenance_Mode::instance()->level()) {
98
-                case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
99
-                    $notice = '<div class="update-nag">
32
+	public function __construct()
33
+	{
34
+		//define some page related constants
35
+		define('EE_MAINTENANCE_LABEL', __('Maintenance', 'event_espresso'));
36
+		define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
37
+		define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
38
+		define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance' . DS);
39
+		define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates' . DS);
40
+		define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
41
+		//check that if we're in maintenance mode that we tell the admin that
42
+		add_action('admin_notices', array($this, 'check_maintenance_mode'));
43
+		parent::__construct();
44
+	}
45
+
46
+
47
+
48
+	protected function _set_init_properties()
49
+	{
50
+		$this->label = EE_MAINTENANCE_LABEL;
51
+	}
52
+
53
+
54
+
55
+	protected function _set_menu_map()
56
+	{
57
+		$menu_map = $this->_menu_map();
58
+		$this->_menu_map = EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance
59
+			? new EE_Admin_Page_Main_Menu($menu_map) : new EE_Admin_Page_Sub_Menu($menu_map);
60
+	}
61
+
62
+
63
+
64
+	protected function _menu_map()
65
+	{
66
+		$map = array(
67
+			'menu_group'              => 'extras',
68
+			'menu_order'              => 30,
69
+			'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
70
+			'parent_slug'             => 'espresso_events',
71
+			'menu_slug'               => EE_MAINTENANCE_PG_SLUG,
72
+			'menu_label'              => EE_MAINTENANCE_LABEL,
73
+			'capability'              => 'manage_options',
74
+			'maintenance_mode_parent' => EE_MAINTENANCE_PG_SLUG,
75
+			'admin_init_page'         => $this,
76
+		);
77
+		if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
78
+			$map['menu_group'] = 'main';
79
+			$map['subtitle'] = EE_MAINTENANCE_LABEL;
80
+			$map['menu_label'] = __('Event Espresso', 'event_espresso');
81
+		}
82
+		return $map;
83
+	}
84
+
85
+
86
+
87
+	/**
88
+	 * Checks if we're in maintenance mode, and if so we notify the admin adn tell them how to take the site OUT of
89
+	 * maintenance mode
90
+	 */
91
+	public function check_maintenance_mode()
92
+	{
93
+		$notice = '';
94
+		$maintenance_page_url = '';
95
+		if (EE_Maintenance_Mode::instance()->level()) {
96
+			$maintenance_page_url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_MAINTENANCE_ADMIN_URL);
97
+			switch (EE_Maintenance_Mode::instance()->level()) {
98
+				case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
99
+					$notice = '<div class="update-nag">
100 100
 						'
101
-                              . sprintf(__("Event Espresso is in Frontend-Only MAINTENANCE MODE. This means the front-end (ie, non-wp-admin pages) is disabled for ALL users except site admins. Visit the %s Maintenance Page %s to disable maintenance mode.",
102
-                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>")
103
-                              .
104
-                              '</div>';
105
-                    break;
106
-                case EE_Maintenance_Mode::level_2_complete_maintenance:
107
-                    $notice = '<div class="error">
101
+							  . sprintf(__("Event Espresso is in Frontend-Only MAINTENANCE MODE. This means the front-end (ie, non-wp-admin pages) is disabled for ALL users except site admins. Visit the %s Maintenance Page %s to disable maintenance mode.",
102
+							"event_espresso"), "<a href='$maintenance_page_url'>", "</a>")
103
+							  .
104
+							  '</div>';
105
+					break;
106
+				case EE_Maintenance_Mode::level_2_complete_maintenance:
107
+					$notice = '<div class="error">
108 108
 						<p>' . sprintf(__("As part of the process for updating Event Espresso, your database also
109 109
 needs to be updated. Event Espresso is in COMPLETE MAINTENANCE MODE (both WordPress admin pages and front-end event registration pages are disabled) until you run the database update script. %s Visit the Maintenance Page to get started,%s it only takes a moment.",
110
-                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>") .
111
-                              '</div>';
112
-                    break;
113
-            }
114
-        }
115
-        echo apply_filters('FHEE__Maintenance_Admin_Page_Init__check_maintenance_mode__notice', $notice,
116
-            $maintenance_page_url);
117
-    }
110
+							"event_espresso"), "<a href='$maintenance_page_url'>", "</a>") .
111
+							  '</div>';
112
+					break;
113
+			}
114
+		}
115
+		echo apply_filters('FHEE__Maintenance_Admin_Page_Init__check_maintenance_mode__notice', $notice,
116
+			$maintenance_page_url);
117
+	}
118 118
 
119 119
 } //end class Payments_Admin_Page_Init
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
         //define some page related constants
35 35
         define('EE_MAINTENANCE_LABEL', __('Maintenance', 'event_espresso'));
36 36
         define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
37
-        define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
38
-        define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance' . DS);
39
-        define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates' . DS);
40
-        define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
37
+        define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page='.EE_MAINTENANCE_PG_SLUG));
38
+        define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES.'maintenance'.DS);
39
+        define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN.'templates'.DS);
40
+        define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL.'maintenance/assets/');
41 41
         //check that if we're in maintenance mode that we tell the admin that
42 42
         add_action('admin_notices', array($this, 'check_maintenance_mode'));
43 43
         parent::__construct();
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     $notice = '<div class="error">
108 108
 						<p>' . sprintf(__("As part of the process for updating Event Espresso, your database also
109 109
 needs to be updated. Event Espresso is in COMPLETE MAINTENANCE MODE (both WordPress admin pages and front-end event registration pages are disabled) until you run the database update script. %s Visit the Maintenance Page to get started,%s it only takes a moment.",
110
-                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>") .
110
+                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>").
111 111
                               '</div>';
112 112
                     break;
113 113
             }
Please login to merge, or discard this patch.
modules/invalid_checkout_access/InvalidCheckoutAccess.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 		if (
40 40
 			! ( $checkout->uts || $checkout->reg_url_link )
41 41
 			&& ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
42
-            && \EE_Config::instance()->registration->track_invalid_checkout_access()
43
-        ) {
42
+			&& \EE_Config::instance()->registration->track_invalid_checkout_access()
43
+		) {
44 44
 			/** @var \EE_Request $request */
45 45
 			$request = \EE_Registry::instance()->load_core( 'EE_Request' );
46 46
 			$ip_address = $request->ip_address();
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 			}
61 61
 			$ee_bot_checkout[ $ip_address ][ $http_referer ]++;
62 62
 			update_option( InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout );
63
-            if (WP_DEBUG) {
64
-                \EE_Error::add_error(
65
-                    esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'),
66
-                    __FILE__,
67
-                    __FUNCTION__,
68
-                    __LINE__
69
-                );
70
-            }
63
+			if (WP_DEBUG) {
64
+				\EE_Error::add_error(
65
+					esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'),
66
+					__FILE__,
67
+					__FUNCTION__,
68
+					__LINE__
69
+				);
70
+			}
71 71
 			return true;
72 72
 		}
73 73
 		return false;
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\modules\invalid_checkout_access;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -35,31 +35,31 @@  discard block
 block discarded – undo
35 35
 	 * @param \EE_Checkout $checkout
36 36
 	 * @return bool true if access to registration checkout appears to be invalid
37 37
 	 */
38
-	public function checkoutAccessIsInvalid( \EE_Checkout $checkout ) {
38
+	public function checkoutAccessIsInvalid(\EE_Checkout $checkout) {
39 39
 		if (
40
-			! ( $checkout->uts || $checkout->reg_url_link )
41
-			&& ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
40
+			! ($checkout->uts || $checkout->reg_url_link)
41
+			&& ! (defined('DOING_AJAX') && DOING_AJAX)
42 42
             && \EE_Config::instance()->registration->track_invalid_checkout_access()
43 43
         ) {
44 44
 			/** @var \EE_Request $request */
45
-			$request = \EE_Registry::instance()->load_core( 'EE_Request' );
45
+			$request = \EE_Registry::instance()->load_core('EE_Request');
46 46
 			$ip_address = $request->ip_address();
47
-			$ee_bot_checkout = get_option( InvalidCheckoutAccess::OPTION_KEY );
48
-			if ( $ee_bot_checkout === false ) {
47
+			$ee_bot_checkout = get_option(InvalidCheckoutAccess::OPTION_KEY);
48
+			if ($ee_bot_checkout === false) {
49 49
 				$ee_bot_checkout = array();
50
-				add_option( InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false );
50
+				add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false);
51 51
 			}
52
-			if ( ! isset( $ee_bot_checkout[ $ip_address ] ) ) {
53
-				$ee_bot_checkout[ $ip_address ] = array();
52
+			if ( ! isset($ee_bot_checkout[$ip_address])) {
53
+				$ee_bot_checkout[$ip_address] = array();
54 54
 			}
55
-			$http_referer = isset( $_SERVER['HTTP_REFERER'] )
56
-				? esc_attr( $_SERVER['HTTP_REFERER'] )
55
+			$http_referer = isset($_SERVER['HTTP_REFERER'])
56
+				? esc_attr($_SERVER['HTTP_REFERER'])
57 57
 				: 0;
58
-			if ( ! isset( $ee_bot_checkout[ $ip_address ][ $http_referer ] ) ) {
59
-				$ee_bot_checkout[ $ip_address ][ $http_referer ] = 0;
58
+			if ( ! isset($ee_bot_checkout[$ip_address][$http_referer])) {
59
+				$ee_bot_checkout[$ip_address][$http_referer] = 0;
60 60
 			}
61
-			$ee_bot_checkout[ $ip_address ][ $http_referer ]++;
62
-			update_option( InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout );
61
+			$ee_bot_checkout[$ip_address][$http_referer]++;
62
+			update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout);
63 63
             if (WP_DEBUG) {
64 64
                 \EE_Error::add_error(
65 65
                     esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'),
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 				'layout_strategy' => new \EE_Admin_Two_Column_Layout(),
89 89
 				'subsections'     => array(
90 90
 					'invalid_checkout_access_hdr'   => new \EE_Form_Section_HTML(
91
-						\EEH_HTML::h2( esc_html__( 'Invalid Checkout Access', 'event_espresso' ) )
91
+						\EEH_HTML::h2(esc_html__('Invalid Checkout Access', 'event_espresso'))
92 92
 					),
93 93
 					'ee_bot_checkout_data'          => new \EE_Text_Area_Input(
94 94
 						array(
95
-							'html_label_text' => esc_html__( 'Invalid Checkout Data', 'event_espresso' ),
95
+							'html_label_text' => esc_html__('Invalid Checkout Data', 'event_espresso'),
96 96
 							'default'         => var_export(
97
-								get_option( InvalidCheckoutAccess::OPTION_KEY, array() ),
97
+								get_option(InvalidCheckoutAccess::OPTION_KEY, array()),
98 98
 								true
99 99
 							),
100 100
 							'required'        => false,
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 					),
107 107
 					'track_invalid_checkout_access' => new \EE_Yes_No_Input(
108 108
 						array(
109
-							'html_label_text'         => __( 'Track Invalid Checkout Access?', 'event_espresso' ),
109
+							'html_label_text'         => __('Track Invalid Checkout Access?', 'event_espresso'),
110 110
 							'html_help_text'          => esc_html__(
111 111
 								'Controls whether or not invalid attempts to directly access the registration checkout page should be tracked. Setting this to "No" means that the above data will no longer be collected.',
112 112
 								'event_espresso'
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 					),
120 120
 					'delete_invalid_checkout_data'  => new \EE_Yes_No_Input(
121 121
 						array(
122
-							'html_label_text'         => __( 'Reset Invalid Checkout Data', 'event_espresso' ),
122
+							'html_label_text'         => __('Reset Invalid Checkout Data', 'event_espresso'),
123 123
 							'html_help_text'          => esc_html__(
124 124
 								'Setting this to "Yes" will delete all existing invalid checkout access data.',
125 125
 								'event_espresso'
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
 	 * @param \EE_Registration_Config $EE_Registration_Config
142 142
 	 * @return \EE_Registration_Config
143 143
 	 */
144
-	public function processForm( \EE_Registration_Config $EE_Registration_Config ) {
144
+	public function processForm(\EE_Registration_Config $EE_Registration_Config) {
145 145
 		try {
146 146
 			$invalid_checkout_access_form = $this->getForm();
147 147
 			// if not displaying a form, then check for form submission
148
-			if ( $invalid_checkout_access_form->was_submitted() ) {
148
+			if ($invalid_checkout_access_form->was_submitted()) {
149 149
 				// capture form data
150 150
 				$invalid_checkout_access_form->receive_form_submission();
151 151
 				// validate form data
152
-				if ( $invalid_checkout_access_form->is_valid() ) {
152
+				if ($invalid_checkout_access_form->is_valid()) {
153 153
 					// grab validated data from form
154 154
 					$valid_data = $invalid_checkout_access_form->valid_data();
155 155
 					// ensure form inputs we want are set
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 							$valid_data['track_invalid_checkout_access']
164 164
 						);
165 165
 						// if deleting, then update option with empty array
166
-						if ( filter_var( $valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN ) ) {
167
-							update_option( InvalidCheckoutAccess::OPTION_KEY, array() );
166
+						if (filter_var($valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN)) {
167
+							update_option(InvalidCheckoutAccess::OPTION_KEY, array());
168 168
 						}
169 169
 					} else {
170 170
 						\EE_Error::add_error(
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 						);
179 179
 					}
180 180
 				} else {
181
-					if ( $invalid_checkout_access_form->submission_error_message() !== '' ) {
181
+					if ($invalid_checkout_access_form->submission_error_message() !== '') {
182 182
 						\EE_Error::add_error(
183 183
 							$invalid_checkout_access_form->submission_error_message(),
184 184
 							__FILE__,
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 					}
189 189
 				}
190 190
 			}
191
-		} catch ( \EE_Error $e ) {
191
+		} catch (\EE_Error $e) {
192 192
 			$e->get_error();
193 193
 		}
194 194
 		return $EE_Registration_Config;
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_1_0.dms.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1421,7 +1421,6 @@  discard block
 block discarded – undo
1421 1421
      * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1422 1422
      * and sets it as the featured image on the CPT event
1423 1423
      *
1424
-     * @param type                            $old_event
1425 1424
      * @param type                            $new_cpt_id
1426 1425
      * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1427 1426
      * @return boolean whether or not we had to do the big job of creating an image attachment
@@ -1483,7 +1482,7 @@  discard block
 block discarded – undo
1483 1482
      * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1484 1483
      * thumbnails)
1485 1484
      *
1486
-     * @param type                           $guid
1485
+     * @param string                           $guid
1487 1486
      * @param EE_Data_Migration_Script_Stage $migration_stage
1488 1487
      * @return int
1489 1488
      */
@@ -1571,7 +1570,7 @@  discard block
 block discarded – undo
1571 1570
      * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1572 1571
      * (and optionally a timezone; if none is given, the wp DEFAULT is used)
1573 1572
      *
1574
-     * @param EE_Data_Migration_Script_base $stage
1573
+     * @param EE_Data_Migration_Script_Stage $stage
1575 1574
      * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1576 1575
      *                                                   UTC time for
1577 1576
      * @param string                        $DATETIME_string
Please login to merge, or discard this patch.
Indentation   +1137 added lines, -1137 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 $stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 if ( ! empty($stages)) {
15
-    foreach ($stages as $filepath) {
16
-        $matches = array();
17
-        preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
-        $class_to_filepath[$matches[1]] = $filepath;
19
-    }
15
+	foreach ($stages as $filepath) {
16
+		$matches = array();
17
+		preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
+		$class_to_filepath[$matches[1]] = $filepath;
19
+	}
20 20
 }
21 21
 //give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath);
@@ -44,91 +44,91 @@  discard block
 block discarded – undo
44 44
 
45 45
 
46 46
 
47
-    /**
48
-     * EE_DMS_Core_4_1_0 constructor.
49
-     *
50
-     * @param TableManager  $table_manager
51
-     * @param TableAnalysis $table_analysis
52
-     */
53
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
54
-    {
55
-        $this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso");
56
-        $this->_priority = 10;
57
-        $this->_migration_stages = array(
58
-                new EE_DMS_4_1_0_org_options(),
59
-                new EE_DMS_4_1_0_shortcodes(),
60
-                new EE_DMS_4_1_0_gateways(),
61
-                new EE_DMS_4_1_0_events(),
62
-                new EE_DMS_4_1_0_prices(),
63
-                new EE_DMS_4_1_0_category_details(),
64
-                new EE_DMS_4_1_0_event_category(),
65
-                new EE_DMS_4_1_0_venues(),
66
-                new EE_DMS_4_1_0_event_venue(),
67
-                new EE_DMS_4_1_0_question_groups(),
68
-                new EE_DMS_4_1_0_questions(),
69
-                new EE_DMS_4_1_0_question_group_question(),
70
-                new EE_DMS_4_1_0_event_question_group(),
71
-                new EE_DMS_4_1_0_attendees(),
72
-                new EE_DMS_4_1_0_line_items(),
73
-                new EE_DMS_4_1_0_answers(),
74
-                new EE_DMS_4_1_0_checkins(),
75
-        );
76
-        parent::__construct($table_manager, $table_analysis);
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
83
-     *
84
-     * @global wpdb $wpdb
85
-     * @return boolean
86
-     */
87
-    private function _checkin_table_exists()
88
-    {
89
-        global $wpdb;
90
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
91
-        if ($results) {
92
-            return true;
93
-        } else {
94
-            return false;
95
-        }
96
-    }
97
-
98
-
99
-
100
-    public function can_migrate_from_version($version_array)
101
-    {
102
-        $version_string = $version_array['Core'];
103
-        if (version_compare($version_string, '4.0.0', '<=') && version_compare($version_string, '3.1.26', '>=')) {
47
+	/**
48
+	 * EE_DMS_Core_4_1_0 constructor.
49
+	 *
50
+	 * @param TableManager  $table_manager
51
+	 * @param TableAnalysis $table_analysis
52
+	 */
53
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
54
+	{
55
+		$this->_pretty_name = esc_html__("Data Migration from Event Espresso 3 to Event Espresso 4.1.0", "event_espresso");
56
+		$this->_priority = 10;
57
+		$this->_migration_stages = array(
58
+				new EE_DMS_4_1_0_org_options(),
59
+				new EE_DMS_4_1_0_shortcodes(),
60
+				new EE_DMS_4_1_0_gateways(),
61
+				new EE_DMS_4_1_0_events(),
62
+				new EE_DMS_4_1_0_prices(),
63
+				new EE_DMS_4_1_0_category_details(),
64
+				new EE_DMS_4_1_0_event_category(),
65
+				new EE_DMS_4_1_0_venues(),
66
+				new EE_DMS_4_1_0_event_venue(),
67
+				new EE_DMS_4_1_0_question_groups(),
68
+				new EE_DMS_4_1_0_questions(),
69
+				new EE_DMS_4_1_0_question_group_question(),
70
+				new EE_DMS_4_1_0_event_question_group(),
71
+				new EE_DMS_4_1_0_attendees(),
72
+				new EE_DMS_4_1_0_line_items(),
73
+				new EE_DMS_4_1_0_answers(),
74
+				new EE_DMS_4_1_0_checkins(),
75
+		);
76
+		parent::__construct($table_manager, $table_analysis);
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
83
+	 *
84
+	 * @global wpdb $wpdb
85
+	 * @return boolean
86
+	 */
87
+	private function _checkin_table_exists()
88
+	{
89
+		global $wpdb;
90
+		$results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
91
+		if ($results) {
92
+			return true;
93
+		} else {
94
+			return false;
95
+		}
96
+	}
97
+
98
+
99
+
100
+	public function can_migrate_from_version($version_array)
101
+	{
102
+		$version_string = $version_array['Core'];
103
+		if (version_compare($version_string, '4.0.0', '<=') && version_compare($version_string, '3.1.26', '>=')) {
104 104
 //			echo "$version_string can be migrated fro";
105
-            return true;
106
-        } elseif ( ! $version_string) {
105
+			return true;
106
+		} elseif ( ! $version_string) {
107 107
 //			echo "no version string provided: $version_string";
108
-            //no version string provided... this must be pre 4.1
109
-            //because since 4.1 we're
110
-            return false;//changed mind. dont want people thinking they should migrate yet because they cant
111
-        } else {
108
+			//no version string provided... this must be pre 4.1
109
+			//because since 4.1 we're
110
+			return false;//changed mind. dont want people thinking they should migrate yet because they cant
111
+		} else {
112 112
 //			echo "$version_string doesnt apply";
113
-            return false;
114
-        }
115
-    }
113
+			return false;
114
+		}
115
+	}
116 116
 
117 117
 
118 118
 
119
-    public function schema_changes_before_migration()
120
-    {
121
-        //relies on 4.1's EEH_Activation::create_table
122
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
123
-        $table_name = 'esp_answer';
124
-        $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
119
+	public function schema_changes_before_migration()
120
+	{
121
+		//relies on 4.1's EEH_Activation::create_table
122
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
123
+		$table_name = 'esp_answer';
124
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
125 125
 					REG_ID INT UNSIGNED NOT NULL,
126 126
 					QST_ID INT UNSIGNED NOT NULL,
127 127
 					ANS_value TEXT NOT NULL,
128 128
 					PRIMARY KEY  (ANS_ID)";
129
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
130
-        $table_name = 'esp_attendee_meta';
131
-        $sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
129
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
130
+		$table_name = 'esp_attendee_meta';
131
+		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
132 132
 						ATT_ID BIGINT(20) UNSIGNED NOT NULL,
133 133
 						ATT_fname VARCHAR(45) NOT NULL,
134 134
 						ATT_lname VARCHAR(45) NOT	NULL,
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 								KEY ATT_fname (ATT_fname),
145 145
 								KEY ATT_lname (ATT_lname),
146 146
 								KEY ATT_email (ATT_email)";
147
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
148
-        $table_name = 'esp_country';
149
-        $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
147
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
148
+		$table_name = 'esp_country';
149
+		$sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
150 150
 					  CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL,
151 151
 					  RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL,
152 152
 					  CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL,
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
163 163
 					  CNT_active TINYINT(1) DEFAULT '0',
164 164
 					  PRIMARY KEY  (CNT_ISO)";
165
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
166
-        $table_name = 'esp_datetime';
167
-        $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
165
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
166
+		$table_name = 'esp_datetime';
167
+		$sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
168 168
 				  EVT_ID BIGINT(20) UNSIGNED NOT NULL,
169 169
 				  DTT_EVT_start DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
170 170
 				  DTT_EVT_end DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 						PRIMARY KEY  (DTT_ID),
178 178
 						KEY EVT_ID (EVT_ID),
179 179
 						KEY DTT_is_primary (DTT_is_primary)";
180
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
181
-        $table_name = 'esp_event_meta';
182
-        $sql = "
180
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
181
+		$table_name = 'esp_event_meta';
182
+		$sql = "
183 183
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
184 184
 			EVT_ID BIGINT(20) UNSIGNED NOT NULL,
185 185
 			EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -194,31 +194,31 @@  discard block
 block discarded – undo
194 194
 			EVT_external_URL VARCHAR(200) NULL,
195 195
 			EVT_donations TINYINT(1) NULL,
196 196
 			PRIMARY KEY  (EVTM_ID)";
197
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
198
-        $table_name = 'esp_event_question_group';
199
-        $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
197
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
198
+		$table_name = 'esp_event_question_group';
199
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
200 200
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
201 201
 					QSG_ID INT UNSIGNED NOT NULL,
202 202
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
203 203
 					PRIMARY KEY  (EQG_ID)";
204
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205
-        $table_name = 'esp_event_venue';
206
-        $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
204
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205
+		$table_name = 'esp_event_venue';
206
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
207 207
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
208 208
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
209 209
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
210 210
 				PRIMARY KEY  (EVV_ID)";
211
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
212
-        $table_name = 'esp_extra_meta';
213
-        $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
211
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
212
+		$table_name = 'esp_extra_meta';
213
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
214 214
 				OBJ_ID INT(11) DEFAULT NULL,
215 215
 				EXM_type VARCHAR(45) DEFAULT NULL,
216 216
 				EXM_key VARCHAR(45) DEFAULT NULL,
217 217
 				EXM_value TEXT,
218 218
 				PRIMARY KEY  (EXM_ID)";
219
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
220
-        $table_name = 'esp_line_item';
221
-        $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
219
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
220
+		$table_name = 'esp_line_item';
221
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
222 222
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
223 223
 				TXN_ID INT(11) DEFAULT NULL,
224 224
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -234,18 +234,18 @@  discard block
 block discarded – undo
234 234
 				OBJ_ID INT(11) DEFAULT NULL,
235 235
 				OBJ_type VARCHAR(45)DEFAULT NULL,
236 236
 				PRIMARY KEY  (LIN_ID)";
237
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238
-        $table_name = 'esp_message_template';
239
-        $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
237
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238
+		$table_name = 'esp_message_template';
239
+		$sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
240 240
 					GRP_ID INT(10) UNSIGNED NOT NULL,
241 241
 					MTP_context VARCHAR(50) NOT NULL,
242 242
 					MTP_template_field VARCHAR(30) NOT NULL,
243 243
 					MTP_content TEXT NOT NULL,
244 244
 					PRIMARY KEY  (MTP_ID),
245 245
 					KEY GRP_ID (GRP_ID)";
246
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
-        $table_name = 'esp_message_template_group';
248
-        $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
246
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247
+		$table_name = 'esp_message_template_group';
248
+		$sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
249 249
 					EVT_ID BIGINT(20) UNSIGNED DEFAULT NULL,
250 250
 					MTP_user_id INT(10) NOT NULL DEFAULT '1',
251 251
 					MTP_messenger VARCHAR(30) NOT NULL,
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 					PRIMARY KEY  (GRP_ID),
258 258
 					KEY EVT_ID (EVT_ID),
259 259
 					KEY MTP_user_id (MTP_user_id)";
260
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
261
-        $table_name = 'esp_payment';
262
-        $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
260
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
261
+		$table_name = 'esp_payment';
262
+		$sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
263 263
 					TXN_ID INT(10) UNSIGNED DEFAULT NULL,
264 264
 					STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL,
265 265
 					PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 					PRIMARY KEY  (PAY_ID),
276 276
 					KEY TXN_ID (TXN_ID),
277 277
 					KEY PAY_timestamp (PAY_timestamp)";
278
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
279
-        $table_name = "esp_ticket";
280
-        $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
278
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
279
+		$table_name = "esp_ticket";
280
+		$sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
281 281
 					  TTM_ID INT(10) UNSIGNED NOT NULL,
282 282
 					  TKT_name VARCHAR(245) NOT NULL DEFAULT '',
283 283
 					  TKT_description TEXT NOT NULL,
@@ -296,28 +296,28 @@  discard block
 block discarded – undo
296 296
 					  TKT_parent INT(10) UNSIGNED DEFAULT '0',
297 297
 					  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',
298 298
 					  PRIMARY KEY  (TKT_ID)";
299
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
300
-        $table_name = "esp_ticket_price";
301
-        $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
299
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
300
+		$table_name = "esp_ticket_price";
301
+		$sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
302 302
 					  TKT_ID INT(10) UNSIGNED NOT NULL,
303 303
 					  PRC_ID INT(10) UNSIGNED NOT NULL,
304 304
 					  PRIMARY KEY  (TKP_ID)";
305
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
306
-        $table_name = "esp_datetime_ticket";
307
-        $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
305
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
306
+		$table_name = "esp_datetime_ticket";
307
+		$sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
308 308
 					  DTT_ID INT(10) UNSIGNED NOT NULL,
309 309
 					  TKT_ID INT(10) UNSIGNED NOT NULL,
310 310
 					  PRIMARY KEY  (DTK_ID)";
311
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
312
-        $table_name = "esp_ticket_template";
313
-        $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
311
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
312
+		$table_name = "esp_ticket_template";
313
+		$sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
314 314
 					  TTM_name VARCHAR(45) NOT NULL,
315 315
 					  TTM_description TEXT,
316 316
 					  TTM_file VARCHAR(45),
317 317
 					  PRIMARY KEY  (TTM_ID)";
318
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
319
-        $table_name = "esp_price";
320
-        $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
318
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
319
+		$table_name = "esp_price";
320
+		$sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
321 321
 					  PRT_ID TINYINT(3) UNSIGNED NOT NULL,
322 322
 					  PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00',
323 323
 					  PRC_name VARCHAR(245) NOT NULL,
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 					  PRC_order TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
329 329
 					  PRC_parent INT(10) UNSIGNED DEFAULT 0,
330 330
 					  PRIMARY KEY  (PRC_ID)";
331
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
332
-        $table_name = "esp_price_type";
333
-        $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
331
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
332
+		$table_name = "esp_price_type";
333
+		$sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
334 334
 				  PRT_name VARCHAR(45) NOT NULL,
335 335
 				  PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
336 336
 				  PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0',
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
 				  PRT_deleted TINYINT(1) NOT NULL DEFAULT '0',
339 339
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
340 340
 				  PRIMARY KEY  (PRT_ID)";
341
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
342
-        $table_name = 'esp_question';
343
-        $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
341
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
342
+		$table_name = 'esp_question';
343
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
344 344
 					QST_display_text TEXT NOT NULL,
345 345
 					QST_admin_label VARCHAR(255) NOT NULL,
346 346
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 					QST_wp_user BIGINT UNSIGNED NULL,
353 353
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
354 354
 					PRIMARY KEY  (QST_ID)';
355
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
356
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
357
-        $table_name = 'esp_question_group';
358
-        $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
355
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
356
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
357
+		$table_name = 'esp_question_group';
358
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
359 359
 					QSG_name VARCHAR(255) NOT NULL,
360 360
 					QSG_identifier VARCHAR(100) NOT NULL,
361 361
 					QSG_desc TEXT NULL,
@@ -366,23 +366,23 @@  discard block
 block discarded – undo
366 366
 					QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
367 367
 					PRIMARY KEY  (QSG_ID),
368 368
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
369
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
370
-        $table_name = 'esp_question_group_question';
371
-        $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
369
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
370
+		$table_name = 'esp_question_group_question';
371
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
372 372
 					QSG_ID INT UNSIGNED NOT NULL,
373 373
 					QST_ID INT UNSIGNED NOT NULL,
374 374
 					PRIMARY KEY  (QGQ_ID) ";
375
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
-        $table_name = 'esp_question_option';
377
-        $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
375
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
376
+		$table_name = 'esp_question_option';
377
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
378 378
 					QSO_value VARCHAR(255) NOT NULL,
379 379
 					QSO_desc TEXT NOT NULL,
380 380
 					QST_ID INT UNSIGNED NOT NULL,
381 381
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
382 382
 					PRIMARY KEY  (QSO_ID)";
383
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
384
-        $table_name = 'esp_registration';
385
-        $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
383
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
384
+		$table_name = 'esp_registration';
385
+		$sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
386 386
 					  EVT_ID BIGINT(20) UNSIGNED NOT NULL,
387 387
 					  ATT_ID BIGINT(20) UNSIGNED NOT NULL,
388 388
 					  TXN_ID INT(10) UNSIGNED NOT NULL,
@@ -405,25 +405,25 @@  discard block
 block discarded – undo
405 405
 					  KEY STS_ID (STS_ID),
406 406
 					  KEY REG_url_link (REG_url_link),
407 407
 					  KEY REG_code (REG_code)";
408
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
409
-        $table_name = 'esp_checkin';
410
-        $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
408
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
409
+		$table_name = 'esp_checkin';
410
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
411 411
 					REG_ID INT(10) UNSIGNED NOT NULL,
412 412
 					DTT_ID INT(10) UNSIGNED NOT NULL,
413 413
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
414 414
 					CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
415 415
 					PRIMARY KEY  (CHK_ID)";
416
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
417
-        $table_name = 'esp_state';
418
-        $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT,
416
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
417
+		$table_name = 'esp_state';
418
+		$sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT,
419 419
 					  CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
420 420
 					  STA_abbrev VARCHAR(6) COLLATE utf8_bin NOT NULL,
421 421
 					  STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL,
422 422
 					  STA_active TINYINT(1) DEFAULT '1',
423 423
 					  PRIMARY KEY  (STA_ID)";
424
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
425
-        $table_name = 'esp_status';
426
-        $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL,
424
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
425
+		$table_name = 'esp_status';
426
+		$sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL,
427 427
 					  STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL,
428 428
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
429 429
 					  STS_can_edit TINYINT(1) NOT NULL DEFAULT 0,
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
 					  STS_open TINYINT(1) NOT NULL DEFAULT 1,
432 432
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
433 433
 					  KEY STS_type (STS_type)";
434
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
435
-        $table_name = 'esp_transaction';
436
-        $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
434
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
435
+		$table_name = 'esp_transaction';
436
+		$sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
437 437
 					  TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
438 438
 					  TXN_total DECIMAL(10,3) DEFAULT '0.00',
439 439
 					  TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00',
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
 					  PRIMARY KEY  (TXN_ID),
444 444
 					  KEY TXN_timestamp (TXN_timestamp),
445 445
 					  KEY STS_ID (STS_ID)";
446
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
447
-        $table_name = 'esp_venue_meta';
448
-        $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT,
446
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
447
+		$table_name = 'esp_venue_meta';
448
+		$sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT,
449 449
 			VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
450 450
 			VNU_address VARCHAR(255) DEFAULT NULL,
451 451
 			VNU_address2 VARCHAR(255) DEFAULT NULL,
@@ -463,52 +463,52 @@  discard block
 block discarded – undo
463 463
 			PRIMARY KEY  (VNUM_ID),
464 464
 			KEY STA_ID (STA_ID),
465 465
 			KEY CNT_ISO (CNT_ISO)";
466
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
467
-        //setting up the DEFAULT stats and countries is also essential for the data migrations to run
468
-        //(because many need to convert old string states to foreign keys into the states table)
469
-        $this->insert_default_states();
470
-        $this->insert_default_countries();
471
-        //setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
472
-        $this->insert_default_price_types();
473
-        $this->insert_default_prices();
474
-        $this->insert_default_tickets();
475
-        //setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
476
-        EE_Config::instance()->update_espresso_config(false, true);
477
-        return true;
478
-    }
479
-
480
-
481
-
482
-    /**
483
-     * Yes we could have cleaned up the ee3 tables here. But just in case someone
484
-     * didn't backup their DB, and decides they want ot keep using EE3, we'll
485
-     * leave them for now. Mayeb remove them in 4.5 or something.
486
-     *
487
-     * @return boolean
488
-     */
489
-    public function schema_changes_after_migration()
490
-    {
491
-        return true;
492
-    }
493
-
494
-
495
-
496
-    /**
497
-     * insert_default_states
498
-     *
499
-     * @access public
500
-     * @static
501
-     * @return void
502
-     */
503
-    public function insert_default_states()
504
-    {
505
-        global $wpdb;
506
-        $state_table = $wpdb->prefix . "esp_state";
507
-        if ($this->_get_table_analysis()->tableExists($state_table)) {
508
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
509
-            $states = $wpdb->get_var($SQL);
510
-            if ( ! $states) {
511
-                $SQL = "INSERT INTO " . $state_table . "
466
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
467
+		//setting up the DEFAULT stats and countries is also essential for the data migrations to run
468
+		//(because many need to convert old string states to foreign keys into the states table)
469
+		$this->insert_default_states();
470
+		$this->insert_default_countries();
471
+		//setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
472
+		$this->insert_default_price_types();
473
+		$this->insert_default_prices();
474
+		$this->insert_default_tickets();
475
+		//setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
476
+		EE_Config::instance()->update_espresso_config(false, true);
477
+		return true;
478
+	}
479
+
480
+
481
+
482
+	/**
483
+	 * Yes we could have cleaned up the ee3 tables here. But just in case someone
484
+	 * didn't backup their DB, and decides they want ot keep using EE3, we'll
485
+	 * leave them for now. Mayeb remove them in 4.5 or something.
486
+	 *
487
+	 * @return boolean
488
+	 */
489
+	public function schema_changes_after_migration()
490
+	{
491
+		return true;
492
+	}
493
+
494
+
495
+
496
+	/**
497
+	 * insert_default_states
498
+	 *
499
+	 * @access public
500
+	 * @static
501
+	 * @return void
502
+	 */
503
+	public function insert_default_states()
504
+	{
505
+		global $wpdb;
506
+		$state_table = $wpdb->prefix . "esp_state";
507
+		if ($this->_get_table_analysis()->tableExists($state_table)) {
508
+			$SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
509
+			$states = $wpdb->get_var($SQL);
510
+			if ( ! $states) {
511
+				$SQL = "INSERT INTO " . $state_table . "
512 512
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
513 513
 				(1, 'US', 'AK', 'Alaska', 1),
514 514
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -579,29 +579,29 @@  discard block
 block discarded – undo
579 579
 				(67, 'CA', 'PE', 'Prince Edward Island', 1),
580 580
 				(68, 'CA', 'QC', 'Quebec', 1),
581 581
 				(69, 'CA', 'SK', 'Saskatchewan', 1);";
582
-                $wpdb->query($SQL);
583
-            }
584
-        }
585
-    }
586
-
587
-
588
-
589
-    /**
590
-     * insert_default_countries
591
-     *
592
-     * @access public
593
-     * @static
594
-     * @return void
595
-     */
596
-    public function insert_default_countries()
597
-    {
598
-        global $wpdb;
599
-        $country_table = $wpdb->prefix . "esp_country";
600
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
601
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
602
-            $countries = $wpdb->get_var($SQL);
603
-            if ( ! $countries) {
604
-                $SQL = "INSERT INTO " . $country_table . "
582
+				$wpdb->query($SQL);
583
+			}
584
+		}
585
+	}
586
+
587
+
588
+
589
+	/**
590
+	 * insert_default_countries
591
+	 *
592
+	 * @access public
593
+	 * @static
594
+	 * @return void
595
+	 */
596
+	public function insert_default_countries()
597
+	{
598
+		global $wpdb;
599
+		$country_table = $wpdb->prefix . "esp_country";
600
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
601
+			$SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
602
+			$countries = $wpdb->get_var($SQL);
603
+			if ( ! $countries) {
604
+				$SQL = "INSERT INTO " . $country_table . "
605 605
 				(CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES
606 606
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
607 607
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -829,941 +829,941 @@  discard block
 block discarded – undo
829 829
 				('ZA', 'ZAF', 0, 'South Africa', 'ZAR', 'Rand', 'Rands', 'R', 1, 2, '+27', 0, 0),
830 830
 				('ZM', 'ZMB', 0, 'Zambia', 'ZMK', 'Kwacha', 'Kwachas', '', 1, 2, '+260', 0, 0),
831 831
 				('ZW', 'ZWE', 0, 'Zimbabwe', 'ZWD', 'Dollar', 'Dollars', 'Z$', 1, 2, '+263', 0, 0);";
832
-                $wpdb->query($SQL);
833
-            }
834
-        }
835
-    }
836
-
837
-
838
-
839
-    /**
840
-     * insert_default_price_types
841
-     *
842
-     * @access public
843
-     * @static
844
-     * @return void
845
-     */
846
-    public function insert_default_price_types()
847
-    {
848
-        global $wpdb;
849
-        $price_type_table = $wpdb->prefix . "esp_price_type";
850
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
851
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
852
-            $price_types_exist = $wpdb->get_var($SQL);
853
-            if ( ! $price_types_exist) {
854
-                $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
832
+				$wpdb->query($SQL);
833
+			}
834
+		}
835
+	}
836
+
837
+
838
+
839
+	/**
840
+	 * insert_default_price_types
841
+	 *
842
+	 * @access public
843
+	 * @static
844
+	 * @return void
845
+	 */
846
+	public function insert_default_price_types()
847
+	{
848
+		global $wpdb;
849
+		$price_type_table = $wpdb->prefix . "esp_price_type";
850
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
851
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
852
+			$price_types_exist = $wpdb->get_var($SQL);
853
+			if ( ! $price_types_exist) {
854
+				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
855 855
 							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
856 856
 							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
857 857
 							(3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
858 858
 							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
859 859
 							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
860
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
861
-                $wpdb->query($SQL);
862
-            }
863
-        }
864
-    }
865
-
866
-
867
-
868
-    /**
869
-     * insert_default_prices. We assume we're upgrading to regular here.
870
-     * If we're INSTALLING 4.1 CAF, then we add a few extra DEFAULT prices
871
-     * when EEH_Activaion's initialize_db_content is called via  ahook in
872
-     * EE_BRewing_regular
873
-     *
874
-     * @access public
875
-     * @static
876
-     * @return void
877
-     */
878
-    public function insert_default_prices()
879
-    {
880
-        global $wpdb;
881
-        $price_table = $wpdb->prefix . "esp_price";
882
-        if ($this->_get_table_analysis()->tableExists($price_table)) {
883
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
884
-            $prices_exist = $wpdb->get_var($SQL);
885
-            if ( ! $prices_exist) {
886
-                $SQL = "INSERT INTO $price_table
860
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
861
+				$wpdb->query($SQL);
862
+			}
863
+		}
864
+	}
865
+
866
+
867
+
868
+	/**
869
+	 * insert_default_prices. We assume we're upgrading to regular here.
870
+	 * If we're INSTALLING 4.1 CAF, then we add a few extra DEFAULT prices
871
+	 * when EEH_Activaion's initialize_db_content is called via  ahook in
872
+	 * EE_BRewing_regular
873
+	 *
874
+	 * @access public
875
+	 * @static
876
+	 * @return void
877
+	 */
878
+	public function insert_default_prices()
879
+	{
880
+		global $wpdb;
881
+		$price_table = $wpdb->prefix . "esp_price";
882
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
883
+			$SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
884
+			$prices_exist = $wpdb->get_var($SQL);
885
+			if ( ! $prices_exist) {
886
+				$SQL = "INSERT INTO $price_table
887 887
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
888 888
 							(1, 1, '0.00', 'Free Admission', '', 1, NULL, 0, 0, 0);";
889
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
890
-                $wpdb->query($SQL);
891
-            }
892
-        }
893
-    }
894
-
895
-
896
-
897
-    /**
898
-     * insert DEFAULT ticket
899
-     *
900
-     * @access public
901
-     * @static
902
-     * @return void
903
-     */
904
-    public function insert_default_tickets()
905
-    {
906
-        global $wpdb;
907
-        $ticket_table = $wpdb->prefix . "esp_ticket";
908
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
909
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
910
-            $tickets_exist = $wpdb->get_var($SQL);
911
-            if ( ! $tickets_exist) {
912
-                $SQL = "INSERT INTO $ticket_table
889
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
890
+				$wpdb->query($SQL);
891
+			}
892
+		}
893
+	}
894
+
895
+
896
+
897
+	/**
898
+	 * insert DEFAULT ticket
899
+	 *
900
+	 * @access public
901
+	 * @static
902
+	 * @return void
903
+	 */
904
+	public function insert_default_tickets()
905
+	{
906
+		global $wpdb;
907
+		$ticket_table = $wpdb->prefix . "esp_ticket";
908
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
909
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
910
+			$tickets_exist = $wpdb->get_var($SQL);
911
+			if ( ! $tickets_exist) {
912
+				$SQL = "INSERT INTO $ticket_table
913 913
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES
914 914
 					( 1, 0, '"
915
-                       . esc_html__("Free Ticket", "event_espresso")
916
-                       . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
917
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
918
-                $wpdb->query($SQL);
919
-            }
920
-        }
921
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
922
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
923
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
924
-            $ticket_prc_exist = $wpdb->get_var($SQL);
925
-            if ( ! $ticket_prc_exist) {
926
-                $SQL = "INSERT INTO $ticket_price_table
915
+					   . esc_html__("Free Ticket", "event_espresso")
916
+					   . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
917
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
918
+				$wpdb->query($SQL);
919
+			}
920
+		}
921
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
922
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
923
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
924
+			$ticket_prc_exist = $wpdb->get_var($SQL);
925
+			if ( ! $ticket_prc_exist) {
926
+				$SQL = "INSERT INTO $ticket_price_table
927 927
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
928 928
 				( 1, 1, 1 )
929 929
 				";
930
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
931
-                $wpdb->query($SQL);
932
-            }
933
-        }
934
-    }
935
-
936
-
937
-
938
-    /**
939
-     * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
940
-     * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
941
-     * country ID (int), a 2-letter ISO, 3-letter ISO, or name
942
-     *
943
-     * @global type  $wpdb
944
-     * @param string $country_name
945
-     * @return array where keys are columns, values are column values
946
-     */
947
-    public function get_or_create_country($country_name)
948
-    {
949
-        if ( ! $country_name) {
950
-            throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
951
-        }
952
-        global $wpdb;
953
-        $country_table = $wpdb->prefix . "esp_country";
954
-        if (is_int($country_name)) {
955
-            $country_name = $this->get_iso_from_3_1_country_id($country_name);
956
-        }
957
-        $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
930
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
931
+				$wpdb->query($SQL);
932
+			}
933
+		}
934
+	}
935
+
936
+
937
+
938
+	/**
939
+	 * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
940
+	 * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
941
+	 * country ID (int), a 2-letter ISO, 3-letter ISO, or name
942
+	 *
943
+	 * @global type  $wpdb
944
+	 * @param string $country_name
945
+	 * @return array where keys are columns, values are column values
946
+	 */
947
+	public function get_or_create_country($country_name)
948
+	{
949
+		if ( ! $country_name) {
950
+			throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
951
+		}
952
+		global $wpdb;
953
+		$country_table = $wpdb->prefix . "esp_country";
954
+		if (is_int($country_name)) {
955
+			$country_name = $this->get_iso_from_3_1_country_id($country_name);
956
+		}
957
+		$country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
958 958
 			CNT_ISO LIKE %s OR
959 959
 			CNT_ISO3 LIKE %s OR
960 960
 			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
961
-        if ( ! $country) {
962
-            //insert a new one then
963
-            $cols_n_values = array(
964
-                    'CNT_ISO'         => $this->_find_available_country_iso(2),
965
-                    'CNT_ISO3'        => $this->_find_available_country_iso(3),
966
-                    'RGN_ID'          => 0,
967
-                    'CNT_name'        => $country_name,
968
-                    'CNT_cur_code'    => 'USD',
969
-                    'CNT_cur_single'  => 'Dollar',
970
-                    'CNT_cur_plural'  => 'Dollars',
971
-                    'CNT_cur_sign'    => '&#36;',
972
-                    'CNT_cur_sign_b4' => true,
973
-                    'CNT_cur_dec_plc' => 2,
974
-                    'CNT_cur_dec_mrk' => '.',
975
-                    'CNT_cur_thsnds'  => ',',
976
-                    'CNT_tel_code'    => '+1',
977
-                    'CNT_is_EU'       => false,
978
-                    'CNT_active'      => true,
979
-            );
980
-            $data_types = array(
981
-                    '%s',//CNT_ISO
982
-                    '%s',//CNT_ISO3
983
-                    '%d',//RGN_ID
984
-                    '%s',//CNT_name
985
-                    '%s',//CNT_cur_code
986
-                    '%s',//CNT_cur_single
987
-                    '%s',//CNT_cur_plural
988
-                    '%s',//CNT_cur_sign
989
-                    '%d',//CNT_cur_sign_b4
990
-                    '%d',//CNT_cur_dec_plc
991
-                    '%s',//CNT_cur_dec_mrk
992
-                    '%s',//CNT_cur_thsnds
993
-                    '%s',//CNT_tel_code
994
-                    '%d',//CNT_is_EU
995
-                    '%d',//CNT_active
996
-            );
997
-            $success = $wpdb->insert($country_table,
998
-                    $cols_n_values,
999
-                    $data_types);
1000
-            if ( ! $success) {
1001
-                throw new EE_Error($this->_create_error_message_for_db_insertion('N/A',
1002
-                        array('country_id' => $country_name), $country_table, $cols_n_values, $data_types));
1003
-            }
1004
-            $country = $cols_n_values;
1005
-        }
1006
-        return $country;
1007
-    }
1008
-
1009
-
1010
-
1011
-    /**
1012
-     * finds a country iso which hasnt been used yet
1013
-     *
1014
-     * @global type $wpdb
1015
-     * @return string
1016
-     */
1017
-    private function _find_available_country_iso($num_letters = 2)
1018
-    {
1019
-        global $wpdb;
1020
-        $country_table = $wpdb->prefix . "esp_country";
1021
-        $attempts = 0;
1022
-        do {
1023
-            $current_iso = strtoupper(wp_generate_password($num_letters, false));
1024
-            $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1025
-                                                                   . $country_table
1026
-                                                                   . " WHERE CNT_ISO=%s", $current_iso));
1027
-            $attempts++;
1028
-            //keep going until we find an available country code, or we arbitrarily
1029
-            //decide we've tried this enough. Somehow they have way too many countries
1030
-            //(probably because they're mis-using the EE3 country_id like a custom question)
1031
-        } while (intval($country_with_that_iso) && $attempts < 200);
1032
-        return $current_iso;
1033
-    }
1034
-
1035
-
1036
-
1037
-    /**
1038
-     * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1039
-     * is independent of outside code which can change in future versions of EE
1040
-     *
1041
-     * @global type  $wpdb
1042
-     * @param string $state_name
1043
-     * @return array where keys are columns, values are column values
1044
-     */
1045
-    public function get_or_create_state($state_name, $country_name = '')
1046
-    {
1047
-        if ( ! $state_name) {
1048
-            throw new EE_Error(esc_html__("Could not get-or-create state because no state name was provided",
1049
-                    "event_espresso"));
1050
-        }
1051
-        try {
1052
-            $country = $this->get_or_create_country($country_name);
1053
-            $country_iso = $country['CNT_ISO'];
1054
-        } catch (EE_Error $e) {
1055
-            $country_iso = $this->get_default_country_iso();
1056
-        }
1057
-        global $wpdb;
1058
-        $state_table = $wpdb->prefix . "esp_state";
1059
-        $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
961
+		if ( ! $country) {
962
+			//insert a new one then
963
+			$cols_n_values = array(
964
+					'CNT_ISO'         => $this->_find_available_country_iso(2),
965
+					'CNT_ISO3'        => $this->_find_available_country_iso(3),
966
+					'RGN_ID'          => 0,
967
+					'CNT_name'        => $country_name,
968
+					'CNT_cur_code'    => 'USD',
969
+					'CNT_cur_single'  => 'Dollar',
970
+					'CNT_cur_plural'  => 'Dollars',
971
+					'CNT_cur_sign'    => '&#36;',
972
+					'CNT_cur_sign_b4' => true,
973
+					'CNT_cur_dec_plc' => 2,
974
+					'CNT_cur_dec_mrk' => '.',
975
+					'CNT_cur_thsnds'  => ',',
976
+					'CNT_tel_code'    => '+1',
977
+					'CNT_is_EU'       => false,
978
+					'CNT_active'      => true,
979
+			);
980
+			$data_types = array(
981
+					'%s',//CNT_ISO
982
+					'%s',//CNT_ISO3
983
+					'%d',//RGN_ID
984
+					'%s',//CNT_name
985
+					'%s',//CNT_cur_code
986
+					'%s',//CNT_cur_single
987
+					'%s',//CNT_cur_plural
988
+					'%s',//CNT_cur_sign
989
+					'%d',//CNT_cur_sign_b4
990
+					'%d',//CNT_cur_dec_plc
991
+					'%s',//CNT_cur_dec_mrk
992
+					'%s',//CNT_cur_thsnds
993
+					'%s',//CNT_tel_code
994
+					'%d',//CNT_is_EU
995
+					'%d',//CNT_active
996
+			);
997
+			$success = $wpdb->insert($country_table,
998
+					$cols_n_values,
999
+					$data_types);
1000
+			if ( ! $success) {
1001
+				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A',
1002
+						array('country_id' => $country_name), $country_table, $cols_n_values, $data_types));
1003
+			}
1004
+			$country = $cols_n_values;
1005
+		}
1006
+		return $country;
1007
+	}
1008
+
1009
+
1010
+
1011
+	/**
1012
+	 * finds a country iso which hasnt been used yet
1013
+	 *
1014
+	 * @global type $wpdb
1015
+	 * @return string
1016
+	 */
1017
+	private function _find_available_country_iso($num_letters = 2)
1018
+	{
1019
+		global $wpdb;
1020
+		$country_table = $wpdb->prefix . "esp_country";
1021
+		$attempts = 0;
1022
+		do {
1023
+			$current_iso = strtoupper(wp_generate_password($num_letters, false));
1024
+			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1025
+																   . $country_table
1026
+																   . " WHERE CNT_ISO=%s", $current_iso));
1027
+			$attempts++;
1028
+			//keep going until we find an available country code, or we arbitrarily
1029
+			//decide we've tried this enough. Somehow they have way too many countries
1030
+			//(probably because they're mis-using the EE3 country_id like a custom question)
1031
+		} while (intval($country_with_that_iso) && $attempts < 200);
1032
+		return $current_iso;
1033
+	}
1034
+
1035
+
1036
+
1037
+	/**
1038
+	 * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1039
+	 * is independent of outside code which can change in future versions of EE
1040
+	 *
1041
+	 * @global type  $wpdb
1042
+	 * @param string $state_name
1043
+	 * @return array where keys are columns, values are column values
1044
+	 */
1045
+	public function get_or_create_state($state_name, $country_name = '')
1046
+	{
1047
+		if ( ! $state_name) {
1048
+			throw new EE_Error(esc_html__("Could not get-or-create state because no state name was provided",
1049
+					"event_espresso"));
1050
+		}
1051
+		try {
1052
+			$country = $this->get_or_create_country($country_name);
1053
+			$country_iso = $country['CNT_ISO'];
1054
+		} catch (EE_Error $e) {
1055
+			$country_iso = $this->get_default_country_iso();
1056
+		}
1057
+		global $wpdb;
1058
+		$state_table = $wpdb->prefix . "esp_state";
1059
+		$state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1060 1060
 			(STA_abbrev LIKE %s OR
1061 1061
 			STA_name LIKE %s) AND
1062 1062
 			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1063
-        if ( ! $state) {
1064
-            //insert a new one then
1065
-            $cols_n_values = array(
1066
-                    'CNT_ISO'    => $country_iso,
1067
-                    'STA_abbrev' => substr($state_name, 0, 6),
1068
-                    'STA_name'   => $state_name,
1069
-                    'STA_active' => true,
1070
-            );
1071
-            $data_types = array(
1072
-                    '%s',//CNT_ISO
1073
-                    '%s',//STA_abbrev
1074
-                    '%s',//STA_name
1075
-                    '%d',//STA_active
1076
-            );
1077
-            $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1078
-            if ( ! $success) {
1079
-                throw new EE_Error($this->_create_error_message_for_db_insertion('N/A',
1080
-                        array('state' => $state_name, 'country_id' => $country_name), $state_table, $cols_n_values,
1081
-                        $data_types));
1082
-            }
1083
-            $state = $cols_n_values;
1084
-            $state['STA_ID'] = $wpdb->insert_id;
1085
-        }
1086
-        return $state;
1087
-    }
1088
-
1089
-
1090
-
1091
-    /**
1092
-     * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1093
-     * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1094
-     *
1095
-     * @param type $timeString
1096
-     * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1097
-     *                with leading zeros)
1098
-     */
1099
-    public function convertTimeFromAMPM($timeString)
1100
-    {
1101
-        $matches = array();
1102
-        preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1103
-        if ( ! $matches || count($matches) < 3) {
1104
-            $hour = '00';
1105
-            $minutes = '00';
1106
-        } else {
1107
-            $hour = intval($matches[1]);
1108
-            $minutes = $matches[2];
1109
-        }
1110
-        if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1111
-            $hour = intval($hour) + 12;
1112
-        }
1113
-        $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1114
-        $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1115
-        return "$hour:$minutes";
1116
-    }
1117
-
1118
-
1119
-
1120
-    /**
1121
-     * Gets the ISO3 fora country given its 3.1 country ID.
1122
-     *
1123
-     * @param int $country_id
1124
-     * @return string the country's ISO3 code
1125
-     */
1126
-    public function get_iso_from_3_1_country_id($country_id)
1127
-    {
1128
-        $old_countries = array(
1129
-                array(64, 'United States', 'US', 'USA', 1),
1130
-                array(15, 'Australia', 'AU', 'AUS', 1),
1131
-                array(39, 'Canada', 'CA', 'CAN', 1),
1132
-                array(171, 'United Kingdom', 'GB', 'GBR', 1),
1133
-                array(70, 'France', 'FR', 'FRA', 2),
1134
-                array(111, 'Italy', 'IT', 'ITA', 2),
1135
-                array(63, 'Spain', 'ES', 'ESP', 2),
1136
-                array(1, 'Afghanistan', 'AF', 'AFG', 1),
1137
-                array(2, 'Albania', 'AL', 'ALB', 1),
1138
-                array(3, 'Germany', 'DE', 'DEU', 2),
1139
-                array(198, 'Switzerland', 'CH', 'CHE', 1),
1140
-                array(87, 'Netherlands', 'NL', 'NLD', 2),
1141
-                array(197, 'Sweden', 'SE', 'SWE', 1),
1142
-                array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1143
-                array(4, 'Andorra', 'AD', 'AND', 2),
1144
-                array(5, 'Angola', 'AO', 'AGO', 1),
1145
-                array(6, 'Anguilla', 'AI', 'AIA', 1),
1146
-                array(7, 'Antarctica', 'AQ', 'ATA', 1),
1147
-                array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1148
-                array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1149
-                array(11, 'Algeria', 'DZ', 'DZA', 1),
1150
-                array(12, 'Argentina', 'AR', 'ARG', 1),
1151
-                array(13, 'Armenia', 'AM', 'ARM', 1),
1152
-                array(14, 'Aruba', 'AW', 'ABW', 1),
1153
-                array(16, 'Austria', 'AT', 'AUT', 2),
1154
-                array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1155
-                array(18, 'Bahamas', 'BS', 'BHS', 1),
1156
-                array(19, 'Bahrain', 'BH', 'BHR', 1),
1157
-                array(20, 'Bangladesh', 'BD', 'BGD', 1),
1158
-                array(21, 'Barbados', 'BB', 'BRB', 1),
1159
-                array(22, 'Belgium ', 'BE', 'BEL', 2),
1160
-                array(23, 'Belize', 'BZ', 'BLZ', 1),
1161
-                array(24, 'Benin', 'BJ', 'BEN', 1),
1162
-                array(25, 'Bermudas', 'BM', 'BMU', 1),
1163
-                array(26, 'Belarus', 'BY', 'BLR', 1),
1164
-                array(27, 'Bolivia', 'BO', 'BOL', 1),
1165
-                array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1166
-                array(29, 'Botswana', 'BW', 'BWA', 1),
1167
-                array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1168
-                array(30, 'Brazil', 'BR', 'BRA', 1),
1169
-                array(31, 'Brunei', 'BN', 'BRN', 1),
1170
-                array(32, 'Bulgaria', 'BG', 'BGR', 1),
1171
-                array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1172
-                array(34, 'Burundi', 'BI', 'BDI', 1),
1173
-                array(35, 'Bhutan', 'BT', 'BTN', 1),
1174
-                array(36, 'Cape Verde', 'CV', 'CPV', 1),
1175
-                array(37, 'Cambodia', 'KH', 'KHM', 1),
1176
-                array(38, 'Cameroon', 'CM', 'CMR', 1),
1177
-                array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1178
-                array(172, 'Central African Republic', 'CF', 'CAF', 1),
1179
-                array(40, 'Chad', 'TD', 'TCD', 1),
1180
-                array(41, 'Chile', 'CL', 'CHL', 1),
1181
-                array(42, 'China', 'CN', 'CHN', 1),
1182
-                array(105, 'Christmas Island', 'CX', 'CXR', 1),
1183
-                array(43, 'Cyprus', 'CY', 'CYP', 2),
1184
-                array(99, 'Cocos Island', 'CC', 'CCK', 1),
1185
-                array(100, 'Cook Islands', 'CK', 'COK', 1),
1186
-                array(44, 'Colombia', 'CO', 'COL', 1),
1187
-                array(45, 'Comoros', 'KM', 'COM', 1),
1188
-                array(46, 'Congo', 'CG', 'COG', 1),
1189
-                array(47, 'North Korea', 'KP', 'PRK', 1),
1190
-                array(50, 'Costa Rica', 'CR', 'CRI', 1),
1191
-                array(51, 'Croatia', 'HR', 'HRV', 1),
1192
-                array(52, 'Cuba', 'CU', 'CUB', 1),
1193
-                array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1194
-                array(53, 'Denmark', 'DK', 'DNK', 1),
1195
-                array(54, 'Djibouti', 'DJ', 'DJI', 1),
1196
-                array(55, 'Dominica', 'DM', 'DMA', 1),
1197
-                array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1198
-                array(56, 'Ecuador', 'EC', 'ECU', 1),
1199
-                array(57, 'Egypt', 'EG', 'EGY', 1),
1200
-                array(58, 'El Salvador', 'SV', 'SLV', 1),
1201
-                array(60, 'Eritrea', 'ER', 'ERI', 1),
1202
-                array(61, 'Slovakia', 'SK', 'SVK', 2),
1203
-                array(62, 'Slovenia', 'SI', 'SVN', 2),
1204
-                array(65, 'Estonia', 'EE', 'EST', 2),
1205
-                array(66, 'Ethiopia', 'ET', 'ETH', 1),
1206
-                array(102, 'Faroe islands', 'FO', 'FRO', 1),
1207
-                array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1208
-                array(67, 'Fiji', 'FJ', 'FJI', 1),
1209
-                array(69, 'Finland', 'FI', 'FIN', 2),
1210
-                array(71, 'Gabon', 'GA', 'GAB', 1),
1211
-                array(72, 'Gambia', 'GM', 'GMB', 1),
1212
-                array(73, 'Georgia', 'GE', 'GEO', 1),
1213
-                array(74, 'Ghana', 'GH', 'GHA', 1),
1214
-                array(75, 'Gibraltar', 'GI', 'GIB', 1),
1215
-                array(76, 'Greece', 'GR', 'GRC', 2),
1216
-                array(77, 'Grenada', 'GD', 'GRD', 1),
1217
-                array(78, 'Greenland', 'GL', 'GRL', 1),
1218
-                array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1219
-                array(80, 'Guam', 'GU', 'GUM', 1),
1220
-                array(81, 'Guatemala', 'GT', 'GTM', 1),
1221
-                array(82, 'Guinea', 'GN', 'GIN', 1),
1222
-                array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1223
-                array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1224
-                array(85, 'Guyana', 'GY', 'GUY', 1),
1225
-                array(86, 'Haiti', 'HT', 'HTI', 1),
1226
-                array(88, 'Honduras', 'HN', 'HND', 1),
1227
-                array(89, 'Hong Kong', 'HK', 'HKG', 1),
1228
-                array(90, 'Hungary', 'HU', 'HUN', 1),
1229
-                array(91, 'India', 'IN', 'IND', 1),
1230
-                array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1231
-                array(92, 'Indonesia', 'ID', 'IDN', 1),
1232
-                array(93, 'Iraq', 'IQ', 'IRQ', 1),
1233
-                array(94, 'Iran', 'IR', 'IRN', 1),
1234
-                array(95, 'Ireland', 'IE', 'IRL', 2),
1235
-                array(97, 'Iceland', 'IS', 'ISL', 1),
1236
-                array(110, 'Israel', 'IL', 'ISR', 1),
1237
-                array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1238
-                array(112, 'Jamaica', 'JM', 'JAM', 1),
1239
-                array(113, 'Japan', 'JP', 'JPN', 1),
1240
-                array(114, 'Jordan', 'JO', 'JOR', 1),
1241
-                array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1242
-                array(116, 'Kenya', 'KE', 'KEN', 1),
1243
-                array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1244
-                array(118, 'Kiribati', 'KI', 'KIR', 1),
1245
-                array(48, 'South Korea', 'KR', 'KOR', 1),
1246
-                array(228, 'Kosovo', 'XK', 'XKV', 2),
1247
-                // there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code
1248
-                array(119, 'Kuwait', 'KW', 'KWT', 1),
1249
-                array(120, 'Laos', 'LA', 'LAO', 1),
1250
-                array(121, 'Latvia', 'LV', 'LVA', 2),
1251
-                array(122, 'Lesotho', 'LS', 'LSO', 1),
1252
-                array(123, 'Lebanon', 'LB', 'LBN', 1),
1253
-                array(124, 'Liberia', 'LR', 'LBR', 1),
1254
-                array(125, 'Libya', 'LY', 'LBY', 1),
1255
-                array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1256
-                array(127, 'Lithuania', 'LT', 'LTU', 2),
1257
-                array(128, 'Luxemburg', 'LU', 'LUX', 2),
1258
-                array(129, 'Macao', 'MO', 'MAC', 1),
1259
-                array(130, 'Macedonia', 'MK', 'MKD', 1),
1260
-                array(131, 'Madagascar', 'MG', 'MDG', 1),
1261
-                array(132, 'Malaysia', 'MY', 'MYS', 1),
1262
-                array(133, 'Malawi', 'MW', 'MWI', 1),
1263
-                array(134, 'Maldivas', 'MV', 'MDV', 1),
1264
-                array(135, 'Mali', 'ML', 'MLI', 1),
1265
-                array(136, 'Malta', 'MT', 'MLT', 2),
1266
-                array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1267
-                array(137, 'Morocco', 'MA', 'MAR', 1),
1268
-                array(104, 'Marshall islands', 'MH', 'MHL', 1),
1269
-                array(138, 'Martinique', 'MQ', 'MTQ', 1),
1270
-                array(139, 'Mauritius', 'MU', 'MUS', 1),
1271
-                array(140, 'Mauritania', 'MR', 'MRT', 1),
1272
-                array(141, 'Mayote', 'YT', 'MYT', 2),
1273
-                array(142, 'Mexico', 'MX', 'MEX', 1),
1274
-                array(143, 'Micronesia', 'FM', 'FSM', 1),
1275
-                array(144, 'Moldova', 'MD', 'MDA', 1),
1276
-                array(145, 'Monaco', 'MC', 'MCO', 2),
1277
-                array(146, 'Mongolia', 'MN', 'MNG', 1),
1278
-                array(147, 'Montserrat', 'MS', 'MSR', 1),
1279
-                array(227, 'Montenegro', 'ME', 'MNE', 2),
1280
-                array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1281
-                array(149, 'Myanmar', 'MM', 'MMR', 1),
1282
-                array(150, 'Namibia', 'NA', 'NAM', 1),
1283
-                array(151, 'Nauru', 'NR', 'NRU', 1),
1284
-                array(152, 'Nepal', 'NP', 'NPL', 1),
1285
-                array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1286
-                array(153, 'Nicaragua', 'NI', 'NIC', 1),
1287
-                array(154, 'Niger', 'NE', 'NER', 1),
1288
-                array(155, 'Nigeria', 'NG', 'NGA', 1),
1289
-                array(156, 'Niue', 'NU', 'NIU', 1),
1290
-                array(157, 'Norway', 'NO', 'NOR', 1),
1291
-                array(158, 'New Caledonia', 'NC', 'NCL', 1),
1292
-                array(159, 'New Zealand', 'NZ', 'NZL', 1),
1293
-                array(160, 'Oman', 'OM', 'OMN', 1),
1294
-                array(161, 'Pakistan', 'PK', 'PAK', 1),
1295
-                array(162, 'Palau', 'PW', 'PLW', 1),
1296
-                array(163, 'Panama', 'PA', 'PAN', 1),
1297
-                array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1298
-                array(165, 'Paraguay', 'PY', 'PRY', 1),
1299
-                array(166, 'Peru', 'PE', 'PER', 1),
1300
-                array(68, 'Philippines', 'PH', 'PHL', 1),
1301
-                array(167, 'Poland', 'PL', 'POL', 1),
1302
-                array(168, 'Portugal', 'PT', 'PRT', 2),
1303
-                array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1304
-                array(170, 'Qatar', 'QA', 'QAT', 1),
1305
-                array(176, 'Rwanda', 'RW', 'RWA', 1),
1306
-                array(177, 'Romania', 'RO', 'ROM', 2),
1307
-                array(178, 'Russia', 'RU', 'RUS', 1),
1308
-                array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1309
-                array(180, 'Samoa', 'WS', 'WSM', 1),
1310
-                array(181, 'American Samoa', 'AS', 'ASM', 1),
1311
-                array(183, 'San Marino', 'SM', 'SMR', 2),
1312
-                array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1313
-                array(185, 'Saint Helena', 'SH', 'SHN', 1),
1314
-                array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1315
-                array(188, 'Senegal', 'SN', 'SEN', 1),
1316
-                array(189, 'Seychelles', 'SC', 'SYC', 1),
1317
-                array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1318
-                array(191, 'Singapore', 'SG', 'SGP', 1),
1319
-                array(192, 'Syria', 'SY', 'SYR', 1),
1320
-                array(193, 'Somalia', 'SO', 'SOM', 1),
1321
-                array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1322
-                array(195, 'South Africa', 'ZA', 'ZAF', 1),
1323
-                array(196, 'Sudan', 'SD', 'SDN', 1),
1324
-                array(199, 'Suriname', 'SR', 'SUR', 1),
1325
-                array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1326
-                array(201, 'Thailand', 'TH', 'THA', 1),
1327
-                array(202, 'Taiwan', 'TW', 'TWN', 1),
1328
-                array(203, 'Tanzania', 'TZ', 'TZA', 1),
1329
-                array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1330
-                array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1331
-                array(207, 'Togo', 'TG', 'TGO', 1),
1332
-                array(208, 'Tokelau', 'TK', 'TKL', 1),
1333
-                array(209, 'Tonga', 'TO', 'TON', 1),
1334
-                array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1335
-                array(211, 'Tunisia', 'TN', 'TUN', 1),
1336
-                array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1337
-                array(213, 'Turkey', 'TR', 'TUR', 1),
1338
-                array(214, 'Tuvalu', 'TV', 'TUV', 1),
1339
-                array(215, 'Ukraine', 'UA', 'UKR', 1),
1340
-                array(216, 'Uganda', 'UG', 'UGA', 1),
1341
-                array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1342
-                array(217, 'Uruguay', 'UY', 'URY', 1),
1343
-                array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1344
-                array(219, 'Vanuatu', 'VU', 'VUT', 1),
1345
-                array(220, 'Vatican City', 'VA', 'VAT', 2),
1346
-                array(221, 'Venezuela', 'VE', 'VEN', 1),
1347
-                array(222, 'Vietnam', 'VN', 'VNM', 1),
1348
-                array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1349
-                array(223, 'Yemen', 'YE', 'YEM', 1),
1350
-                array(225, 'Zambia', 'ZM', 'ZMB', 1),
1351
-                array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1352
-        );
1353
-        $country_iso = 'US';
1354
-        foreach ($old_countries as $country_array) {
1355
-            //note: index 0 is the 3.1 country ID
1356
-            if ($country_array[0] == $country_id) {
1357
-                //note: index 2 is the ISO
1358
-                $country_iso = $country_array[2];
1359
-                break;
1360
-            }
1361
-        }
1362
-        return $country_iso;
1363
-    }
1364
-
1365
-
1366
-
1367
-    /**
1368
-     * Gets the ISO3 for the
1369
-     *
1370
-     * @return string
1371
-     */
1372
-    public function get_default_country_iso()
1373
-    {
1374
-        $old_org_options = get_option('events_organization_settings');
1375
-        $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1376
-        return $iso;
1377
-    }
1378
-
1379
-
1380
-
1381
-    /**
1382
-     * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1383
-     *
1384
-     * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1385
-     * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1386
-     *                                                  DEFAULT payment status, the event's DEFAULT payment status, or
1387
-     *                                                  the attendee's payment status) required pre-approval.
1388
-     * @return string STS_ID for use in 4.1
1389
-     */
1390
-    public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1391
-    {
1392
-        //EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1393
-        if ($this_thing_required_pre_approval) {
1394
-            return 'RNA';
1395
-        } else {
1396
-            $mapping = $default_reg_stati_conversions = array(
1397
-                    'Completed'        => 'RAP',
1398
-                    ''                 => 'RPP',
1399
-                    'Incomplete'       => 'RPP',
1400
-                    'Pending'          => 'RAP',
1401
-                    //stati that only occurred on 3.1 attendees:
1402
-                    'Payment Declined' => 'RPP',
1403
-                    'Not Completed'    => 'RPP',
1404
-                    'Cancelled'        => 'RPP',
1405
-                    'Declined'         => 'RPP',
1406
-            );
1407
-        }
1408
-        return isset($mapping[$payment_status]) ? $mapping[$payment_status] : 'RNA';
1409
-    }
1410
-
1411
-
1412
-
1413
-    /**
1414
-     * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1415
-     * and sets it as the featured image on the CPT event
1416
-     *
1417
-     * @param type                            $old_event
1418
-     * @param type                            $new_cpt_id
1419
-     * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1420
-     * @return boolean whether or not we had to do the big job of creating an image attachment
1421
-     */
1422
-    public function convert_image_url_to_attachment_and_attach_to_post(
1423
-            $guid,
1424
-            $new_cpt_id,
1425
-            EE_Data_Migration_Script_Stage $migration_stage
1426
-    ) {
1427
-        $created_attachment_post = false;
1428
-        $guid = $this->_get_original_guid($guid);
1429
-        if ($guid) {
1430
-            //check for an existing attachment post with this guid
1431
-            $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1432
-            if ( ! $attachment_post_id) {
1433
-                //post thumbnail with that GUID doesn't exist, we should create one
1434
-                $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1435
-                $created_attachment_post = true;
1436
-            }
1437
-            //double-check we actually have an attachment post
1438
-            if ($attachment_post_id) {
1439
-                update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1440
-            } else {
1441
-                $migration_stage->add_error(sprintf(esc_html__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1442
-                        "event_espresso"), $guid, $new_cpt_id, $attachment_post_id));
1443
-            }
1444
-        }
1445
-        return $created_attachment_post;
1446
-    }
1447
-
1448
-
1449
-
1450
-    /**
1451
-     * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1452
-     * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1453
-     * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1454
-     * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1455
-     * exists
1456
-     *
1457
-     * @param string $guid_in_old_event
1458
-     * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1459
-     */
1460
-    private function _get_original_guid($guid_in_old_event)
1461
-    {
1462
-        $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1463
-        //do a head request to verify the file exists
1464
-        $head_response = wp_remote_head($original_guid);
1465
-        if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1466
-            return $original_guid;
1467
-        } else {
1468
-            return $guid_in_old_event;
1469
-        }
1470
-    }
1471
-
1472
-
1473
-
1474
-    /**
1475
-     * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1476
-     * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1477
-     * thumbnails)
1478
-     *
1479
-     * @param type                           $guid
1480
-     * @param EE_Data_Migration_Script_Stage $migration_stage
1481
-     * @return int
1482
-     */
1483
-    private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1484
-    {
1485
-        if ( ! $guid) {
1486
-            $migration_stage->add_error(sprintf(esc_html__("Cannot create image attachment for a blank GUID!",
1487
-                    "event_espresso")));
1488
-            return 0;
1489
-        }
1490
-        $wp_filetype = wp_check_filetype(basename($guid), null);
1491
-        $wp_upload_dir = wp_upload_dir();
1492
-        //if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1493
-        if (strpos($guid, $wp_upload_dir['url']) === false) {
1494
-            //image is located remotely. download it and place it in the uploads directory
1495
-            if ( ! is_readable($guid)) {
1496
-                $migration_stage->add_error(sprintf(esc_html__("Could not create image attachment from non-existent file: %s",
1497
-                        "event_espresso"), $guid));
1498
-                return 0;
1499
-            }
1500
-            $contents = file_get_contents($guid);
1501
-            if ($contents === false) {
1502
-                $migration_stage->add_error(sprintf(esc_html__("Could not read image at %s, and therefore couldnt create an attachment post for it.",
1503
-                        "event_espresso"), $guid));
1504
-                return false;
1505
-            }
1506
-            $local_filepath = $wp_upload_dir['path'] . DS . basename($guid);
1507
-            $savefile = fopen($local_filepath, 'w');
1508
-            fwrite($savefile, $contents);
1509
-            fclose($savefile);
1510
-            $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1511
-        } else {
1512
-            $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1513
-        }
1514
-        $attachment = array(
1515
-                'guid'           => $guid,
1516
-                'post_mime_type' => $wp_filetype['type'],
1517
-                'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1518
-                'post_content'   => '',
1519
-                'post_status'    => 'inherit',
1520
-        );
1521
-        $attach_id = wp_insert_attachment($attachment, $guid);
1522
-        if ( ! $attach_id) {
1523
-            $migration_stage->add_error(sprintf(esc_html__("Could not create image attachment post from image '%s'. Attachment data was %s.",
1524
-                    "event_espresso"), $guid, $this->_json_encode($attachment)));
1525
-            return $attach_id;
1526
-        }
1527
-        // you must first include the image.php file
1528
-        // for the function wp_generate_attachment_metadata() to work
1529
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1530
-        $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1531
-        if ( ! $attach_data) {
1532
-            $migration_stage->add_error(sprintf(esc_html__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1533
-                    "event_espresso"), $attach_id, $local_filepath, $guid));
1534
-            return $attach_id;
1535
-        }
1536
-        $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1537
-        if ( ! $metadata_save_result) {
1538
-            $migration_stage->add_error(sprintf(esc_html__("Could not update attachment metadata for attachment %d with data %s",
1539
-                    "event_espresso"), $attach_id, $this->_json_encode($attach_data)));
1540
-        }
1541
-        return $attach_id;
1542
-    }
1543
-
1544
-
1545
-
1546
-    /**
1547
-     * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1548
-     * and returns its ID.
1549
-     *
1550
-     * @global type  $wpdb
1551
-     * @param string $guid
1552
-     * @return int
1553
-     */
1554
-    private function _get_image_attachment_id_by_GUID($guid)
1555
-    {
1556
-        global $wpdb;
1557
-        $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1558
-        return $attachment_id;
1559
-    }
1560
-
1561
-
1562
-
1563
-    /**
1564
-     * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1565
-     * (and optionally a timezone; if none is given, the wp DEFAULT is used)
1566
-     *
1567
-     * @param EE_Data_Migration_Script_base $stage
1568
-     * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1569
-     *                                                   UTC time for
1570
-     * @param string                        $DATETIME_string
1571
-     * @param string                        $timezone
1572
-     * @return string
1573
-     */
1574
-    public function convert_date_string_to_utc(
1575
-            EE_Data_Migration_Script_Stage $stage,
1576
-            $row_of_data,
1577
-            $DATETIME_string,
1578
-            $timezone = null
1579
-    ) {
1580
-        $original_tz = $timezone;
1581
-        if ( ! $timezone) {
1582
-            $timezone = $this->_get_wp_timezone();
1583
-        }
1584
-        if ( ! $timezone) {
1585
-            $stage->add_error(sprintf(esc_html__("Could not find timezone given %s for %s", "event_espresso"), $original_tz,
1586
-                    $row_of_data));
1587
-            $timezone = 'UTC';
1588
-        }
1589
-        try {
1590
-            $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1591
-            $date_obj->setTimezone(new DateTimeZone('UTC'));
1592
-        } catch (Exception $e) {
1593
-            $stage->add_error(sprintf(esc_html__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1594
-                    "event_espresso"), $DATETIME_string, $timezone));
1595
-            $date_obj = new DateTime();
1596
-        }
1597
-        return $date_obj->format('Y-m-d H:i:s');
1598
-    }
1599
-
1600
-
1601
-
1602
-    /**
1603
-     * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset)
1604
-     *
1605
-     * @return string
1606
-     */
1607
-    private function _get_wp_timezone()
1608
-    {
1609
-        $timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1610
-        //if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1611
-        if (empty($timezone)) {
1612
-            //let's get a the WordPress UTC offset
1613
-            $offset = get_option('gmt_offset');
1614
-            $timezone = $this->timezone_convert_to_string_from_offset($offset);
1615
-        }
1616
-        return $timezone;
1617
-    }
1618
-
1619
-
1620
-
1621
-    /**
1622
-     * Gets the wordpress timezone string from a UTC offset
1623
-     *
1624
-     * @param int $offset
1625
-     * @return boolean
1626
-     */
1627
-    private function timezone_convert_to_string_from_offset($offset)
1628
-    {
1629
-        //shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
1630
-        $offset *= 3600; // convert hour offset to seconds
1631
-        $abbrarray = timezone_abbreviations_list();
1632
-        foreach ($abbrarray as $abbr) {
1633
-            foreach ($abbr as $city) {
1634
-                if ($city['offset'] == $offset) {
1635
-                    return $city['timezone_id'];
1636
-                }
1637
-            }
1638
-        }
1639
-        return false;
1640
-    }
1641
-
1642
-
1643
-
1644
-    public function migration_page_hooks()
1645
-    {
1646
-        add_filter(
1647
-                'FHEE__ee_migration_page__header',
1648
-                array($this, '_migrate_page_hook_simplify_version_strings'),
1649
-                10,
1650
-                3
1651
-        );
1652
-        add_filter(
1653
-                'FHEE__ee_migration_page__p_after_header',
1654
-                array($this, '_migration_page_hook_simplify_next_db_state'),
1655
-                10,
1656
-                2
1657
-        );
1658
-        add_filter(
1659
-                'FHEE__ee_migration_page__option_1_main',
1660
-                array($this, '_migrate_page_hook_simplify_version_strings'),
1661
-                10,
1662
-                3
1663
-        );
1664
-        add_filter(
1665
-                'FHEE__ee_migration_page__option_1_button_text',
1666
-                array($this, '_migrate_page_hook_simplify_version_strings'),
1667
-                10,
1668
-                3
1669
-        );
1670
-        add_action(
1671
-                'AHEE__ee_migration_page__option_1_extra_details',
1672
-                array($this, '_migration_page_hook_option_1_extra_details'),
1673
-                10,
1674
-                3
1675
-        );
1676
-        add_filter(
1677
-                'FHEE__ee_migration_page__option_2_main',
1678
-                array($this, '_migrate_page_hook_simplify_version_strings'),
1679
-                10,
1680
-                4
1681
-        );
1682
-        add_filter(
1683
-                'FHEE__ee_migration_page__option_2_button_text',
1684
-                array($this, '_migration_page_hook_simplify_next_db_state'),
1685
-                10,
1686
-                2
1687
-        );
1688
-        add_filter(
1689
-                'FHEE__ee_migration_page__option_2_details',
1690
-                array($this, '_migration_page_hook_simplify_next_db_state'),
1691
-                10,
1692
-                2
1693
-        );
1694
-        add_action(
1695
-                'AHEE__ee_migration_page__after_migration_options_table',
1696
-                array($this, '_migration_page_hook_after_migration_options_table')
1697
-        );
1698
-        add_filter(
1699
-                'FHEE__ee_migration_page__done_migration_header',
1700
-                array($this, '_migration_page_hook_simplify_next_db_state'),
1701
-                10,
1702
-                2
1703
-        );
1704
-        add_filter(
1705
-                'FHEE__ee_migration_page__p_after_done_migration_header',
1706
-                array($this, '_migration_page_hook_simplify_next_db_state'),
1707
-                10,
1708
-                2
1709
-        );
1710
-        add_filter(
1711
-                'FHEE__ee_migration_page__migration_options_template',
1712
-                array($this,'use_migration_options_from_ee3_template')
1713
-        );
1714
-    }
1715
-
1716
-
1717
-
1718
-    public function _migrate_page_hook_simplify_version_strings(
1719
-            $old_content,
1720
-            $current_db_state,
1721
-            $next_db_state,
1722
-            $ultimate_db_state = null
1723
-    ) {
1724
-        return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state),
1725
-                array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')),
1726
-                $old_content);
1727
-    }
1728
-
1729
-
1730
-
1731
-    public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1732
-    {
1733
-        return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content);
1734
-    }
1735
-
1736
-
1737
-
1738
-    public function _migration_page_hook_option_1_extra_details()
1739
-    {
1740
-        ?>
1063
+		if ( ! $state) {
1064
+			//insert a new one then
1065
+			$cols_n_values = array(
1066
+					'CNT_ISO'    => $country_iso,
1067
+					'STA_abbrev' => substr($state_name, 0, 6),
1068
+					'STA_name'   => $state_name,
1069
+					'STA_active' => true,
1070
+			);
1071
+			$data_types = array(
1072
+					'%s',//CNT_ISO
1073
+					'%s',//STA_abbrev
1074
+					'%s',//STA_name
1075
+					'%d',//STA_active
1076
+			);
1077
+			$success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1078
+			if ( ! $success) {
1079
+				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A',
1080
+						array('state' => $state_name, 'country_id' => $country_name), $state_table, $cols_n_values,
1081
+						$data_types));
1082
+			}
1083
+			$state = $cols_n_values;
1084
+			$state['STA_ID'] = $wpdb->insert_id;
1085
+		}
1086
+		return $state;
1087
+	}
1088
+
1089
+
1090
+
1091
+	/**
1092
+	 * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1093
+	 * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1094
+	 *
1095
+	 * @param type $timeString
1096
+	 * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1097
+	 *                with leading zeros)
1098
+	 */
1099
+	public function convertTimeFromAMPM($timeString)
1100
+	{
1101
+		$matches = array();
1102
+		preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1103
+		if ( ! $matches || count($matches) < 3) {
1104
+			$hour = '00';
1105
+			$minutes = '00';
1106
+		} else {
1107
+			$hour = intval($matches[1]);
1108
+			$minutes = $matches[2];
1109
+		}
1110
+		if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1111
+			$hour = intval($hour) + 12;
1112
+		}
1113
+		$hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1114
+		$minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1115
+		return "$hour:$minutes";
1116
+	}
1117
+
1118
+
1119
+
1120
+	/**
1121
+	 * Gets the ISO3 fora country given its 3.1 country ID.
1122
+	 *
1123
+	 * @param int $country_id
1124
+	 * @return string the country's ISO3 code
1125
+	 */
1126
+	public function get_iso_from_3_1_country_id($country_id)
1127
+	{
1128
+		$old_countries = array(
1129
+				array(64, 'United States', 'US', 'USA', 1),
1130
+				array(15, 'Australia', 'AU', 'AUS', 1),
1131
+				array(39, 'Canada', 'CA', 'CAN', 1),
1132
+				array(171, 'United Kingdom', 'GB', 'GBR', 1),
1133
+				array(70, 'France', 'FR', 'FRA', 2),
1134
+				array(111, 'Italy', 'IT', 'ITA', 2),
1135
+				array(63, 'Spain', 'ES', 'ESP', 2),
1136
+				array(1, 'Afghanistan', 'AF', 'AFG', 1),
1137
+				array(2, 'Albania', 'AL', 'ALB', 1),
1138
+				array(3, 'Germany', 'DE', 'DEU', 2),
1139
+				array(198, 'Switzerland', 'CH', 'CHE', 1),
1140
+				array(87, 'Netherlands', 'NL', 'NLD', 2),
1141
+				array(197, 'Sweden', 'SE', 'SWE', 1),
1142
+				array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1143
+				array(4, 'Andorra', 'AD', 'AND', 2),
1144
+				array(5, 'Angola', 'AO', 'AGO', 1),
1145
+				array(6, 'Anguilla', 'AI', 'AIA', 1),
1146
+				array(7, 'Antarctica', 'AQ', 'ATA', 1),
1147
+				array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1148
+				array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1149
+				array(11, 'Algeria', 'DZ', 'DZA', 1),
1150
+				array(12, 'Argentina', 'AR', 'ARG', 1),
1151
+				array(13, 'Armenia', 'AM', 'ARM', 1),
1152
+				array(14, 'Aruba', 'AW', 'ABW', 1),
1153
+				array(16, 'Austria', 'AT', 'AUT', 2),
1154
+				array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1155
+				array(18, 'Bahamas', 'BS', 'BHS', 1),
1156
+				array(19, 'Bahrain', 'BH', 'BHR', 1),
1157
+				array(20, 'Bangladesh', 'BD', 'BGD', 1),
1158
+				array(21, 'Barbados', 'BB', 'BRB', 1),
1159
+				array(22, 'Belgium ', 'BE', 'BEL', 2),
1160
+				array(23, 'Belize', 'BZ', 'BLZ', 1),
1161
+				array(24, 'Benin', 'BJ', 'BEN', 1),
1162
+				array(25, 'Bermudas', 'BM', 'BMU', 1),
1163
+				array(26, 'Belarus', 'BY', 'BLR', 1),
1164
+				array(27, 'Bolivia', 'BO', 'BOL', 1),
1165
+				array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1166
+				array(29, 'Botswana', 'BW', 'BWA', 1),
1167
+				array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1168
+				array(30, 'Brazil', 'BR', 'BRA', 1),
1169
+				array(31, 'Brunei', 'BN', 'BRN', 1),
1170
+				array(32, 'Bulgaria', 'BG', 'BGR', 1),
1171
+				array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1172
+				array(34, 'Burundi', 'BI', 'BDI', 1),
1173
+				array(35, 'Bhutan', 'BT', 'BTN', 1),
1174
+				array(36, 'Cape Verde', 'CV', 'CPV', 1),
1175
+				array(37, 'Cambodia', 'KH', 'KHM', 1),
1176
+				array(38, 'Cameroon', 'CM', 'CMR', 1),
1177
+				array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1178
+				array(172, 'Central African Republic', 'CF', 'CAF', 1),
1179
+				array(40, 'Chad', 'TD', 'TCD', 1),
1180
+				array(41, 'Chile', 'CL', 'CHL', 1),
1181
+				array(42, 'China', 'CN', 'CHN', 1),
1182
+				array(105, 'Christmas Island', 'CX', 'CXR', 1),
1183
+				array(43, 'Cyprus', 'CY', 'CYP', 2),
1184
+				array(99, 'Cocos Island', 'CC', 'CCK', 1),
1185
+				array(100, 'Cook Islands', 'CK', 'COK', 1),
1186
+				array(44, 'Colombia', 'CO', 'COL', 1),
1187
+				array(45, 'Comoros', 'KM', 'COM', 1),
1188
+				array(46, 'Congo', 'CG', 'COG', 1),
1189
+				array(47, 'North Korea', 'KP', 'PRK', 1),
1190
+				array(50, 'Costa Rica', 'CR', 'CRI', 1),
1191
+				array(51, 'Croatia', 'HR', 'HRV', 1),
1192
+				array(52, 'Cuba', 'CU', 'CUB', 1),
1193
+				array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1194
+				array(53, 'Denmark', 'DK', 'DNK', 1),
1195
+				array(54, 'Djibouti', 'DJ', 'DJI', 1),
1196
+				array(55, 'Dominica', 'DM', 'DMA', 1),
1197
+				array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1198
+				array(56, 'Ecuador', 'EC', 'ECU', 1),
1199
+				array(57, 'Egypt', 'EG', 'EGY', 1),
1200
+				array(58, 'El Salvador', 'SV', 'SLV', 1),
1201
+				array(60, 'Eritrea', 'ER', 'ERI', 1),
1202
+				array(61, 'Slovakia', 'SK', 'SVK', 2),
1203
+				array(62, 'Slovenia', 'SI', 'SVN', 2),
1204
+				array(65, 'Estonia', 'EE', 'EST', 2),
1205
+				array(66, 'Ethiopia', 'ET', 'ETH', 1),
1206
+				array(102, 'Faroe islands', 'FO', 'FRO', 1),
1207
+				array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1208
+				array(67, 'Fiji', 'FJ', 'FJI', 1),
1209
+				array(69, 'Finland', 'FI', 'FIN', 2),
1210
+				array(71, 'Gabon', 'GA', 'GAB', 1),
1211
+				array(72, 'Gambia', 'GM', 'GMB', 1),
1212
+				array(73, 'Georgia', 'GE', 'GEO', 1),
1213
+				array(74, 'Ghana', 'GH', 'GHA', 1),
1214
+				array(75, 'Gibraltar', 'GI', 'GIB', 1),
1215
+				array(76, 'Greece', 'GR', 'GRC', 2),
1216
+				array(77, 'Grenada', 'GD', 'GRD', 1),
1217
+				array(78, 'Greenland', 'GL', 'GRL', 1),
1218
+				array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1219
+				array(80, 'Guam', 'GU', 'GUM', 1),
1220
+				array(81, 'Guatemala', 'GT', 'GTM', 1),
1221
+				array(82, 'Guinea', 'GN', 'GIN', 1),
1222
+				array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1223
+				array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1224
+				array(85, 'Guyana', 'GY', 'GUY', 1),
1225
+				array(86, 'Haiti', 'HT', 'HTI', 1),
1226
+				array(88, 'Honduras', 'HN', 'HND', 1),
1227
+				array(89, 'Hong Kong', 'HK', 'HKG', 1),
1228
+				array(90, 'Hungary', 'HU', 'HUN', 1),
1229
+				array(91, 'India', 'IN', 'IND', 1),
1230
+				array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1231
+				array(92, 'Indonesia', 'ID', 'IDN', 1),
1232
+				array(93, 'Iraq', 'IQ', 'IRQ', 1),
1233
+				array(94, 'Iran', 'IR', 'IRN', 1),
1234
+				array(95, 'Ireland', 'IE', 'IRL', 2),
1235
+				array(97, 'Iceland', 'IS', 'ISL', 1),
1236
+				array(110, 'Israel', 'IL', 'ISR', 1),
1237
+				array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1238
+				array(112, 'Jamaica', 'JM', 'JAM', 1),
1239
+				array(113, 'Japan', 'JP', 'JPN', 1),
1240
+				array(114, 'Jordan', 'JO', 'JOR', 1),
1241
+				array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1242
+				array(116, 'Kenya', 'KE', 'KEN', 1),
1243
+				array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1244
+				array(118, 'Kiribati', 'KI', 'KIR', 1),
1245
+				array(48, 'South Korea', 'KR', 'KOR', 1),
1246
+				array(228, 'Kosovo', 'XK', 'XKV', 2),
1247
+				// there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code
1248
+				array(119, 'Kuwait', 'KW', 'KWT', 1),
1249
+				array(120, 'Laos', 'LA', 'LAO', 1),
1250
+				array(121, 'Latvia', 'LV', 'LVA', 2),
1251
+				array(122, 'Lesotho', 'LS', 'LSO', 1),
1252
+				array(123, 'Lebanon', 'LB', 'LBN', 1),
1253
+				array(124, 'Liberia', 'LR', 'LBR', 1),
1254
+				array(125, 'Libya', 'LY', 'LBY', 1),
1255
+				array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1256
+				array(127, 'Lithuania', 'LT', 'LTU', 2),
1257
+				array(128, 'Luxemburg', 'LU', 'LUX', 2),
1258
+				array(129, 'Macao', 'MO', 'MAC', 1),
1259
+				array(130, 'Macedonia', 'MK', 'MKD', 1),
1260
+				array(131, 'Madagascar', 'MG', 'MDG', 1),
1261
+				array(132, 'Malaysia', 'MY', 'MYS', 1),
1262
+				array(133, 'Malawi', 'MW', 'MWI', 1),
1263
+				array(134, 'Maldivas', 'MV', 'MDV', 1),
1264
+				array(135, 'Mali', 'ML', 'MLI', 1),
1265
+				array(136, 'Malta', 'MT', 'MLT', 2),
1266
+				array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1267
+				array(137, 'Morocco', 'MA', 'MAR', 1),
1268
+				array(104, 'Marshall islands', 'MH', 'MHL', 1),
1269
+				array(138, 'Martinique', 'MQ', 'MTQ', 1),
1270
+				array(139, 'Mauritius', 'MU', 'MUS', 1),
1271
+				array(140, 'Mauritania', 'MR', 'MRT', 1),
1272
+				array(141, 'Mayote', 'YT', 'MYT', 2),
1273
+				array(142, 'Mexico', 'MX', 'MEX', 1),
1274
+				array(143, 'Micronesia', 'FM', 'FSM', 1),
1275
+				array(144, 'Moldova', 'MD', 'MDA', 1),
1276
+				array(145, 'Monaco', 'MC', 'MCO', 2),
1277
+				array(146, 'Mongolia', 'MN', 'MNG', 1),
1278
+				array(147, 'Montserrat', 'MS', 'MSR', 1),
1279
+				array(227, 'Montenegro', 'ME', 'MNE', 2),
1280
+				array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1281
+				array(149, 'Myanmar', 'MM', 'MMR', 1),
1282
+				array(150, 'Namibia', 'NA', 'NAM', 1),
1283
+				array(151, 'Nauru', 'NR', 'NRU', 1),
1284
+				array(152, 'Nepal', 'NP', 'NPL', 1),
1285
+				array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1286
+				array(153, 'Nicaragua', 'NI', 'NIC', 1),
1287
+				array(154, 'Niger', 'NE', 'NER', 1),
1288
+				array(155, 'Nigeria', 'NG', 'NGA', 1),
1289
+				array(156, 'Niue', 'NU', 'NIU', 1),
1290
+				array(157, 'Norway', 'NO', 'NOR', 1),
1291
+				array(158, 'New Caledonia', 'NC', 'NCL', 1),
1292
+				array(159, 'New Zealand', 'NZ', 'NZL', 1),
1293
+				array(160, 'Oman', 'OM', 'OMN', 1),
1294
+				array(161, 'Pakistan', 'PK', 'PAK', 1),
1295
+				array(162, 'Palau', 'PW', 'PLW', 1),
1296
+				array(163, 'Panama', 'PA', 'PAN', 1),
1297
+				array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1298
+				array(165, 'Paraguay', 'PY', 'PRY', 1),
1299
+				array(166, 'Peru', 'PE', 'PER', 1),
1300
+				array(68, 'Philippines', 'PH', 'PHL', 1),
1301
+				array(167, 'Poland', 'PL', 'POL', 1),
1302
+				array(168, 'Portugal', 'PT', 'PRT', 2),
1303
+				array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1304
+				array(170, 'Qatar', 'QA', 'QAT', 1),
1305
+				array(176, 'Rwanda', 'RW', 'RWA', 1),
1306
+				array(177, 'Romania', 'RO', 'ROM', 2),
1307
+				array(178, 'Russia', 'RU', 'RUS', 1),
1308
+				array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1309
+				array(180, 'Samoa', 'WS', 'WSM', 1),
1310
+				array(181, 'American Samoa', 'AS', 'ASM', 1),
1311
+				array(183, 'San Marino', 'SM', 'SMR', 2),
1312
+				array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1313
+				array(185, 'Saint Helena', 'SH', 'SHN', 1),
1314
+				array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1315
+				array(188, 'Senegal', 'SN', 'SEN', 1),
1316
+				array(189, 'Seychelles', 'SC', 'SYC', 1),
1317
+				array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1318
+				array(191, 'Singapore', 'SG', 'SGP', 1),
1319
+				array(192, 'Syria', 'SY', 'SYR', 1),
1320
+				array(193, 'Somalia', 'SO', 'SOM', 1),
1321
+				array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1322
+				array(195, 'South Africa', 'ZA', 'ZAF', 1),
1323
+				array(196, 'Sudan', 'SD', 'SDN', 1),
1324
+				array(199, 'Suriname', 'SR', 'SUR', 1),
1325
+				array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1326
+				array(201, 'Thailand', 'TH', 'THA', 1),
1327
+				array(202, 'Taiwan', 'TW', 'TWN', 1),
1328
+				array(203, 'Tanzania', 'TZ', 'TZA', 1),
1329
+				array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1330
+				array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1331
+				array(207, 'Togo', 'TG', 'TGO', 1),
1332
+				array(208, 'Tokelau', 'TK', 'TKL', 1),
1333
+				array(209, 'Tonga', 'TO', 'TON', 1),
1334
+				array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1335
+				array(211, 'Tunisia', 'TN', 'TUN', 1),
1336
+				array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1337
+				array(213, 'Turkey', 'TR', 'TUR', 1),
1338
+				array(214, 'Tuvalu', 'TV', 'TUV', 1),
1339
+				array(215, 'Ukraine', 'UA', 'UKR', 1),
1340
+				array(216, 'Uganda', 'UG', 'UGA', 1),
1341
+				array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1342
+				array(217, 'Uruguay', 'UY', 'URY', 1),
1343
+				array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1344
+				array(219, 'Vanuatu', 'VU', 'VUT', 1),
1345
+				array(220, 'Vatican City', 'VA', 'VAT', 2),
1346
+				array(221, 'Venezuela', 'VE', 'VEN', 1),
1347
+				array(222, 'Vietnam', 'VN', 'VNM', 1),
1348
+				array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1349
+				array(223, 'Yemen', 'YE', 'YEM', 1),
1350
+				array(225, 'Zambia', 'ZM', 'ZMB', 1),
1351
+				array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1352
+		);
1353
+		$country_iso = 'US';
1354
+		foreach ($old_countries as $country_array) {
1355
+			//note: index 0 is the 3.1 country ID
1356
+			if ($country_array[0] == $country_id) {
1357
+				//note: index 2 is the ISO
1358
+				$country_iso = $country_array[2];
1359
+				break;
1360
+			}
1361
+		}
1362
+		return $country_iso;
1363
+	}
1364
+
1365
+
1366
+
1367
+	/**
1368
+	 * Gets the ISO3 for the
1369
+	 *
1370
+	 * @return string
1371
+	 */
1372
+	public function get_default_country_iso()
1373
+	{
1374
+		$old_org_options = get_option('events_organization_settings');
1375
+		$iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1376
+		return $iso;
1377
+	}
1378
+
1379
+
1380
+
1381
+	/**
1382
+	 * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1383
+	 *
1384
+	 * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1385
+	 * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1386
+	 *                                                  DEFAULT payment status, the event's DEFAULT payment status, or
1387
+	 *                                                  the attendee's payment status) required pre-approval.
1388
+	 * @return string STS_ID for use in 4.1
1389
+	 */
1390
+	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1391
+	{
1392
+		//EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1393
+		if ($this_thing_required_pre_approval) {
1394
+			return 'RNA';
1395
+		} else {
1396
+			$mapping = $default_reg_stati_conversions = array(
1397
+					'Completed'        => 'RAP',
1398
+					''                 => 'RPP',
1399
+					'Incomplete'       => 'RPP',
1400
+					'Pending'          => 'RAP',
1401
+					//stati that only occurred on 3.1 attendees:
1402
+					'Payment Declined' => 'RPP',
1403
+					'Not Completed'    => 'RPP',
1404
+					'Cancelled'        => 'RPP',
1405
+					'Declined'         => 'RPP',
1406
+			);
1407
+		}
1408
+		return isset($mapping[$payment_status]) ? $mapping[$payment_status] : 'RNA';
1409
+	}
1410
+
1411
+
1412
+
1413
+	/**
1414
+	 * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1415
+	 * and sets it as the featured image on the CPT event
1416
+	 *
1417
+	 * @param type                            $old_event
1418
+	 * @param type                            $new_cpt_id
1419
+	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1420
+	 * @return boolean whether or not we had to do the big job of creating an image attachment
1421
+	 */
1422
+	public function convert_image_url_to_attachment_and_attach_to_post(
1423
+			$guid,
1424
+			$new_cpt_id,
1425
+			EE_Data_Migration_Script_Stage $migration_stage
1426
+	) {
1427
+		$created_attachment_post = false;
1428
+		$guid = $this->_get_original_guid($guid);
1429
+		if ($guid) {
1430
+			//check for an existing attachment post with this guid
1431
+			$attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1432
+			if ( ! $attachment_post_id) {
1433
+				//post thumbnail with that GUID doesn't exist, we should create one
1434
+				$attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1435
+				$created_attachment_post = true;
1436
+			}
1437
+			//double-check we actually have an attachment post
1438
+			if ($attachment_post_id) {
1439
+				update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1440
+			} else {
1441
+				$migration_stage->add_error(sprintf(esc_html__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1442
+						"event_espresso"), $guid, $new_cpt_id, $attachment_post_id));
1443
+			}
1444
+		}
1445
+		return $created_attachment_post;
1446
+	}
1447
+
1448
+
1449
+
1450
+	/**
1451
+	 * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1452
+	 * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1453
+	 * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1454
+	 * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1455
+	 * exists
1456
+	 *
1457
+	 * @param string $guid_in_old_event
1458
+	 * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1459
+	 */
1460
+	private function _get_original_guid($guid_in_old_event)
1461
+	{
1462
+		$original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1463
+		//do a head request to verify the file exists
1464
+		$head_response = wp_remote_head($original_guid);
1465
+		if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1466
+			return $original_guid;
1467
+		} else {
1468
+			return $guid_in_old_event;
1469
+		}
1470
+	}
1471
+
1472
+
1473
+
1474
+	/**
1475
+	 * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1476
+	 * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1477
+	 * thumbnails)
1478
+	 *
1479
+	 * @param type                           $guid
1480
+	 * @param EE_Data_Migration_Script_Stage $migration_stage
1481
+	 * @return int
1482
+	 */
1483
+	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1484
+	{
1485
+		if ( ! $guid) {
1486
+			$migration_stage->add_error(sprintf(esc_html__("Cannot create image attachment for a blank GUID!",
1487
+					"event_espresso")));
1488
+			return 0;
1489
+		}
1490
+		$wp_filetype = wp_check_filetype(basename($guid), null);
1491
+		$wp_upload_dir = wp_upload_dir();
1492
+		//if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1493
+		if (strpos($guid, $wp_upload_dir['url']) === false) {
1494
+			//image is located remotely. download it and place it in the uploads directory
1495
+			if ( ! is_readable($guid)) {
1496
+				$migration_stage->add_error(sprintf(esc_html__("Could not create image attachment from non-existent file: %s",
1497
+						"event_espresso"), $guid));
1498
+				return 0;
1499
+			}
1500
+			$contents = file_get_contents($guid);
1501
+			if ($contents === false) {
1502
+				$migration_stage->add_error(sprintf(esc_html__("Could not read image at %s, and therefore couldnt create an attachment post for it.",
1503
+						"event_espresso"), $guid));
1504
+				return false;
1505
+			}
1506
+			$local_filepath = $wp_upload_dir['path'] . DS . basename($guid);
1507
+			$savefile = fopen($local_filepath, 'w');
1508
+			fwrite($savefile, $contents);
1509
+			fclose($savefile);
1510
+			$guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1511
+		} else {
1512
+			$local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1513
+		}
1514
+		$attachment = array(
1515
+				'guid'           => $guid,
1516
+				'post_mime_type' => $wp_filetype['type'],
1517
+				'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1518
+				'post_content'   => '',
1519
+				'post_status'    => 'inherit',
1520
+		);
1521
+		$attach_id = wp_insert_attachment($attachment, $guid);
1522
+		if ( ! $attach_id) {
1523
+			$migration_stage->add_error(sprintf(esc_html__("Could not create image attachment post from image '%s'. Attachment data was %s.",
1524
+					"event_espresso"), $guid, $this->_json_encode($attachment)));
1525
+			return $attach_id;
1526
+		}
1527
+		// you must first include the image.php file
1528
+		// for the function wp_generate_attachment_metadata() to work
1529
+		require_once(ABSPATH . 'wp-admin/includes/image.php');
1530
+		$attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1531
+		if ( ! $attach_data) {
1532
+			$migration_stage->add_error(sprintf(esc_html__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1533
+					"event_espresso"), $attach_id, $local_filepath, $guid));
1534
+			return $attach_id;
1535
+		}
1536
+		$metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1537
+		if ( ! $metadata_save_result) {
1538
+			$migration_stage->add_error(sprintf(esc_html__("Could not update attachment metadata for attachment %d with data %s",
1539
+					"event_espresso"), $attach_id, $this->_json_encode($attach_data)));
1540
+		}
1541
+		return $attach_id;
1542
+	}
1543
+
1544
+
1545
+
1546
+	/**
1547
+	 * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1548
+	 * and returns its ID.
1549
+	 *
1550
+	 * @global type  $wpdb
1551
+	 * @param string $guid
1552
+	 * @return int
1553
+	 */
1554
+	private function _get_image_attachment_id_by_GUID($guid)
1555
+	{
1556
+		global $wpdb;
1557
+		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1558
+		return $attachment_id;
1559
+	}
1560
+
1561
+
1562
+
1563
+	/**
1564
+	 * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1565
+	 * (and optionally a timezone; if none is given, the wp DEFAULT is used)
1566
+	 *
1567
+	 * @param EE_Data_Migration_Script_base $stage
1568
+	 * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1569
+	 *                                                   UTC time for
1570
+	 * @param string                        $DATETIME_string
1571
+	 * @param string                        $timezone
1572
+	 * @return string
1573
+	 */
1574
+	public function convert_date_string_to_utc(
1575
+			EE_Data_Migration_Script_Stage $stage,
1576
+			$row_of_data,
1577
+			$DATETIME_string,
1578
+			$timezone = null
1579
+	) {
1580
+		$original_tz = $timezone;
1581
+		if ( ! $timezone) {
1582
+			$timezone = $this->_get_wp_timezone();
1583
+		}
1584
+		if ( ! $timezone) {
1585
+			$stage->add_error(sprintf(esc_html__("Could not find timezone given %s for %s", "event_espresso"), $original_tz,
1586
+					$row_of_data));
1587
+			$timezone = 'UTC';
1588
+		}
1589
+		try {
1590
+			$date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1591
+			$date_obj->setTimezone(new DateTimeZone('UTC'));
1592
+		} catch (Exception $e) {
1593
+			$stage->add_error(sprintf(esc_html__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1594
+					"event_espresso"), $DATETIME_string, $timezone));
1595
+			$date_obj = new DateTime();
1596
+		}
1597
+		return $date_obj->format('Y-m-d H:i:s');
1598
+	}
1599
+
1600
+
1601
+
1602
+	/**
1603
+	 * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset)
1604
+	 *
1605
+	 * @return string
1606
+	 */
1607
+	private function _get_wp_timezone()
1608
+	{
1609
+		$timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1610
+		//if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1611
+		if (empty($timezone)) {
1612
+			//let's get a the WordPress UTC offset
1613
+			$offset = get_option('gmt_offset');
1614
+			$timezone = $this->timezone_convert_to_string_from_offset($offset);
1615
+		}
1616
+		return $timezone;
1617
+	}
1618
+
1619
+
1620
+
1621
+	/**
1622
+	 * Gets the wordpress timezone string from a UTC offset
1623
+	 *
1624
+	 * @param int $offset
1625
+	 * @return boolean
1626
+	 */
1627
+	private function timezone_convert_to_string_from_offset($offset)
1628
+	{
1629
+		//shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
1630
+		$offset *= 3600; // convert hour offset to seconds
1631
+		$abbrarray = timezone_abbreviations_list();
1632
+		foreach ($abbrarray as $abbr) {
1633
+			foreach ($abbr as $city) {
1634
+				if ($city['offset'] == $offset) {
1635
+					return $city['timezone_id'];
1636
+				}
1637
+			}
1638
+		}
1639
+		return false;
1640
+	}
1641
+
1642
+
1643
+
1644
+	public function migration_page_hooks()
1645
+	{
1646
+		add_filter(
1647
+				'FHEE__ee_migration_page__header',
1648
+				array($this, '_migrate_page_hook_simplify_version_strings'),
1649
+				10,
1650
+				3
1651
+		);
1652
+		add_filter(
1653
+				'FHEE__ee_migration_page__p_after_header',
1654
+				array($this, '_migration_page_hook_simplify_next_db_state'),
1655
+				10,
1656
+				2
1657
+		);
1658
+		add_filter(
1659
+				'FHEE__ee_migration_page__option_1_main',
1660
+				array($this, '_migrate_page_hook_simplify_version_strings'),
1661
+				10,
1662
+				3
1663
+		);
1664
+		add_filter(
1665
+				'FHEE__ee_migration_page__option_1_button_text',
1666
+				array($this, '_migrate_page_hook_simplify_version_strings'),
1667
+				10,
1668
+				3
1669
+		);
1670
+		add_action(
1671
+				'AHEE__ee_migration_page__option_1_extra_details',
1672
+				array($this, '_migration_page_hook_option_1_extra_details'),
1673
+				10,
1674
+				3
1675
+		);
1676
+		add_filter(
1677
+				'FHEE__ee_migration_page__option_2_main',
1678
+				array($this, '_migrate_page_hook_simplify_version_strings'),
1679
+				10,
1680
+				4
1681
+		);
1682
+		add_filter(
1683
+				'FHEE__ee_migration_page__option_2_button_text',
1684
+				array($this, '_migration_page_hook_simplify_next_db_state'),
1685
+				10,
1686
+				2
1687
+		);
1688
+		add_filter(
1689
+				'FHEE__ee_migration_page__option_2_details',
1690
+				array($this, '_migration_page_hook_simplify_next_db_state'),
1691
+				10,
1692
+				2
1693
+		);
1694
+		add_action(
1695
+				'AHEE__ee_migration_page__after_migration_options_table',
1696
+				array($this, '_migration_page_hook_after_migration_options_table')
1697
+		);
1698
+		add_filter(
1699
+				'FHEE__ee_migration_page__done_migration_header',
1700
+				array($this, '_migration_page_hook_simplify_next_db_state'),
1701
+				10,
1702
+				2
1703
+		);
1704
+		add_filter(
1705
+				'FHEE__ee_migration_page__p_after_done_migration_header',
1706
+				array($this, '_migration_page_hook_simplify_next_db_state'),
1707
+				10,
1708
+				2
1709
+		);
1710
+		add_filter(
1711
+				'FHEE__ee_migration_page__migration_options_template',
1712
+				array($this,'use_migration_options_from_ee3_template')
1713
+		);
1714
+	}
1715
+
1716
+
1717
+
1718
+	public function _migrate_page_hook_simplify_version_strings(
1719
+			$old_content,
1720
+			$current_db_state,
1721
+			$next_db_state,
1722
+			$ultimate_db_state = null
1723
+	) {
1724
+		return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state),
1725
+				array(esc_html__('EE3', 'event_espresso'), esc_html__('EE4', 'event_espresso'), esc_html__("EE4", 'event_espresso')),
1726
+				$old_content);
1727
+	}
1728
+
1729
+
1730
+
1731
+	public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1732
+	{
1733
+		return str_replace($next_db_state, esc_html__("EE4", 'event_espresso'), $old_content);
1734
+	}
1735
+
1736
+
1737
+
1738
+	public function _migration_page_hook_option_1_extra_details()
1739
+	{
1740
+		?>
1741 1741
         <p><?php printf(esc_html__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents",
1742
-            "event_espresso")); ?></p><?php
1743
-    }
1742
+			"event_espresso")); ?></p><?php
1743
+	}
1744 1744
 
1745 1745
 
1746 1746
 
1747
-    public function _migration_page_hook_after_migration_options_table()
1748
-    {
1749
-        ?><p class="ee-attention">
1747
+	public function _migration_page_hook_after_migration_options_table()
1748
+	{
1749
+		?><p class="ee-attention">
1750 1750
         <strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ",
1751
-                        "event_espresso"); ?></span></strong>
1751
+						"event_espresso"); ?></span></strong>
1752 1752
         <br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.",
1753
-            "event_espresso"); ?>
1753
+			"event_espresso"); ?>
1754 1754
         </p><?php
1755
-    }
1755
+	}
1756 1756
 
1757 1757
 
1758 1758
 
1759
-    /**
1760
-     * When showing the migration options, show more options and info than normal (ie, give folks the option
1761
-     * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because
1762
-     * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea).
1763
-     * @param $template_filepath
1764
-     * @return string
1765
-     */
1766
-    public function use_migration_options_from_ee3_template( $template_filepath ) {
1767
-        return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1768
-    }
1759
+	/**
1760
+	 * When showing the migration options, show more options and info than normal (ie, give folks the option
1761
+	 * to start using EE4 without migrating. From EE3 that's fine, because it doesn't actually remove any data, because
1762
+	 * EE4 doesn't have any yet. But when migrating from EE4 it would remove old data, so its not a great idea).
1763
+	 * @param $template_filepath
1764
+	 * @return string
1765
+	 */
1766
+	public function use_migration_options_from_ee3_template( $template_filepath ) {
1767
+		return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1768
+	}
1769 1769
 }
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 //unfortunately, this needs to be done upon INCLUSION of this file,
10 10
 //instead of construction, because it only gets constructed on first page load
11 11
 //(all other times it gets resurrected from a wordpress option)
12
-$stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
12
+$stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 if ( ! empty($stages)) {
15 15
     foreach ($stages as $filepath) {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     private function _checkin_table_exists()
88 88
     {
89 89
         global $wpdb;
90
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
90
+        $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
91 91
         if ($results) {
92 92
             return true;
93 93
         } else {
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 //			echo "no version string provided: $version_string";
108 108
             //no version string provided... this must be pre 4.1
109 109
             //because since 4.1 we're
110
-            return false;//changed mind. dont want people thinking they should migrate yet because they cant
110
+            return false; //changed mind. dont want people thinking they should migrate yet because they cant
111 111
         } else {
112 112
 //			echo "$version_string doesnt apply";
113 113
             return false;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     public function schema_changes_before_migration()
120 120
     {
121 121
         //relies on 4.1's EEH_Activation::create_table
122
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
122
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
123 123
         $table_name = 'esp_answer';
124 124
         $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
125 125
 					REG_ID INT UNSIGNED NOT NULL,
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
     public function insert_default_states()
504 504
     {
505 505
         global $wpdb;
506
-        $state_table = $wpdb->prefix . "esp_state";
506
+        $state_table = $wpdb->prefix."esp_state";
507 507
         if ($this->_get_table_analysis()->tableExists($state_table)) {
508
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
508
+            $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table;
509 509
             $states = $wpdb->get_var($SQL);
510 510
             if ( ! $states) {
511
-                $SQL = "INSERT INTO " . $state_table . "
511
+                $SQL = "INSERT INTO ".$state_table."
512 512
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
513 513
 				(1, 'US', 'AK', 'Alaska', 1),
514 514
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -596,12 +596,12 @@  discard block
 block discarded – undo
596 596
     public function insert_default_countries()
597 597
     {
598 598
         global $wpdb;
599
-        $country_table = $wpdb->prefix . "esp_country";
599
+        $country_table = $wpdb->prefix."esp_country";
600 600
         if ($this->_get_table_analysis()->tableExists($country_table)) {
601
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
601
+            $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table;
602 602
             $countries = $wpdb->get_var($SQL);
603 603
             if ( ! $countries) {
604
-                $SQL = "INSERT INTO " . $country_table . "
604
+                $SQL = "INSERT INTO ".$country_table."
605 605
 				(CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES
606 606
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
607 607
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -846,17 +846,17 @@  discard block
 block discarded – undo
846 846
     public function insert_default_price_types()
847 847
     {
848 848
         global $wpdb;
849
-        $price_type_table = $wpdb->prefix . "esp_price_type";
849
+        $price_type_table = $wpdb->prefix."esp_price_type";
850 850
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
851
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
851
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
852 852
             $price_types_exist = $wpdb->get_var($SQL);
853 853
             if ( ! $price_types_exist) {
854 854
                 $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
855
-							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
856
-							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
857
-							(3, '" . esc_html__('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
858
-							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
859
-							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
855
+							(1, '".esc_html__('Base Price', 'event_espresso')."', 1,  0, 0, 0),
856
+							(2, '" . esc_html__('Percent Discount', 'event_espresso')."', 2,  1, 20, 0),
857
+							(3, '" . esc_html__('Fixed Discount', 'event_espresso')."', 2,  0, 30, 0),
858
+							(4, '" . esc_html__('Percent Surcharge', 'event_espresso')."', 3,  1, 40, 0),
859
+							(5, '" . esc_html__('Fixed Surcharge', 'event_espresso')."', 3,  0, 50, 0);";
860 860
                 $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
861 861
                 $wpdb->query($SQL);
862 862
             }
@@ -878,9 +878,9 @@  discard block
 block discarded – undo
878 878
     public function insert_default_prices()
879 879
     {
880 880
         global $wpdb;
881
-        $price_table = $wpdb->prefix . "esp_price";
881
+        $price_table = $wpdb->prefix."esp_price";
882 882
         if ($this->_get_table_analysis()->tableExists($price_table)) {
883
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
883
+            $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
884 884
             $prices_exist = $wpdb->get_var($SQL);
885 885
             if ( ! $prices_exist) {
886 886
                 $SQL = "INSERT INTO $price_table
@@ -904,9 +904,9 @@  discard block
 block discarded – undo
904 904
     public function insert_default_tickets()
905 905
     {
906 906
         global $wpdb;
907
-        $ticket_table = $wpdb->prefix . "esp_ticket";
907
+        $ticket_table = $wpdb->prefix."esp_ticket";
908 908
         if ($this->_get_table_analysis()->tableExists($ticket_table)) {
909
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
909
+            $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
910 910
             $tickets_exist = $wpdb->get_var($SQL);
911 911
             if ( ! $tickets_exist) {
912 912
                 $SQL = "INSERT INTO $ticket_table
@@ -918,9 +918,9 @@  discard block
 block discarded – undo
918 918
                 $wpdb->query($SQL);
919 919
             }
920 920
         }
921
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
921
+        $ticket_price_table = $wpdb->prefix."esp_ticket_price";
922 922
         if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
923
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
923
+            $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
924 924
             $ticket_prc_exist = $wpdb->get_var($SQL);
925 925
             if ( ! $ticket_prc_exist) {
926 926
                 $SQL = "INSERT INTO $ticket_price_table
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
             throw new EE_Error(esc_html__("Could not get a country because country name is blank", "event_espresso"));
951 951
         }
952 952
         global $wpdb;
953
-        $country_table = $wpdb->prefix . "esp_country";
953
+        $country_table = $wpdb->prefix."esp_country";
954 954
         if (is_int($country_name)) {
955 955
             $country_name = $this->get_iso_from_3_1_country_id($country_name);
956 956
         }
@@ -978,21 +978,21 @@  discard block
 block discarded – undo
978 978
                     'CNT_active'      => true,
979 979
             );
980 980
             $data_types = array(
981
-                    '%s',//CNT_ISO
982
-                    '%s',//CNT_ISO3
983
-                    '%d',//RGN_ID
984
-                    '%s',//CNT_name
985
-                    '%s',//CNT_cur_code
986
-                    '%s',//CNT_cur_single
987
-                    '%s',//CNT_cur_plural
988
-                    '%s',//CNT_cur_sign
989
-                    '%d',//CNT_cur_sign_b4
990
-                    '%d',//CNT_cur_dec_plc
991
-                    '%s',//CNT_cur_dec_mrk
992
-                    '%s',//CNT_cur_thsnds
993
-                    '%s',//CNT_tel_code
994
-                    '%d',//CNT_is_EU
995
-                    '%d',//CNT_active
981
+                    '%s', //CNT_ISO
982
+                    '%s', //CNT_ISO3
983
+                    '%d', //RGN_ID
984
+                    '%s', //CNT_name
985
+                    '%s', //CNT_cur_code
986
+                    '%s', //CNT_cur_single
987
+                    '%s', //CNT_cur_plural
988
+                    '%s', //CNT_cur_sign
989
+                    '%d', //CNT_cur_sign_b4
990
+                    '%d', //CNT_cur_dec_plc
991
+                    '%s', //CNT_cur_dec_mrk
992
+                    '%s', //CNT_cur_thsnds
993
+                    '%s', //CNT_tel_code
994
+                    '%d', //CNT_is_EU
995
+                    '%d', //CNT_active
996 996
             );
997 997
             $success = $wpdb->insert($country_table,
998 998
                     $cols_n_values,
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
     private function _find_available_country_iso($num_letters = 2)
1018 1018
     {
1019 1019
         global $wpdb;
1020
-        $country_table = $wpdb->prefix . "esp_country";
1020
+        $country_table = $wpdb->prefix."esp_country";
1021 1021
         $attempts = 0;
1022 1022
         do {
1023 1023
             $current_iso = strtoupper(wp_generate_password($num_letters, false));
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
             //keep going until we find an available country code, or we arbitrarily
1029 1029
             //decide we've tried this enough. Somehow they have way too many countries
1030 1030
             //(probably because they're mis-using the EE3 country_id like a custom question)
1031
-        } while (intval($country_with_that_iso) && $attempts < 200);
1031
+        }while (intval($country_with_that_iso) && $attempts < 200);
1032 1032
         return $current_iso;
1033 1033
     }
1034 1034
 
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
             $country_iso = $this->get_default_country_iso();
1056 1056
         }
1057 1057
         global $wpdb;
1058
-        $state_table = $wpdb->prefix . "esp_state";
1058
+        $state_table = $wpdb->prefix."esp_state";
1059 1059
         $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1060 1060
 			(STA_abbrev LIKE %s OR
1061 1061
 			STA_name LIKE %s) AND
@@ -1069,10 +1069,10 @@  discard block
 block discarded – undo
1069 1069
                     'STA_active' => true,
1070 1070
             );
1071 1071
             $data_types = array(
1072
-                    '%s',//CNT_ISO
1073
-                    '%s',//STA_abbrev
1074
-                    '%s',//STA_name
1075
-                    '%d',//STA_active
1072
+                    '%s', //CNT_ISO
1073
+                    '%s', //STA_abbrev
1074
+                    '%s', //STA_name
1075
+                    '%d', //STA_active
1076 1076
             );
1077 1077
             $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1078 1078
             if ( ! $success) {
@@ -1503,7 +1503,7 @@  discard block
 block discarded – undo
1503 1503
                         "event_espresso"), $guid));
1504 1504
                 return false;
1505 1505
             }
1506
-            $local_filepath = $wp_upload_dir['path'] . DS . basename($guid);
1506
+            $local_filepath = $wp_upload_dir['path'].DS.basename($guid);
1507 1507
             $savefile = fopen($local_filepath, 'w');
1508 1508
             fwrite($savefile, $contents);
1509 1509
             fclose($savefile);
@@ -1526,7 +1526,7 @@  discard block
 block discarded – undo
1526 1526
         }
1527 1527
         // you must first include the image.php file
1528 1528
         // for the function wp_generate_attachment_metadata() to work
1529
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1529
+        require_once(ABSPATH.'wp-admin/includes/image.php');
1530 1530
         $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1531 1531
         if ( ! $attach_data) {
1532 1532
             $migration_stage->add_error(sprintf(esc_html__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
         );
1710 1710
         add_filter(
1711 1711
                 'FHEE__ee_migration_page__migration_options_template',
1712
-                array($this,'use_migration_options_from_ee3_template')
1712
+                array($this, 'use_migration_options_from_ee3_template')
1713 1713
         );
1714 1714
     }
1715 1715
 
@@ -1763,7 +1763,7 @@  discard block
 block discarded – undo
1763 1763
      * @param $template_filepath
1764 1764
      * @return string
1765 1765
      */
1766
-    public function use_migration_options_from_ee3_template( $template_filepath ) {
1767
-        return EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee3.template.php';
1766
+    public function use_migration_options_from_ee3_template($template_filepath) {
1767
+        return EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee3.template.php';
1768 1768
     }
1769 1769
 }
Please login to merge, or discard this patch.
core/EE_Capabilities.core.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
      * @since                        4.5.0
806 806
      *
807 807
      * @param string $meta_cap   What meta capability is this mapping.
808
-     * @param array  $map_values array {
808
+     * @param string[]  $map_values array {
809 809
      *                           //array of values that MUST match a count of 4.  It's okay to send an empty string for
810 810
      *                           capabilities that don't get mapped to.
811 811
      *
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
      * @since 4.6.x
881 881
      *
882 882
      * @param $caps
883
-     * @param $cap
884
-     * @param $user_id
883
+     * @param string $cap
884
+     * @param integer $user_id
885 885
      * @param $args
886 886
      *
887 887
      * @return array
Please login to merge, or discard this patch.
Indentation   +1389 added lines, -1389 removed lines patch added patch discarded remove patch
@@ -18,1001 +18,1001 @@  discard block
 block discarded – undo
18 18
 final class EE_Capabilities extends EE_Base
19 19
 {
20 20
 
21
-    /**
22
-     * the name of the wp option used to store caps previously initialized
23
-     */
24
-    const option_name = 'ee_caps_initialized';
25
-
26
-    /**
27
-     * instance of EE_Capabilities object
28
-     *
29
-     * @var EE_Capabilities
30
-     */
31
-    private static $_instance;
32
-
33
-
34
-    /**
35
-     * This is a map of caps that correspond to a default WP_Role.
36
-     * Array is indexed by Role and values are ee capabilities.
37
-     *
38
-     * @since 4.5.0
39
-     *
40
-     * @var array
41
-     */
42
-    private $capabilities_map = array();
43
-
44
-    /**
45
-     * This used to hold an array of EE_Meta_Capability_Map objects
46
-     * that define the granular capabilities mapped to for a user depending on context.
47
-     *
48
-     * @var EE_Meta_Capability_Map[]
49
-     */
50
-    private $_meta_caps = array();
51
-
52
-    /**
53
-     * The internal $capabilities_map needs to be initialized before it can be used.
54
-     * This flag tracks whether that has happened or not.
55
-     * But for this to work, we need three states to indicate:
56
-     *      initialization has not occurred at all
57
-     *      initialization has started but is not complete
58
-     *      initialization is complete
59
-     * The reason this is needed is because the addCaps() method
60
-     * normally requires the $capabilities_map to be initialized,
61
-     * but is also used during the initialization process.
62
-     * So:
63
-     *      If initialized === null, init_caps() will be called before any other methods will run.
64
-     *      If initialized === false, then init_caps() is in the process of running it's logic.
65
-     *      If initialized === true, then init_caps() has completed the initialization process.
66
-     *
67
-     * @var boolean|null $initialized
68
-     */
69
-    private $initialized;
70
-
71
-    /**
72
-     * @var boolean $reset
73
-     */
74
-    private $reset = false;
75
-
76
-
77
-
78
-    /**
79
-     * singleton method used to instantiate class object
80
-     *
81
-     * @since 4.5.0
82
-     *
83
-     * @return EE_Capabilities
84
-     */
85
-    public static function instance()
86
-    {
87
-        //check if instantiated, and if not do so.
88
-        if (! self::$_instance instanceof EE_Capabilities) {
89
-            self::$_instance = new self();
90
-        }
91
-        return self::$_instance;
92
-    }
93
-
94
-
95
-
96
-    /**
97
-     * private constructor
98
-     *
99
-     * @since 4.5.0
100
-     */
101
-    private function __construct()
102
-    {
103
-    }
104
-
105
-
106
-
107
-    /**
108
-     * This delays the initialization of the capabilities class until EE_System core is loaded and ready.
109
-     *
110
-     * @param bool $reset allows for resetting the default capabilities saved on roles.  Note that this doesn't
111
-     *                    actually REMOVE any capabilities from existing roles, it just resaves defaults roles and
112
-     *                    ensures that they are up to date.
113
-     *
114
-     * @since 4.5.0
115
-     * @return bool
116
-     * @throws EE_Error
117
-     */
118
-    public function init_caps($reset = false)
119
-    {
120
-        if(! EE_Maintenance_Mode::instance()->models_can_query()){
121
-            return false;
122
-        }
123
-        $this->reset = filter_var($reset, FILTER_VALIDATE_BOOLEAN);
124
-        // if reset, then completely delete the cache option and clear the $capabilities_map property.
125
-        if ($this->reset) {
126
-            $this->initialized = null;
127
-            $this->capabilities_map = array();
128
-            delete_option(self::option_name);
129
-        }
130
-        if ($this->initialized === null) {
131
-            $this->initialized = false;
132
-            do_action(
133
-                'AHEE__EE_Capabilities__init_caps__before_initialization',
134
-                $this->reset
135
-            );
136
-            $this->addCaps($this->_init_caps_map());
137
-            $this->_set_meta_caps();
138
-            do_action(
139
-                'AHEE__EE_Capabilities__init_caps__after_initialization',
140
-                $this->capabilities_map
141
-            );
142
-            $this->initialized = true;
143
-        }
144
-        // reset $this->reset so that it's not stuck on true if init_caps() gets called again
145
-        $this->reset = false;
146
-        return true;
147
-    }
148
-
149
-
150
-
151
-
152
-    /**
153
-     * This sets the meta caps property.
154
-     *
155
-     * @since 4.5.0
156
-     * @return void
157
-     * @throws EE_Error
158
-     */
159
-    private function _set_meta_caps()
160
-    {
161
-        // get default meta caps and filter the returned array
162
-        $this->_meta_caps = apply_filters(
163
-            'FHEE__EE_Capabilities___set_meta_caps__meta_caps',
164
-            $this->_get_default_meta_caps_array()
165
-        );
166
-        //add filter for map_meta_caps but only if models can query.
167
-        if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) {
168
-            add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4);
169
-        }
170
-    }
171
-
172
-
173
-
174
-    /**
175
-     * This builds and returns the default meta_caps array only once.
176
-     *
177
-     * @since  4.8.28.rc.012
178
-     * @return array
179
-     * @throws EE_Error
180
-     */
181
-    private function _get_default_meta_caps_array()
182
-    {
183
-        static $default_meta_caps = array();
184
-        // make sure we're only ever initializing the default _meta_caps array once if it's empty.
185
-        if (empty($default_meta_caps)) {
186
-            $default_meta_caps = array(
187
-                //edits
188
-                new EE_Meta_Capability_Map_Edit(
189
-                    'ee_edit_event',
190
-                    array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')
191
-                ),
192
-                new EE_Meta_Capability_Map_Edit(
193
-                    'ee_edit_venue',
194
-                    array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')
195
-                ),
196
-                new EE_Meta_Capability_Map_Edit(
197
-                    'ee_edit_registration',
198
-                    array('Registration', '', 'ee_edit_others_registrations', '')
199
-                ),
200
-                new EE_Meta_Capability_Map_Edit(
201
-                    'ee_edit_checkin',
202
-                    array('Registration', '', 'ee_edit_others_checkins', '')
203
-                ),
204
-                new EE_Meta_Capability_Map_Messages_Cap(
205
-                    'ee_edit_message',
206
-                    array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')
207
-                ),
208
-                new EE_Meta_Capability_Map_Edit(
209
-                    'ee_edit_default_ticket',
210
-                    array('Ticket', '', 'ee_edit_others_default_tickets', '')
211
-                ),
212
-                new EE_Meta_Capability_Map_Registration_Form_Cap(
213
-                    'ee_edit_question',
214
-                    array('Question', '', '', 'ee_edit_system_questions')
215
-                ),
216
-                new EE_Meta_Capability_Map_Registration_Form_Cap(
217
-                    'ee_edit_question_group',
218
-                    array('Question_Group', '', '', 'ee_edit_system_question_groups')
219
-                ),
220
-                new EE_Meta_Capability_Map_Edit(
221
-                    'ee_edit_payment_method',
222
-                    array('Payment_Method', '', 'ee_edit_others_payment_methods', '')
223
-                ),
224
-                //reads
225
-                new EE_Meta_Capability_Map_Read(
226
-                    'ee_read_event',
227
-                    array('Event', '', 'ee_read_others_events', 'ee_read_private_events')
228
-                ),
229
-                new EE_Meta_Capability_Map_Read(
230
-                    'ee_read_venue',
231
-                    array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')
232
-                ),
233
-                new EE_Meta_Capability_Map_Read(
234
-                    'ee_read_registration',
235
-                    array('Registration', '', 'ee_read_others_registrations', '')
236
-                ),
237
-                new EE_Meta_Capability_Map_Read(
238
-                    'ee_read_checkin',
239
-                    array('Registration', '', 'ee_read_others_checkins', '')
240
-                ),
241
-                new EE_Meta_Capability_Map_Messages_Cap(
242
-                    'ee_read_message',
243
-                    array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')
244
-                ),
245
-                new EE_Meta_Capability_Map_Read(
246
-                    'ee_read_default_ticket',
247
-                    array('Ticket', '', 'ee_read_others_default_tickets', '')
248
-                ),
249
-                new EE_Meta_Capability_Map_Read(
250
-                    'ee_read_payment_method',
251
-                    array('Payment_Method', '', 'ee_read_others_payment_methods', '')
252
-                ),
253
-                //deletes
254
-                new EE_Meta_Capability_Map_Delete(
255
-                    'ee_delete_event',
256
-                    array(
257
-                        'Event',
258
-                        'ee_delete_published_events',
259
-                        'ee_delete_others_events',
260
-                        'ee_delete_private_events',
261
-                    )
262
-                ),
263
-                new EE_Meta_Capability_Map_Delete(
264
-                    'ee_delete_venue',
265
-                    array(
266
-                        'Venue',
267
-                        'ee_delete_published_venues',
268
-                        'ee_delete_others_venues',
269
-                        'ee_delete_private_venues',
270
-                    )
271
-                ),
272
-                new EE_Meta_Capability_Map_Delete(
273
-                    'ee_delete_registration',
274
-                    array('Registration', '', 'ee_delete_others_registrations', '')
275
-                ),
276
-                new EE_Meta_Capability_Map_Delete(
277
-                    'ee_delete_checkin',
278
-                    array('Registration', '', 'ee_delete_others_checkins', '')
279
-                ),
280
-                new EE_Meta_Capability_Map_Messages_Cap(
281
-                    'ee_delete_message',
282
-                    array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')
283
-                ),
284
-                new EE_Meta_Capability_Map_Delete(
285
-                    'ee_delete_default_ticket',
286
-                    array('Ticket', '', 'ee_delete_others_default_tickets', '')
287
-                ),
288
-                new EE_Meta_Capability_Map_Registration_Form_Cap(
289
-                    'ee_delete_question',
290
-                    array('Question', '', '', 'delete_system_questions')
291
-                ),
292
-                new EE_Meta_Capability_Map_Registration_Form_Cap(
293
-                    'ee_delete_question_group',
294
-                    array('Question_Group', '', '', 'delete_system_question_groups')
295
-                ),
296
-                new EE_Meta_Capability_Map_Delete(
297
-                    'ee_delete_payment_method',
298
-                    array('Payment_Method', '', 'ee_delete_others_payment_methods', '')
299
-                ),
300
-            );
301
-        }
302
-        return $default_meta_caps;
303
-    }
304
-
305
-
306
-
307
-    /**
308
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
309
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
310
-     *
311
-     * The actual logic is carried out by implementer classes in their definition of _map_meta_caps.
312
-     *
313
-     * @since 4.5.0
314
-     * @see   wp-includes/capabilities.php
315
-     *
316
-     * @param array  $caps    actual users capabilities
317
-     * @param string $cap     initial capability name that is being checked (the "map" key)
318
-     * @param int    $user_id The user id
319
-     * @param array  $args    Adds context to the cap. Typically the object ID.
320
-     * @return array actual users capabilities
321
-     * @throws EE_Error
322
-     */
323
-    public function map_meta_caps($caps, $cap, $user_id, $args)
324
-    {
325
-        if (did_action('AHEE__EE_System__load_espresso_addons__complete')) {
326
-            //loop through our _meta_caps array
327
-            foreach ($this->_meta_caps as $meta_map) {
328
-                if (! $meta_map instanceof EE_Meta_Capability_Map) {
329
-                    continue;
330
-                }
331
-                // don't load models if there is no object ID in the args
332
-                if (! empty($args[0])) {
333
-                    $meta_map->ensure_is_model();
334
-                }
335
-                $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args);
336
-            }
337
-        }
338
-        return $caps;
339
-    }
340
-
341
-
342
-
343
-    /**
344
-     * This sets up and returns the initial capabilities map for Event Espresso
345
-     * Note this array is filtered.
346
-     * It is assumed that all available EE capabilities are assigned to the administrator role.
347
-     *
348
-     * @since 4.5.0
349
-     *
350
-     * @return array
351
-     */
352
-    private function _init_caps_map()
353
-    {
354
-        return apply_filters(
355
-            'FHEE__EE_Capabilities__init_caps_map__caps',
356
-            array(
357
-                'administrator'           => array(
358
-                    //basic access
359
-                    'ee_read_ee',
360
-                    //gateways
361
-                    /**
362
-                     * note that with payment method capabilities, although we've implemented
363
-                     * capability mapping which will be used for accessing payment methods owned by
364
-                     * other users.  This is not fully implemented yet in the payment method ui.
365
-                     * Currently only the "plural" caps are in active use.
366
-                     * (Specific payment method caps are in use as well).
367
-                     **/
368
-                    'ee_manage_gateways',
369
-                    'ee_read_payment_methods',
370
-                    'ee_read_others_payment_methods',
371
-                    'ee_edit_payment_methods',
372
-                    'ee_edit_others_payment_methods',
373
-                    'ee_delete_payment_methods',
374
-                    //events
375
-                    'ee_publish_events',
376
-                    'ee_read_private_events',
377
-                    'ee_read_others_events',
378
-                    'ee_read_events',
379
-                    'ee_edit_events',
380
-                    'ee_edit_published_events',
381
-                    'ee_edit_others_events',
382
-                    'ee_edit_private_events',
383
-                    'ee_delete_published_events',
384
-                    'ee_delete_private_events',
385
-                    'ee_delete_events',
386
-                    'ee_delete_others_events',
387
-                    //event categories
388
-                    'ee_manage_event_categories',
389
-                    'ee_edit_event_category',
390
-                    'ee_delete_event_category',
391
-                    'ee_assign_event_category',
392
-                    //venues
393
-                    'ee_publish_venues',
394
-                    'ee_read_venues',
395
-                    'ee_read_others_venues',
396
-                    'ee_read_private_venues',
397
-                    'ee_edit_venues',
398
-                    'ee_edit_others_venues',
399
-                    'ee_edit_published_venues',
400
-                    'ee_edit_private_venues',
401
-                    'ee_delete_venues',
402
-                    'ee_delete_others_venues',
403
-                    'ee_delete_private_venues',
404
-                    'ee_delete_published_venues',
405
-                    //venue categories
406
-                    'ee_manage_venue_categories',
407
-                    'ee_edit_venue_category',
408
-                    'ee_delete_venue_category',
409
-                    'ee_assign_venue_category',
410
-                    //contacts
411
-                    'ee_read_contacts',
412
-                    'ee_edit_contacts',
413
-                    'ee_delete_contacts',
414
-                    //registrations
415
-                    'ee_read_registrations',
416
-                    'ee_read_others_registrations',
417
-                    'ee_edit_registrations',
418
-                    'ee_edit_others_registrations',
419
-                    'ee_delete_registrations',
420
-                    //checkins
421
-                    'ee_read_others_checkins',
422
-                    'ee_read_checkins',
423
-                    'ee_edit_checkins',
424
-                    'ee_edit_others_checkins',
425
-                    'ee_delete_checkins',
426
-                    'ee_delete_others_checkins',
427
-                    //transactions && payments
428
-                    'ee_read_transaction',
429
-                    'ee_read_transactions',
430
-                    'ee_edit_payments',
431
-                    'ee_delete_payments',
432
-                    //messages
433
-                    'ee_read_messages',
434
-                    'ee_read_others_messages',
435
-                    'ee_read_global_messages',
436
-                    'ee_edit_global_messages',
437
-                    'ee_edit_messages',
438
-                    'ee_edit_others_messages',
439
-                    'ee_delete_messages',
440
-                    'ee_delete_others_messages',
441
-                    'ee_delete_global_messages',
442
-                    'ee_send_message',
443
-                    //tickets
444
-                    'ee_read_default_tickets',
445
-                    'ee_read_others_default_tickets',
446
-                    'ee_edit_default_tickets',
447
-                    'ee_edit_others_default_tickets',
448
-                    'ee_delete_default_tickets',
449
-                    'ee_delete_others_default_tickets',
450
-                    //prices
451
-                    'ee_edit_default_price',
452
-                    'ee_edit_default_prices',
453
-                    'ee_delete_default_price',
454
-                    'ee_delete_default_prices',
455
-                    'ee_edit_default_price_type',
456
-                    'ee_edit_default_price_types',
457
-                    'ee_delete_default_price_type',
458
-                    'ee_delete_default_price_types',
459
-                    'ee_read_default_prices',
460
-                    'ee_read_default_price_types',
461
-                    //registration form
462
-                    'ee_edit_questions',
463
-                    'ee_edit_system_questions',
464
-                    'ee_read_questions',
465
-                    'ee_delete_questions',
466
-                    'ee_edit_question_groups',
467
-                    'ee_read_question_groups',
468
-                    'ee_edit_system_question_groups',
469
-                    'ee_delete_question_groups',
470
-                    //event_type taxonomy
471
-                    'ee_assign_event_type',
472
-                    'ee_manage_event_types',
473
-                    'ee_edit_event_type',
474
-                    'ee_delete_event_type',
475
-                ),
476
-                'ee_events_administrator' => array(
477
-                    //core wp caps
478
-                    'read',
479
-                    'read_private_pages',
480
-                    'read_private_posts',
481
-                    'edit_users',
482
-                    'edit_posts',
483
-                    'edit_pages',
484
-                    'edit_published_posts',
485
-                    'edit_published_pages',
486
-                    'edit_private_pages',
487
-                    'edit_private_posts',
488
-                    'edit_others_posts',
489
-                    'edit_others_pages',
490
-                    'publish_posts',
491
-                    'publish_pages',
492
-                    'delete_posts',
493
-                    'delete_pages',
494
-                    'delete_private_pages',
495
-                    'delete_private_posts',
496
-                    'delete_published_pages',
497
-                    'delete_published_posts',
498
-                    'delete_others_posts',
499
-                    'delete_others_pages',
500
-                    'manage_categories',
501
-                    'manage_links',
502
-                    'moderate_comments',
503
-                    'unfiltered_html',
504
-                    'upload_files',
505
-                    'export',
506
-                    'import',
507
-                    'list_users',
508
-                    'level_1', //required if user with this role shows up in author dropdowns
509
-                    //basic ee access
510
-                    'ee_read_ee',
511
-                    //events
512
-                    'ee_publish_events',
513
-                    'ee_read_private_events',
514
-                    'ee_read_others_events',
515
-                    'ee_read_event',
516
-                    'ee_read_events',
517
-                    'ee_edit_event',
518
-                    'ee_edit_events',
519
-                    'ee_edit_published_events',
520
-                    'ee_edit_others_events',
521
-                    'ee_edit_private_events',
522
-                    'ee_delete_published_events',
523
-                    'ee_delete_private_events',
524
-                    'ee_delete_event',
525
-                    'ee_delete_events',
526
-                    'ee_delete_others_events',
527
-                    //event categories
528
-                    'ee_manage_event_categories',
529
-                    'ee_edit_event_category',
530
-                    'ee_delete_event_category',
531
-                    'ee_assign_event_category',
532
-                    //venues
533
-                    'ee_publish_venues',
534
-                    'ee_read_venue',
535
-                    'ee_read_venues',
536
-                    'ee_read_others_venues',
537
-                    'ee_read_private_venues',
538
-                    'ee_edit_venue',
539
-                    'ee_edit_venues',
540
-                    'ee_edit_others_venues',
541
-                    'ee_edit_published_venues',
542
-                    'ee_edit_private_venues',
543
-                    'ee_delete_venue',
544
-                    'ee_delete_venues',
545
-                    'ee_delete_others_venues',
546
-                    'ee_delete_private_venues',
547
-                    'ee_delete_published_venues',
548
-                    //venue categories
549
-                    'ee_manage_venue_categories',
550
-                    'ee_edit_venue_category',
551
-                    'ee_delete_venue_category',
552
-                    'ee_assign_venue_category',
553
-                    //contacts
554
-                    'ee_read_contacts',
555
-                    'ee_edit_contacts',
556
-                    'ee_delete_contacts',
557
-                    //registrations
558
-                    'ee_read_registrations',
559
-                    'ee_read_others_registrations',
560
-                    'ee_edit_registration',
561
-                    'ee_edit_registrations',
562
-                    'ee_edit_others_registrations',
563
-                    'ee_delete_registration',
564
-                    'ee_delete_registrations',
565
-                    //checkins
566
-                    'ee_read_others_checkins',
567
-                    'ee_read_checkins',
568
-                    'ee_edit_checkins',
569
-                    'ee_edit_others_checkins',
570
-                    'ee_delete_checkins',
571
-                    'ee_delete_others_checkins',
572
-                    //transactions && payments
573
-                    'ee_read_transaction',
574
-                    'ee_read_transactions',
575
-                    'ee_edit_payments',
576
-                    'ee_delete_payments',
577
-                    //messages
578
-                    'ee_read_messages',
579
-                    'ee_read_others_messages',
580
-                    'ee_read_global_messages',
581
-                    'ee_edit_global_messages',
582
-                    'ee_edit_messages',
583
-                    'ee_edit_others_messages',
584
-                    'ee_delete_messages',
585
-                    'ee_delete_others_messages',
586
-                    'ee_delete_global_messages',
587
-                    'ee_send_message',
588
-                    //tickets
589
-                    'ee_read_default_tickets',
590
-                    'ee_read_others_default_tickets',
591
-                    'ee_edit_default_tickets',
592
-                    'ee_edit_others_default_tickets',
593
-                    'ee_delete_default_tickets',
594
-                    'ee_delete_others_default_tickets',
595
-                    //prices
596
-                    'ee_edit_default_price',
597
-                    'ee_edit_default_prices',
598
-                    'ee_delete_default_price',
599
-                    'ee_delete_default_prices',
600
-                    'ee_edit_default_price_type',
601
-                    'ee_edit_default_price_types',
602
-                    'ee_delete_default_price_type',
603
-                    'ee_delete_default_price_types',
604
-                    'ee_read_default_prices',
605
-                    'ee_read_default_price_types',
606
-                    //registration form
607
-                    'ee_edit_questions',
608
-                    'ee_edit_system_questions',
609
-                    'ee_read_questions',
610
-                    'ee_delete_questions',
611
-                    'ee_edit_question_groups',
612
-                    'ee_read_question_groups',
613
-                    'ee_edit_system_question_groups',
614
-                    'ee_delete_question_groups',
615
-                    //event_type taxonomy
616
-                    'ee_assign_event_type',
617
-                    'ee_manage_event_types',
618
-                    'ee_edit_event_type',
619
-                    'ee_delete_event_type',
620
-                )
621
-            )
622
-        );
623
-    }
624
-
625
-
626
-
627
-    /**
628
-     * @return bool
629
-     * @throws EE_Error
630
-     */
631
-    private function setupCapabilitiesMap()
632
-    {
633
-        // if the initialization process hasn't even started, then we need to call init_caps()
634
-        if($this->initialized === null) {
635
-            return $this->init_caps();
636
-        }
637
-        // unless resetting, get caps from db if we haven't already
638
-        $this->capabilities_map = $this->reset || ! empty($this->capabilities_map)
639
-            ? $this->capabilities_map
640
-            : get_option(self::option_name, array());
641
-        return true;
642
-    }
643
-
644
-
645
-
646
-    /**
647
-     * @param bool $update
648
-     * @return bool
649
-     */
650
-    private function updateCapabilitiesMap($update = true)
651
-    {
652
-        return $update ? update_option(self::option_name, $this->capabilities_map) : false;
653
-    }
654
-
655
-
656
-
657
-    /**
658
-     * Adds capabilities to roles.
659
-     *
660
-     * @since 4.9.42
661
-     * @param array $capabilities_to_add array of capabilities to add, indexed by roles.
662
-     *                                   Note that this should ONLY be called on activation hook
663
-     *                                   otherwise the caps will be added on every request.
664
-     * @return bool
665
-     * @throws \EE_Error
666
-     */
667
-    public function addCaps(array $capabilities_to_add)
668
-    {
669
-        // don't do anything if the capabilities map can not be initialized
670
-        if (! $this->setupCapabilitiesMap()) {
671
-            return false;
672
-        }
673
-        // and filter the array so others can get in on the fun during resets
674
-        $capabilities_to_add = apply_filters(
675
-            'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
676
-            $capabilities_to_add,
677
-            $this->reset,
678
-            $this->capabilities_map
679
-        );
680
-        $update_capabilities_map = false;
681
-        // if not reset, see what caps are new for each role. if they're new, add them.
682
-        foreach ($capabilities_to_add as $role => $caps_for_role) {
683
-            if (is_array($caps_for_role)) {
684
-                foreach ($caps_for_role as $cap) {
685
-                    if (
686
-                        ! $this->capHasBeenAddedToRole($role, $cap)
687
-                        && $this->add_cap_to_role($role, $cap, true, false)
688
-                    ) {
689
-                        $update_capabilities_map = true;
690
-                    }
691
-                }
692
-            }
693
-        }
694
-        // now let's just save the cap that has been set but only if there's been a change.
695
-        $updated = $this->updateCapabilitiesMap($update_capabilities_map);
696
-        $this->flushWpUser($updated);
697
-        do_action('AHEE__EE_Capabilities__addCaps__complete', $this->capabilities_map, $updated);
698
-        return $updated;
699
-    }
700
-
701
-
702
-
703
-    /**
704
-     * Loops through the capabilities map and removes the role caps specified by the incoming array
705
-     *
706
-     * @param array $caps_map map of capabilities to be removed (indexed by roles)
707
-     * @return bool
708
-     * @throws \EE_Error
709
-     */
710
-    public function removeCaps($caps_map)
711
-    {
712
-        // don't do anything if the capabilities map can not be initialized
713
-        if (! $this->setupCapabilitiesMap()) {
714
-            return false;
715
-        }
716
-        $update_capabilities_map = false;
717
-        foreach ($caps_map as $role => $caps_for_role) {
718
-            if (is_array($caps_for_role)) {
719
-                foreach ($caps_for_role as $cap) {
720
-                    if ($this->capHasBeenAddedToRole($role, $cap)
721
-                        && $this->remove_cap_from_role($role, $cap, false)
722
-                    ) {
723
-                        $update_capabilities_map = true;
724
-                    }
725
-                }
726
-            }
727
-        }
728
-        // maybe resave the caps
729
-        $updated = $this->updateCapabilitiesMap($update_capabilities_map);
730
-        $this->flushWpUser($updated);
731
-        return $updated;
732
-    }
733
-
734
-
735
-    /**
736
-     * This ensures that the WP User object cached on the $current_user global in WP has the latest capabilities from
737
-     * the roles on that user.
738
-     *
739
-     * @param bool $flush  Default is to flush the WP_User object.  If false, then this method effectively does nothing.
740
-     */
741
-    private function flushWpUser($flush = true)
742
-    {
743
-        if ($flush) {
744
-            $user = wp_get_current_user();
745
-            if ($user instanceof WP_User) {
746
-                $user->get_role_caps();
747
-            }
748
-        }
749
-    }
750
-
751
-
752
-
753
-    /**
754
-     * This method sets a capability on a role.  Note this should only be done on activation, or if you have something
755
-     * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note.
756
-     * this is a wrapper for $wp_role->add_cap()
757
-     *
758
-     * @see   wp-includes/capabilities.php
759
-     * @since 4.5.0
760
-     * @param string|WP_Role $role  A WordPress role the capability is being added to
761
-     * @param string         $cap   The capability being added to the role
762
-     * @param bool           $grant Whether to grant access to this cap on this role.
763
-     * @param bool           $update_capabilities_map
764
-     * @return bool
765
-     * @throws \EE_Error
766
-     */
767
-    public function add_cap_to_role($role, $cap, $grant = true, $update_capabilities_map = true)
768
-    {
769
-        // capture incoming value for $role because we may need it to create a new WP_Role
770
-        $orig_role = $role;
771
-        $role = $role instanceof WP_Role ? $role : get_role($role);
772
-        //if the role isn't available then we create it.
773
-        if (! $role instanceof WP_Role) {
774
-            // if a plugin wants to create a specific role name then they should create the role before
775
-            // EE_Capabilities does.  Otherwise this function will create the role name from the slug:
776
-            // - removes any `ee_` namespacing from the start of the slug.
777
-            // - replaces `_` with ` ` (empty space).
778
-            // - sentence case on the resulting string.
779
-            $role_label = ucwords(str_replace(array('ee_', '_'), array('', ' '), $orig_role));
780
-            $role = add_role($orig_role, $role_label);
781
-        }
782
-        if ($role instanceof WP_Role) {
783
-            // don't do anything if the capabilities map can not be initialized
784
-            if (! $this->setupCapabilitiesMap()) {
785
-                return false;
786
-            }
787
-            if (! $this->capHasBeenAddedToRole($role->name, $cap)) {
788
-                $role->add_cap($cap, $grant);
789
-                $this->capabilities_map[ $role->name ][] = $cap;
790
-                $this->updateCapabilitiesMap($update_capabilities_map);
791
-                return true;
792
-            }
793
-        }
794
-        return false;
795
-    }
796
-
797
-
798
-
799
-    /**
800
-     * Functions similarly to add_cap_to_role except removes cap from given role.
801
-     * Wrapper for $wp_role->remove_cap()
802
-     *
803
-     * @see   wp-includes/capabilities.php
804
-     * @since 4.5.0
805
-     * @param string|WP_Role $role A WordPress role the capability is being removed from.
806
-     * @param string         $cap  The capability being removed
807
-     * @param bool           $update_capabilities_map
808
-     * @return bool
809
-     * @throws \EE_Error
810
-     */
811
-    public function remove_cap_from_role($role, $cap, $update_capabilities_map = true)
812
-    {
813
-        // don't do anything if the capabilities map can not be initialized
814
-        if (! $this->setupCapabilitiesMap()) {
815
-            return false;
816
-        }
817
-
818
-        $role = $role instanceof WP_Role ? $role : get_role($role);
819
-        if ($role instanceof WP_Role && $index = $this->capHasBeenAddedToRole($role->name, $cap, true)) {
820
-            $role->remove_cap($cap);
821
-            unset($this->capabilities_map[ $role->name ][ $index ]);
822
-            $this->updateCapabilitiesMap($update_capabilities_map);
823
-            return true;
824
-        }
825
-        return false;
826
-    }
827
-
828
-
829
-
830
-    /**
831
-     * @param string $role_name
832
-     * @param string $cap
833
-     * @param bool   $get_index
834
-     * @return bool|mixed
835
-     */
836
-    private function capHasBeenAddedToRole($role_name='', $cap='', $get_index = false)
837
-    {
838
-        if (
839
-            isset($this->capabilities_map[$role_name])
840
-            && ($index = array_search($cap, $this->capabilities_map[$role_name], true)) !== false
841
-        ) {
842
-            return $get_index ? $index : true;
843
-        }
844
-        return false;
845
-    }
846
-
847
-
848
-
849
-    /**
850
-     * Wrapper for the native WP current_user_can() method.
851
-     * This is provided as a handy method for a couple things:
852
-     * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to
853
-     * write those filters wherever current_user_can is called).
854
-     * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters )
855
-     *
856
-     * @since 4.5.0
857
-     *
858
-     * @param string $cap     The cap being checked.
859
-     * @param string $context The context where the current_user_can is being called from.
860
-     * @param int    $id      Optional. Id for item where current_user_can is being called from (used in map_meta_cap()
861
-     *                        filters.
862
-     *
863
-     * @return bool  Whether user can or not.
864
-     */
865
-    public function current_user_can($cap, $context, $id = 0)
866
-    {
867
-        //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
868
-        $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id);
869
-        $filtered_cap = apply_filters(
870
-            'FHEE__EE_Capabilities__current_user_can__cap',
871
-            $filtered_cap,
872
-            $context,
873
-            $cap,
874
-            $id
875
-        );
876
-        return ! empty($id)
877
-            ? current_user_can($filtered_cap, $id)
878
-            : current_user_can($filtered_cap);
879
-    }
880
-
881
-
882
-
883
-    /**
884
-     * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class.
885
-     *
886
-     * @param int|WP_User $user    Either the user_id or a WP_User object
887
-     * @param string      $cap     The capability string being checked
888
-     * @param string      $context The context where the user_can is being called from (used in filters).
889
-     * @param int         $id      Optional. Id for item where user_can is being called from ( used in map_meta_cap()
890
-     *                             filters)
891
-     *
892
-     * @return bool Whether user can or not.
893
-     */
894
-    public function user_can($user, $cap, $context, $id = 0)
895
-    {
896
-        //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
897
-        $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id);
898
-        $filtered_cap = apply_filters(
899
-            'FHEE__EE_Capabilities__user_can__cap',
900
-            $filtered_cap,
901
-            $context,
902
-            $cap,
903
-            $user,
904
-            $id
905
-        );
906
-        return ! empty($id)
907
-            ? user_can($user, $filtered_cap, $id)
908
-            : user_can($user, $filtered_cap);
909
-    }
910
-
911
-
912
-
913
-    /**
914
-     * Wrapper for the native WP current_user_can_for_blog() method.
915
-     * This is provided as a handy method for a couple things:
916
-     * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to
917
-     * write those filters wherever current_user_can is called).
918
-     * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters )
919
-     *
920
-     * @since 4.5.0
921
-     *
922
-     * @param int    $blog_id The blog id that is being checked for.
923
-     * @param string $cap     The cap being checked.
924
-     * @param string $context The context where the current_user_can is being called from.
925
-     * @param int    $id      Optional. Id for item where current_user_can is being called from (used in map_meta_cap()
926
-     *                        filters.
927
-     *
928
-     * @return bool  Whether user can or not.
929
-     */
930
-    public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0)
931
-    {
932
-        $user_can = ! empty($id)
933
-            ? current_user_can_for_blog($blog_id, $cap, $id)
934
-            : current_user_can($blog_id, $cap);
935
-        //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
936
-        $user_can = apply_filters(
937
-            'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context,
938
-            $user_can,
939
-            $blog_id,
940
-            $cap,
941
-            $id
942
-        );
943
-        $user_can = apply_filters(
944
-            'FHEE__EE_Capabilities__current_user_can_for_blog__user_can',
945
-            $user_can,
946
-            $context,
947
-            $blog_id,
948
-            $cap,
949
-            $id
950
-        );
951
-        return $user_can;
952
-    }
953
-
954
-
955
-
956
-    /**
957
-     * This helper method just returns an array of registered EE capabilities.
958
-     *
959
-     * @since 4.5.0
960
-     * @param string $role If empty then the entire role/capability map is returned.
961
-     *                     Otherwise just the capabilities for the given role are returned.
962
-     * @return array
963
-     * @throws EE_Error
964
-     */
965
-    public function get_ee_capabilities($role = 'administrator')
966
-    {
967
-        if (! $this->initialized) {
968
-            $this->init_caps();
969
-        }
970
-        if (empty($role)) {
971
-            return $this->capabilities_map;
972
-        }
973
-        return isset($this->capabilities_map[ $role ])
974
-            ? $this->capabilities_map[ $role ]
975
-            : array();
976
-    }
977
-
978
-
979
-
980
-    /**
981
-     * @deprecated 4.9.42
982
-     * @param bool  $reset      If you need to reset Event Espresso's capabilities,
983
-     *                          then please use the init_caps() method with the "$reset" parameter set to "true"
984
-     * @param array $caps_map   Optional.
985
-     *                          Can be used to send a custom map of roles and capabilities for setting them up.
986
-     *                          Note that this should ONLY be called on activation hook or some other one-time
987
-     *                          task otherwise the caps will be added on every request.
988
-     * @return void
989
-     * @throws EE_Error
990
-     */
991
-    public function init_role_caps($reset = false, $caps_map = array())
992
-    {
993
-        // If this method is called directly and reset is set as 'true',
994
-        // then display a doing it wrong notice, because we want resets to go through init_caps()
995
-        // to guarantee that everything is set up correctly.
996
-        // This prevents the capabilities map getting reset incorrectly by direct calls to this method.
997
-        if ($reset) {
998
-            EE_Error::doing_it_wrong(
999
-                __METHOD__,
1000
-                sprintf(
1001
-                    esc_html__(
1002
-                        'The "%1$s" parameter for the "%2$s" method is deprecated. If you need to reset Event Espresso\'s capabilities, then please use the "%3$s" method with the "%1$s" parameter set to "%4$s".',
1003
-                        'event_espresso'
1004
-                    ),
1005
-                    '$reset',
1006
-                    __METHOD__ . '()',
1007
-                    'EE_Capabilities::init_caps()',
1008
-                    'true'
1009
-                ),
1010
-                '4.9.42',
1011
-                '5.0.0'
1012
-            );
1013
-        }
1014
-        $this->addCaps($caps_map);
1015
-    }
21
+	/**
22
+	 * the name of the wp option used to store caps previously initialized
23
+	 */
24
+	const option_name = 'ee_caps_initialized';
25
+
26
+	/**
27
+	 * instance of EE_Capabilities object
28
+	 *
29
+	 * @var EE_Capabilities
30
+	 */
31
+	private static $_instance;
32
+
33
+
34
+	/**
35
+	 * This is a map of caps that correspond to a default WP_Role.
36
+	 * Array is indexed by Role and values are ee capabilities.
37
+	 *
38
+	 * @since 4.5.0
39
+	 *
40
+	 * @var array
41
+	 */
42
+	private $capabilities_map = array();
43
+
44
+	/**
45
+	 * This used to hold an array of EE_Meta_Capability_Map objects
46
+	 * that define the granular capabilities mapped to for a user depending on context.
47
+	 *
48
+	 * @var EE_Meta_Capability_Map[]
49
+	 */
50
+	private $_meta_caps = array();
51
+
52
+	/**
53
+	 * The internal $capabilities_map needs to be initialized before it can be used.
54
+	 * This flag tracks whether that has happened or not.
55
+	 * But for this to work, we need three states to indicate:
56
+	 *      initialization has not occurred at all
57
+	 *      initialization has started but is not complete
58
+	 *      initialization is complete
59
+	 * The reason this is needed is because the addCaps() method
60
+	 * normally requires the $capabilities_map to be initialized,
61
+	 * but is also used during the initialization process.
62
+	 * So:
63
+	 *      If initialized === null, init_caps() will be called before any other methods will run.
64
+	 *      If initialized === false, then init_caps() is in the process of running it's logic.
65
+	 *      If initialized === true, then init_caps() has completed the initialization process.
66
+	 *
67
+	 * @var boolean|null $initialized
68
+	 */
69
+	private $initialized;
70
+
71
+	/**
72
+	 * @var boolean $reset
73
+	 */
74
+	private $reset = false;
75
+
76
+
77
+
78
+	/**
79
+	 * singleton method used to instantiate class object
80
+	 *
81
+	 * @since 4.5.0
82
+	 *
83
+	 * @return EE_Capabilities
84
+	 */
85
+	public static function instance()
86
+	{
87
+		//check if instantiated, and if not do so.
88
+		if (! self::$_instance instanceof EE_Capabilities) {
89
+			self::$_instance = new self();
90
+		}
91
+		return self::$_instance;
92
+	}
93
+
94
+
95
+
96
+	/**
97
+	 * private constructor
98
+	 *
99
+	 * @since 4.5.0
100
+	 */
101
+	private function __construct()
102
+	{
103
+	}
104
+
105
+
106
+
107
+	/**
108
+	 * This delays the initialization of the capabilities class until EE_System core is loaded and ready.
109
+	 *
110
+	 * @param bool $reset allows for resetting the default capabilities saved on roles.  Note that this doesn't
111
+	 *                    actually REMOVE any capabilities from existing roles, it just resaves defaults roles and
112
+	 *                    ensures that they are up to date.
113
+	 *
114
+	 * @since 4.5.0
115
+	 * @return bool
116
+	 * @throws EE_Error
117
+	 */
118
+	public function init_caps($reset = false)
119
+	{
120
+		if(! EE_Maintenance_Mode::instance()->models_can_query()){
121
+			return false;
122
+		}
123
+		$this->reset = filter_var($reset, FILTER_VALIDATE_BOOLEAN);
124
+		// if reset, then completely delete the cache option and clear the $capabilities_map property.
125
+		if ($this->reset) {
126
+			$this->initialized = null;
127
+			$this->capabilities_map = array();
128
+			delete_option(self::option_name);
129
+		}
130
+		if ($this->initialized === null) {
131
+			$this->initialized = false;
132
+			do_action(
133
+				'AHEE__EE_Capabilities__init_caps__before_initialization',
134
+				$this->reset
135
+			);
136
+			$this->addCaps($this->_init_caps_map());
137
+			$this->_set_meta_caps();
138
+			do_action(
139
+				'AHEE__EE_Capabilities__init_caps__after_initialization',
140
+				$this->capabilities_map
141
+			);
142
+			$this->initialized = true;
143
+		}
144
+		// reset $this->reset so that it's not stuck on true if init_caps() gets called again
145
+		$this->reset = false;
146
+		return true;
147
+	}
148
+
149
+
150
+
151
+
152
+	/**
153
+	 * This sets the meta caps property.
154
+	 *
155
+	 * @since 4.5.0
156
+	 * @return void
157
+	 * @throws EE_Error
158
+	 */
159
+	private function _set_meta_caps()
160
+	{
161
+		// get default meta caps and filter the returned array
162
+		$this->_meta_caps = apply_filters(
163
+			'FHEE__EE_Capabilities___set_meta_caps__meta_caps',
164
+			$this->_get_default_meta_caps_array()
165
+		);
166
+		//add filter for map_meta_caps but only if models can query.
167
+		if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) {
168
+			add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4);
169
+		}
170
+	}
171
+
172
+
173
+
174
+	/**
175
+	 * This builds and returns the default meta_caps array only once.
176
+	 *
177
+	 * @since  4.8.28.rc.012
178
+	 * @return array
179
+	 * @throws EE_Error
180
+	 */
181
+	private function _get_default_meta_caps_array()
182
+	{
183
+		static $default_meta_caps = array();
184
+		// make sure we're only ever initializing the default _meta_caps array once if it's empty.
185
+		if (empty($default_meta_caps)) {
186
+			$default_meta_caps = array(
187
+				//edits
188
+				new EE_Meta_Capability_Map_Edit(
189
+					'ee_edit_event',
190
+					array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')
191
+				),
192
+				new EE_Meta_Capability_Map_Edit(
193
+					'ee_edit_venue',
194
+					array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')
195
+				),
196
+				new EE_Meta_Capability_Map_Edit(
197
+					'ee_edit_registration',
198
+					array('Registration', '', 'ee_edit_others_registrations', '')
199
+				),
200
+				new EE_Meta_Capability_Map_Edit(
201
+					'ee_edit_checkin',
202
+					array('Registration', '', 'ee_edit_others_checkins', '')
203
+				),
204
+				new EE_Meta_Capability_Map_Messages_Cap(
205
+					'ee_edit_message',
206
+					array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')
207
+				),
208
+				new EE_Meta_Capability_Map_Edit(
209
+					'ee_edit_default_ticket',
210
+					array('Ticket', '', 'ee_edit_others_default_tickets', '')
211
+				),
212
+				new EE_Meta_Capability_Map_Registration_Form_Cap(
213
+					'ee_edit_question',
214
+					array('Question', '', '', 'ee_edit_system_questions')
215
+				),
216
+				new EE_Meta_Capability_Map_Registration_Form_Cap(
217
+					'ee_edit_question_group',
218
+					array('Question_Group', '', '', 'ee_edit_system_question_groups')
219
+				),
220
+				new EE_Meta_Capability_Map_Edit(
221
+					'ee_edit_payment_method',
222
+					array('Payment_Method', '', 'ee_edit_others_payment_methods', '')
223
+				),
224
+				//reads
225
+				new EE_Meta_Capability_Map_Read(
226
+					'ee_read_event',
227
+					array('Event', '', 'ee_read_others_events', 'ee_read_private_events')
228
+				),
229
+				new EE_Meta_Capability_Map_Read(
230
+					'ee_read_venue',
231
+					array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')
232
+				),
233
+				new EE_Meta_Capability_Map_Read(
234
+					'ee_read_registration',
235
+					array('Registration', '', 'ee_read_others_registrations', '')
236
+				),
237
+				new EE_Meta_Capability_Map_Read(
238
+					'ee_read_checkin',
239
+					array('Registration', '', 'ee_read_others_checkins', '')
240
+				),
241
+				new EE_Meta_Capability_Map_Messages_Cap(
242
+					'ee_read_message',
243
+					array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')
244
+				),
245
+				new EE_Meta_Capability_Map_Read(
246
+					'ee_read_default_ticket',
247
+					array('Ticket', '', 'ee_read_others_default_tickets', '')
248
+				),
249
+				new EE_Meta_Capability_Map_Read(
250
+					'ee_read_payment_method',
251
+					array('Payment_Method', '', 'ee_read_others_payment_methods', '')
252
+				),
253
+				//deletes
254
+				new EE_Meta_Capability_Map_Delete(
255
+					'ee_delete_event',
256
+					array(
257
+						'Event',
258
+						'ee_delete_published_events',
259
+						'ee_delete_others_events',
260
+						'ee_delete_private_events',
261
+					)
262
+				),
263
+				new EE_Meta_Capability_Map_Delete(
264
+					'ee_delete_venue',
265
+					array(
266
+						'Venue',
267
+						'ee_delete_published_venues',
268
+						'ee_delete_others_venues',
269
+						'ee_delete_private_venues',
270
+					)
271
+				),
272
+				new EE_Meta_Capability_Map_Delete(
273
+					'ee_delete_registration',
274
+					array('Registration', '', 'ee_delete_others_registrations', '')
275
+				),
276
+				new EE_Meta_Capability_Map_Delete(
277
+					'ee_delete_checkin',
278
+					array('Registration', '', 'ee_delete_others_checkins', '')
279
+				),
280
+				new EE_Meta_Capability_Map_Messages_Cap(
281
+					'ee_delete_message',
282
+					array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')
283
+				),
284
+				new EE_Meta_Capability_Map_Delete(
285
+					'ee_delete_default_ticket',
286
+					array('Ticket', '', 'ee_delete_others_default_tickets', '')
287
+				),
288
+				new EE_Meta_Capability_Map_Registration_Form_Cap(
289
+					'ee_delete_question',
290
+					array('Question', '', '', 'delete_system_questions')
291
+				),
292
+				new EE_Meta_Capability_Map_Registration_Form_Cap(
293
+					'ee_delete_question_group',
294
+					array('Question_Group', '', '', 'delete_system_question_groups')
295
+				),
296
+				new EE_Meta_Capability_Map_Delete(
297
+					'ee_delete_payment_method',
298
+					array('Payment_Method', '', 'ee_delete_others_payment_methods', '')
299
+				),
300
+			);
301
+		}
302
+		return $default_meta_caps;
303
+	}
304
+
305
+
306
+
307
+	/**
308
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
309
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
310
+	 *
311
+	 * The actual logic is carried out by implementer classes in their definition of _map_meta_caps.
312
+	 *
313
+	 * @since 4.5.0
314
+	 * @see   wp-includes/capabilities.php
315
+	 *
316
+	 * @param array  $caps    actual users capabilities
317
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
318
+	 * @param int    $user_id The user id
319
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
320
+	 * @return array actual users capabilities
321
+	 * @throws EE_Error
322
+	 */
323
+	public function map_meta_caps($caps, $cap, $user_id, $args)
324
+	{
325
+		if (did_action('AHEE__EE_System__load_espresso_addons__complete')) {
326
+			//loop through our _meta_caps array
327
+			foreach ($this->_meta_caps as $meta_map) {
328
+				if (! $meta_map instanceof EE_Meta_Capability_Map) {
329
+					continue;
330
+				}
331
+				// don't load models if there is no object ID in the args
332
+				if (! empty($args[0])) {
333
+					$meta_map->ensure_is_model();
334
+				}
335
+				$caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args);
336
+			}
337
+		}
338
+		return $caps;
339
+	}
340
+
341
+
342
+
343
+	/**
344
+	 * This sets up and returns the initial capabilities map for Event Espresso
345
+	 * Note this array is filtered.
346
+	 * It is assumed that all available EE capabilities are assigned to the administrator role.
347
+	 *
348
+	 * @since 4.5.0
349
+	 *
350
+	 * @return array
351
+	 */
352
+	private function _init_caps_map()
353
+	{
354
+		return apply_filters(
355
+			'FHEE__EE_Capabilities__init_caps_map__caps',
356
+			array(
357
+				'administrator'           => array(
358
+					//basic access
359
+					'ee_read_ee',
360
+					//gateways
361
+					/**
362
+					 * note that with payment method capabilities, although we've implemented
363
+					 * capability mapping which will be used for accessing payment methods owned by
364
+					 * other users.  This is not fully implemented yet in the payment method ui.
365
+					 * Currently only the "plural" caps are in active use.
366
+					 * (Specific payment method caps are in use as well).
367
+					 **/
368
+					'ee_manage_gateways',
369
+					'ee_read_payment_methods',
370
+					'ee_read_others_payment_methods',
371
+					'ee_edit_payment_methods',
372
+					'ee_edit_others_payment_methods',
373
+					'ee_delete_payment_methods',
374
+					//events
375
+					'ee_publish_events',
376
+					'ee_read_private_events',
377
+					'ee_read_others_events',
378
+					'ee_read_events',
379
+					'ee_edit_events',
380
+					'ee_edit_published_events',
381
+					'ee_edit_others_events',
382
+					'ee_edit_private_events',
383
+					'ee_delete_published_events',
384
+					'ee_delete_private_events',
385
+					'ee_delete_events',
386
+					'ee_delete_others_events',
387
+					//event categories
388
+					'ee_manage_event_categories',
389
+					'ee_edit_event_category',
390
+					'ee_delete_event_category',
391
+					'ee_assign_event_category',
392
+					//venues
393
+					'ee_publish_venues',
394
+					'ee_read_venues',
395
+					'ee_read_others_venues',
396
+					'ee_read_private_venues',
397
+					'ee_edit_venues',
398
+					'ee_edit_others_venues',
399
+					'ee_edit_published_venues',
400
+					'ee_edit_private_venues',
401
+					'ee_delete_venues',
402
+					'ee_delete_others_venues',
403
+					'ee_delete_private_venues',
404
+					'ee_delete_published_venues',
405
+					//venue categories
406
+					'ee_manage_venue_categories',
407
+					'ee_edit_venue_category',
408
+					'ee_delete_venue_category',
409
+					'ee_assign_venue_category',
410
+					//contacts
411
+					'ee_read_contacts',
412
+					'ee_edit_contacts',
413
+					'ee_delete_contacts',
414
+					//registrations
415
+					'ee_read_registrations',
416
+					'ee_read_others_registrations',
417
+					'ee_edit_registrations',
418
+					'ee_edit_others_registrations',
419
+					'ee_delete_registrations',
420
+					//checkins
421
+					'ee_read_others_checkins',
422
+					'ee_read_checkins',
423
+					'ee_edit_checkins',
424
+					'ee_edit_others_checkins',
425
+					'ee_delete_checkins',
426
+					'ee_delete_others_checkins',
427
+					//transactions && payments
428
+					'ee_read_transaction',
429
+					'ee_read_transactions',
430
+					'ee_edit_payments',
431
+					'ee_delete_payments',
432
+					//messages
433
+					'ee_read_messages',
434
+					'ee_read_others_messages',
435
+					'ee_read_global_messages',
436
+					'ee_edit_global_messages',
437
+					'ee_edit_messages',
438
+					'ee_edit_others_messages',
439
+					'ee_delete_messages',
440
+					'ee_delete_others_messages',
441
+					'ee_delete_global_messages',
442
+					'ee_send_message',
443
+					//tickets
444
+					'ee_read_default_tickets',
445
+					'ee_read_others_default_tickets',
446
+					'ee_edit_default_tickets',
447
+					'ee_edit_others_default_tickets',
448
+					'ee_delete_default_tickets',
449
+					'ee_delete_others_default_tickets',
450
+					//prices
451
+					'ee_edit_default_price',
452
+					'ee_edit_default_prices',
453
+					'ee_delete_default_price',
454
+					'ee_delete_default_prices',
455
+					'ee_edit_default_price_type',
456
+					'ee_edit_default_price_types',
457
+					'ee_delete_default_price_type',
458
+					'ee_delete_default_price_types',
459
+					'ee_read_default_prices',
460
+					'ee_read_default_price_types',
461
+					//registration form
462
+					'ee_edit_questions',
463
+					'ee_edit_system_questions',
464
+					'ee_read_questions',
465
+					'ee_delete_questions',
466
+					'ee_edit_question_groups',
467
+					'ee_read_question_groups',
468
+					'ee_edit_system_question_groups',
469
+					'ee_delete_question_groups',
470
+					//event_type taxonomy
471
+					'ee_assign_event_type',
472
+					'ee_manage_event_types',
473
+					'ee_edit_event_type',
474
+					'ee_delete_event_type',
475
+				),
476
+				'ee_events_administrator' => array(
477
+					//core wp caps
478
+					'read',
479
+					'read_private_pages',
480
+					'read_private_posts',
481
+					'edit_users',
482
+					'edit_posts',
483
+					'edit_pages',
484
+					'edit_published_posts',
485
+					'edit_published_pages',
486
+					'edit_private_pages',
487
+					'edit_private_posts',
488
+					'edit_others_posts',
489
+					'edit_others_pages',
490
+					'publish_posts',
491
+					'publish_pages',
492
+					'delete_posts',
493
+					'delete_pages',
494
+					'delete_private_pages',
495
+					'delete_private_posts',
496
+					'delete_published_pages',
497
+					'delete_published_posts',
498
+					'delete_others_posts',
499
+					'delete_others_pages',
500
+					'manage_categories',
501
+					'manage_links',
502
+					'moderate_comments',
503
+					'unfiltered_html',
504
+					'upload_files',
505
+					'export',
506
+					'import',
507
+					'list_users',
508
+					'level_1', //required if user with this role shows up in author dropdowns
509
+					//basic ee access
510
+					'ee_read_ee',
511
+					//events
512
+					'ee_publish_events',
513
+					'ee_read_private_events',
514
+					'ee_read_others_events',
515
+					'ee_read_event',
516
+					'ee_read_events',
517
+					'ee_edit_event',
518
+					'ee_edit_events',
519
+					'ee_edit_published_events',
520
+					'ee_edit_others_events',
521
+					'ee_edit_private_events',
522
+					'ee_delete_published_events',
523
+					'ee_delete_private_events',
524
+					'ee_delete_event',
525
+					'ee_delete_events',
526
+					'ee_delete_others_events',
527
+					//event categories
528
+					'ee_manage_event_categories',
529
+					'ee_edit_event_category',
530
+					'ee_delete_event_category',
531
+					'ee_assign_event_category',
532
+					//venues
533
+					'ee_publish_venues',
534
+					'ee_read_venue',
535
+					'ee_read_venues',
536
+					'ee_read_others_venues',
537
+					'ee_read_private_venues',
538
+					'ee_edit_venue',
539
+					'ee_edit_venues',
540
+					'ee_edit_others_venues',
541
+					'ee_edit_published_venues',
542
+					'ee_edit_private_venues',
543
+					'ee_delete_venue',
544
+					'ee_delete_venues',
545
+					'ee_delete_others_venues',
546
+					'ee_delete_private_venues',
547
+					'ee_delete_published_venues',
548
+					//venue categories
549
+					'ee_manage_venue_categories',
550
+					'ee_edit_venue_category',
551
+					'ee_delete_venue_category',
552
+					'ee_assign_venue_category',
553
+					//contacts
554
+					'ee_read_contacts',
555
+					'ee_edit_contacts',
556
+					'ee_delete_contacts',
557
+					//registrations
558
+					'ee_read_registrations',
559
+					'ee_read_others_registrations',
560
+					'ee_edit_registration',
561
+					'ee_edit_registrations',
562
+					'ee_edit_others_registrations',
563
+					'ee_delete_registration',
564
+					'ee_delete_registrations',
565
+					//checkins
566
+					'ee_read_others_checkins',
567
+					'ee_read_checkins',
568
+					'ee_edit_checkins',
569
+					'ee_edit_others_checkins',
570
+					'ee_delete_checkins',
571
+					'ee_delete_others_checkins',
572
+					//transactions && payments
573
+					'ee_read_transaction',
574
+					'ee_read_transactions',
575
+					'ee_edit_payments',
576
+					'ee_delete_payments',
577
+					//messages
578
+					'ee_read_messages',
579
+					'ee_read_others_messages',
580
+					'ee_read_global_messages',
581
+					'ee_edit_global_messages',
582
+					'ee_edit_messages',
583
+					'ee_edit_others_messages',
584
+					'ee_delete_messages',
585
+					'ee_delete_others_messages',
586
+					'ee_delete_global_messages',
587
+					'ee_send_message',
588
+					//tickets
589
+					'ee_read_default_tickets',
590
+					'ee_read_others_default_tickets',
591
+					'ee_edit_default_tickets',
592
+					'ee_edit_others_default_tickets',
593
+					'ee_delete_default_tickets',
594
+					'ee_delete_others_default_tickets',
595
+					//prices
596
+					'ee_edit_default_price',
597
+					'ee_edit_default_prices',
598
+					'ee_delete_default_price',
599
+					'ee_delete_default_prices',
600
+					'ee_edit_default_price_type',
601
+					'ee_edit_default_price_types',
602
+					'ee_delete_default_price_type',
603
+					'ee_delete_default_price_types',
604
+					'ee_read_default_prices',
605
+					'ee_read_default_price_types',
606
+					//registration form
607
+					'ee_edit_questions',
608
+					'ee_edit_system_questions',
609
+					'ee_read_questions',
610
+					'ee_delete_questions',
611
+					'ee_edit_question_groups',
612
+					'ee_read_question_groups',
613
+					'ee_edit_system_question_groups',
614
+					'ee_delete_question_groups',
615
+					//event_type taxonomy
616
+					'ee_assign_event_type',
617
+					'ee_manage_event_types',
618
+					'ee_edit_event_type',
619
+					'ee_delete_event_type',
620
+				)
621
+			)
622
+		);
623
+	}
624
+
625
+
626
+
627
+	/**
628
+	 * @return bool
629
+	 * @throws EE_Error
630
+	 */
631
+	private function setupCapabilitiesMap()
632
+	{
633
+		// if the initialization process hasn't even started, then we need to call init_caps()
634
+		if($this->initialized === null) {
635
+			return $this->init_caps();
636
+		}
637
+		// unless resetting, get caps from db if we haven't already
638
+		$this->capabilities_map = $this->reset || ! empty($this->capabilities_map)
639
+			? $this->capabilities_map
640
+			: get_option(self::option_name, array());
641
+		return true;
642
+	}
643
+
644
+
645
+
646
+	/**
647
+	 * @param bool $update
648
+	 * @return bool
649
+	 */
650
+	private function updateCapabilitiesMap($update = true)
651
+	{
652
+		return $update ? update_option(self::option_name, $this->capabilities_map) : false;
653
+	}
654
+
655
+
656
+
657
+	/**
658
+	 * Adds capabilities to roles.
659
+	 *
660
+	 * @since 4.9.42
661
+	 * @param array $capabilities_to_add array of capabilities to add, indexed by roles.
662
+	 *                                   Note that this should ONLY be called on activation hook
663
+	 *                                   otherwise the caps will be added on every request.
664
+	 * @return bool
665
+	 * @throws \EE_Error
666
+	 */
667
+	public function addCaps(array $capabilities_to_add)
668
+	{
669
+		// don't do anything if the capabilities map can not be initialized
670
+		if (! $this->setupCapabilitiesMap()) {
671
+			return false;
672
+		}
673
+		// and filter the array so others can get in on the fun during resets
674
+		$capabilities_to_add = apply_filters(
675
+			'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
676
+			$capabilities_to_add,
677
+			$this->reset,
678
+			$this->capabilities_map
679
+		);
680
+		$update_capabilities_map = false;
681
+		// if not reset, see what caps are new for each role. if they're new, add them.
682
+		foreach ($capabilities_to_add as $role => $caps_for_role) {
683
+			if (is_array($caps_for_role)) {
684
+				foreach ($caps_for_role as $cap) {
685
+					if (
686
+						! $this->capHasBeenAddedToRole($role, $cap)
687
+						&& $this->add_cap_to_role($role, $cap, true, false)
688
+					) {
689
+						$update_capabilities_map = true;
690
+					}
691
+				}
692
+			}
693
+		}
694
+		// now let's just save the cap that has been set but only if there's been a change.
695
+		$updated = $this->updateCapabilitiesMap($update_capabilities_map);
696
+		$this->flushWpUser($updated);
697
+		do_action('AHEE__EE_Capabilities__addCaps__complete', $this->capabilities_map, $updated);
698
+		return $updated;
699
+	}
700
+
701
+
702
+
703
+	/**
704
+	 * Loops through the capabilities map and removes the role caps specified by the incoming array
705
+	 *
706
+	 * @param array $caps_map map of capabilities to be removed (indexed by roles)
707
+	 * @return bool
708
+	 * @throws \EE_Error
709
+	 */
710
+	public function removeCaps($caps_map)
711
+	{
712
+		// don't do anything if the capabilities map can not be initialized
713
+		if (! $this->setupCapabilitiesMap()) {
714
+			return false;
715
+		}
716
+		$update_capabilities_map = false;
717
+		foreach ($caps_map as $role => $caps_for_role) {
718
+			if (is_array($caps_for_role)) {
719
+				foreach ($caps_for_role as $cap) {
720
+					if ($this->capHasBeenAddedToRole($role, $cap)
721
+						&& $this->remove_cap_from_role($role, $cap, false)
722
+					) {
723
+						$update_capabilities_map = true;
724
+					}
725
+				}
726
+			}
727
+		}
728
+		// maybe resave the caps
729
+		$updated = $this->updateCapabilitiesMap($update_capabilities_map);
730
+		$this->flushWpUser($updated);
731
+		return $updated;
732
+	}
733
+
734
+
735
+	/**
736
+	 * This ensures that the WP User object cached on the $current_user global in WP has the latest capabilities from
737
+	 * the roles on that user.
738
+	 *
739
+	 * @param bool $flush  Default is to flush the WP_User object.  If false, then this method effectively does nothing.
740
+	 */
741
+	private function flushWpUser($flush = true)
742
+	{
743
+		if ($flush) {
744
+			$user = wp_get_current_user();
745
+			if ($user instanceof WP_User) {
746
+				$user->get_role_caps();
747
+			}
748
+		}
749
+	}
750
+
751
+
752
+
753
+	/**
754
+	 * This method sets a capability on a role.  Note this should only be done on activation, or if you have something
755
+	 * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note.
756
+	 * this is a wrapper for $wp_role->add_cap()
757
+	 *
758
+	 * @see   wp-includes/capabilities.php
759
+	 * @since 4.5.0
760
+	 * @param string|WP_Role $role  A WordPress role the capability is being added to
761
+	 * @param string         $cap   The capability being added to the role
762
+	 * @param bool           $grant Whether to grant access to this cap on this role.
763
+	 * @param bool           $update_capabilities_map
764
+	 * @return bool
765
+	 * @throws \EE_Error
766
+	 */
767
+	public function add_cap_to_role($role, $cap, $grant = true, $update_capabilities_map = true)
768
+	{
769
+		// capture incoming value for $role because we may need it to create a new WP_Role
770
+		$orig_role = $role;
771
+		$role = $role instanceof WP_Role ? $role : get_role($role);
772
+		//if the role isn't available then we create it.
773
+		if (! $role instanceof WP_Role) {
774
+			// if a plugin wants to create a specific role name then they should create the role before
775
+			// EE_Capabilities does.  Otherwise this function will create the role name from the slug:
776
+			// - removes any `ee_` namespacing from the start of the slug.
777
+			// - replaces `_` with ` ` (empty space).
778
+			// - sentence case on the resulting string.
779
+			$role_label = ucwords(str_replace(array('ee_', '_'), array('', ' '), $orig_role));
780
+			$role = add_role($orig_role, $role_label);
781
+		}
782
+		if ($role instanceof WP_Role) {
783
+			// don't do anything if the capabilities map can not be initialized
784
+			if (! $this->setupCapabilitiesMap()) {
785
+				return false;
786
+			}
787
+			if (! $this->capHasBeenAddedToRole($role->name, $cap)) {
788
+				$role->add_cap($cap, $grant);
789
+				$this->capabilities_map[ $role->name ][] = $cap;
790
+				$this->updateCapabilitiesMap($update_capabilities_map);
791
+				return true;
792
+			}
793
+		}
794
+		return false;
795
+	}
796
+
797
+
798
+
799
+	/**
800
+	 * Functions similarly to add_cap_to_role except removes cap from given role.
801
+	 * Wrapper for $wp_role->remove_cap()
802
+	 *
803
+	 * @see   wp-includes/capabilities.php
804
+	 * @since 4.5.0
805
+	 * @param string|WP_Role $role A WordPress role the capability is being removed from.
806
+	 * @param string         $cap  The capability being removed
807
+	 * @param bool           $update_capabilities_map
808
+	 * @return bool
809
+	 * @throws \EE_Error
810
+	 */
811
+	public function remove_cap_from_role($role, $cap, $update_capabilities_map = true)
812
+	{
813
+		// don't do anything if the capabilities map can not be initialized
814
+		if (! $this->setupCapabilitiesMap()) {
815
+			return false;
816
+		}
817
+
818
+		$role = $role instanceof WP_Role ? $role : get_role($role);
819
+		if ($role instanceof WP_Role && $index = $this->capHasBeenAddedToRole($role->name, $cap, true)) {
820
+			$role->remove_cap($cap);
821
+			unset($this->capabilities_map[ $role->name ][ $index ]);
822
+			$this->updateCapabilitiesMap($update_capabilities_map);
823
+			return true;
824
+		}
825
+		return false;
826
+	}
827
+
828
+
829
+
830
+	/**
831
+	 * @param string $role_name
832
+	 * @param string $cap
833
+	 * @param bool   $get_index
834
+	 * @return bool|mixed
835
+	 */
836
+	private function capHasBeenAddedToRole($role_name='', $cap='', $get_index = false)
837
+	{
838
+		if (
839
+			isset($this->capabilities_map[$role_name])
840
+			&& ($index = array_search($cap, $this->capabilities_map[$role_name], true)) !== false
841
+		) {
842
+			return $get_index ? $index : true;
843
+		}
844
+		return false;
845
+	}
846
+
847
+
848
+
849
+	/**
850
+	 * Wrapper for the native WP current_user_can() method.
851
+	 * This is provided as a handy method for a couple things:
852
+	 * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to
853
+	 * write those filters wherever current_user_can is called).
854
+	 * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters )
855
+	 *
856
+	 * @since 4.5.0
857
+	 *
858
+	 * @param string $cap     The cap being checked.
859
+	 * @param string $context The context where the current_user_can is being called from.
860
+	 * @param int    $id      Optional. Id for item where current_user_can is being called from (used in map_meta_cap()
861
+	 *                        filters.
862
+	 *
863
+	 * @return bool  Whether user can or not.
864
+	 */
865
+	public function current_user_can($cap, $context, $id = 0)
866
+	{
867
+		//apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
868
+		$filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id);
869
+		$filtered_cap = apply_filters(
870
+			'FHEE__EE_Capabilities__current_user_can__cap',
871
+			$filtered_cap,
872
+			$context,
873
+			$cap,
874
+			$id
875
+		);
876
+		return ! empty($id)
877
+			? current_user_can($filtered_cap, $id)
878
+			: current_user_can($filtered_cap);
879
+	}
880
+
881
+
882
+
883
+	/**
884
+	 * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class.
885
+	 *
886
+	 * @param int|WP_User $user    Either the user_id or a WP_User object
887
+	 * @param string      $cap     The capability string being checked
888
+	 * @param string      $context The context where the user_can is being called from (used in filters).
889
+	 * @param int         $id      Optional. Id for item where user_can is being called from ( used in map_meta_cap()
890
+	 *                             filters)
891
+	 *
892
+	 * @return bool Whether user can or not.
893
+	 */
894
+	public function user_can($user, $cap, $context, $id = 0)
895
+	{
896
+		//apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
897
+		$filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id);
898
+		$filtered_cap = apply_filters(
899
+			'FHEE__EE_Capabilities__user_can__cap',
900
+			$filtered_cap,
901
+			$context,
902
+			$cap,
903
+			$user,
904
+			$id
905
+		);
906
+		return ! empty($id)
907
+			? user_can($user, $filtered_cap, $id)
908
+			: user_can($user, $filtered_cap);
909
+	}
910
+
911
+
912
+
913
+	/**
914
+	 * Wrapper for the native WP current_user_can_for_blog() method.
915
+	 * This is provided as a handy method for a couple things:
916
+	 * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to
917
+	 * write those filters wherever current_user_can is called).
918
+	 * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters )
919
+	 *
920
+	 * @since 4.5.0
921
+	 *
922
+	 * @param int    $blog_id The blog id that is being checked for.
923
+	 * @param string $cap     The cap being checked.
924
+	 * @param string $context The context where the current_user_can is being called from.
925
+	 * @param int    $id      Optional. Id for item where current_user_can is being called from (used in map_meta_cap()
926
+	 *                        filters.
927
+	 *
928
+	 * @return bool  Whether user can or not.
929
+	 */
930
+	public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0)
931
+	{
932
+		$user_can = ! empty($id)
933
+			? current_user_can_for_blog($blog_id, $cap, $id)
934
+			: current_user_can($blog_id, $cap);
935
+		//apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
936
+		$user_can = apply_filters(
937
+			'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context,
938
+			$user_can,
939
+			$blog_id,
940
+			$cap,
941
+			$id
942
+		);
943
+		$user_can = apply_filters(
944
+			'FHEE__EE_Capabilities__current_user_can_for_blog__user_can',
945
+			$user_can,
946
+			$context,
947
+			$blog_id,
948
+			$cap,
949
+			$id
950
+		);
951
+		return $user_can;
952
+	}
953
+
954
+
955
+
956
+	/**
957
+	 * This helper method just returns an array of registered EE capabilities.
958
+	 *
959
+	 * @since 4.5.0
960
+	 * @param string $role If empty then the entire role/capability map is returned.
961
+	 *                     Otherwise just the capabilities for the given role are returned.
962
+	 * @return array
963
+	 * @throws EE_Error
964
+	 */
965
+	public function get_ee_capabilities($role = 'administrator')
966
+	{
967
+		if (! $this->initialized) {
968
+			$this->init_caps();
969
+		}
970
+		if (empty($role)) {
971
+			return $this->capabilities_map;
972
+		}
973
+		return isset($this->capabilities_map[ $role ])
974
+			? $this->capabilities_map[ $role ]
975
+			: array();
976
+	}
977
+
978
+
979
+
980
+	/**
981
+	 * @deprecated 4.9.42
982
+	 * @param bool  $reset      If you need to reset Event Espresso's capabilities,
983
+	 *                          then please use the init_caps() method with the "$reset" parameter set to "true"
984
+	 * @param array $caps_map   Optional.
985
+	 *                          Can be used to send a custom map of roles and capabilities for setting them up.
986
+	 *                          Note that this should ONLY be called on activation hook or some other one-time
987
+	 *                          task otherwise the caps will be added on every request.
988
+	 * @return void
989
+	 * @throws EE_Error
990
+	 */
991
+	public function init_role_caps($reset = false, $caps_map = array())
992
+	{
993
+		// If this method is called directly and reset is set as 'true',
994
+		// then display a doing it wrong notice, because we want resets to go through init_caps()
995
+		// to guarantee that everything is set up correctly.
996
+		// This prevents the capabilities map getting reset incorrectly by direct calls to this method.
997
+		if ($reset) {
998
+			EE_Error::doing_it_wrong(
999
+				__METHOD__,
1000
+				sprintf(
1001
+					esc_html__(
1002
+						'The "%1$s" parameter for the "%2$s" method is deprecated. If you need to reset Event Espresso\'s capabilities, then please use the "%3$s" method with the "%1$s" parameter set to "%4$s".',
1003
+						'event_espresso'
1004
+					),
1005
+					'$reset',
1006
+					__METHOD__ . '()',
1007
+					'EE_Capabilities::init_caps()',
1008
+					'true'
1009
+				),
1010
+				'4.9.42',
1011
+				'5.0.0'
1012
+			);
1013
+		}
1014
+		$this->addCaps($caps_map);
1015
+	}
1016 1016
 
1017 1017
 
1018 1018
 
@@ -1033,142 +1033,142 @@  discard block
 block discarded – undo
1033 1033
 abstract class EE_Meta_Capability_Map
1034 1034
 {
1035 1035
 
1036
-    public $meta_cap;
1037
-
1038
-    /**
1039
-     * @var EEM_Base
1040
-     */
1041
-    protected $_model;
1042
-
1043
-    protected $_model_name;
1044
-
1045
-    public $published_cap = '';
1046
-
1047
-    public $others_cap = '';
1048
-
1049
-    public $private_cap = '';
1050
-
1051
-
1052
-    /**
1053
-     * constructor.
1054
-     * Receives the setup arguments for the map.
1055
-     *
1056
-     * @since                        4.5.0
1057
-     *
1058
-     * @param string $meta_cap   What meta capability is this mapping.
1059
-     * @param array  $map_values array {
1060
-     *                           //array of values that MUST match a count of 4.  It's okay to send an empty string for
1061
-     *                           capabilities that don't get mapped to.
1062
-     *
1063
-     * @type         $map_values [0] string A string representing the model name. Required.  String's
1064
-     *                               should always be used when Menu Maps are registered via the
1065
-     *                               plugin API as models are not allowed to be instantiated when
1066
-     *                               in maintenance mode 2 (migrations).
1067
-     * @type         $map_values [1] string represents the capability used for published. Optional.
1068
-     * @type         $map_values [2] string represents the capability used for "others". Optional.
1069
-     * @type         $map_values [3] string represents the capability used for private. Optional.
1070
-     *                               }
1071
-     * @throws EE_Error
1072
-     */
1073
-    public function __construct($meta_cap, $map_values)
1074
-    {
1075
-        $this->meta_cap = $meta_cap;
1076
-        //verify there are four args in the $map_values array;
1077
-        if (count($map_values) !== 4) {
1078
-            throw new EE_Error(
1079
-                sprintf(
1080
-                    __(
1081
-                        'Incoming $map_values array should have a count of four values in it.  This is what was given: %s',
1082
-                        'event_espresso'
1083
-                    ),
1084
-                    '<br>' . print_r($map_values, true)
1085
-                )
1086
-            );
1087
-        }
1088
-        //set properties
1089
-        $this->_model = null;
1090
-        $this->_model_name = $map_values[0];
1091
-        $this->published_cap = (string)$map_values[1];
1092
-        $this->others_cap = (string)$map_values[2];
1093
-        $this->private_cap = (string)$map_values[3];
1094
-    }
1095
-
1096
-    /**
1097
-     * Makes it so this object stops filtering caps
1098
-     */
1099
-    public function remove_filters()
1100
-    {
1101
-        remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10);
1102
-    }
1103
-
1104
-
1105
-    /**
1106
-     * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class
1107
-     *
1108
-     * @since 4.5.0
1109
-     * @throws EE_Error
1110
-     *
1111
-     * @return void
1112
-     */
1113
-    public function ensure_is_model()
1114
-    {
1115
-        //is it already instantiated?
1116
-        if ($this->_model instanceof EEM_Base) {
1117
-            return;
1118
-        }
1119
-        //ensure model name is string
1120
-        $this->_model_name = (string)$this->_model_name;
1121
-        //error proof if the name has EEM in it
1122
-        $this->_model_name = str_replace('EEM', '', $this->_model_name);
1123
-        $this->_model = EE_Registry::instance()->load_model($this->_model_name);
1124
-        if (! $this->_model instanceof EEM_Base) {
1125
-            throw new EE_Error(
1126
-                sprintf(
1127
-                    __(
1128
-                        'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class.   Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s',
1129
-                        'event_espresso'
1130
-                    ),
1131
-                    get_class($this),
1132
-                    $this->_model
1133
-                )
1134
-            );
1135
-        }
1136
-    }
1137
-
1138
-
1139
-    /**
1140
-     *
1141
-     * @see   EE_Meta_Capability_Map::_map_meta_caps() for docs on params.
1142
-     * @since 4.6.x
1143
-     *
1144
-     * @param $caps
1145
-     * @param $cap
1146
-     * @param $user_id
1147
-     * @param $args
1148
-     *
1149
-     * @return array
1150
-     */
1151
-    public function map_meta_caps($caps, $cap, $user_id, $args)
1152
-    {
1153
-        return $this->_map_meta_caps($caps, $cap, $user_id, $args);
1154
-    }
1155
-
1156
-
1157
-    /**
1158
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1159
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1160
-     *
1161
-     * @since 4.5.0
1162
-     * @see   wp-includes/capabilities.php
1163
-     *
1164
-     * @param array  $caps    actual users capabilities
1165
-     * @param string $cap     initial capability name that is being checked (the "map" key)
1166
-     * @param int    $user_id The user id
1167
-     * @param array  $args    Adds context to the cap. Typically the object ID.
1168
-     *
1169
-     * @return array   actual users capabilities
1170
-     */
1171
-    abstract protected function _map_meta_caps($caps, $cap, $user_id, $args);
1036
+	public $meta_cap;
1037
+
1038
+	/**
1039
+	 * @var EEM_Base
1040
+	 */
1041
+	protected $_model;
1042
+
1043
+	protected $_model_name;
1044
+
1045
+	public $published_cap = '';
1046
+
1047
+	public $others_cap = '';
1048
+
1049
+	public $private_cap = '';
1050
+
1051
+
1052
+	/**
1053
+	 * constructor.
1054
+	 * Receives the setup arguments for the map.
1055
+	 *
1056
+	 * @since                        4.5.0
1057
+	 *
1058
+	 * @param string $meta_cap   What meta capability is this mapping.
1059
+	 * @param array  $map_values array {
1060
+	 *                           //array of values that MUST match a count of 4.  It's okay to send an empty string for
1061
+	 *                           capabilities that don't get mapped to.
1062
+	 *
1063
+	 * @type         $map_values [0] string A string representing the model name. Required.  String's
1064
+	 *                               should always be used when Menu Maps are registered via the
1065
+	 *                               plugin API as models are not allowed to be instantiated when
1066
+	 *                               in maintenance mode 2 (migrations).
1067
+	 * @type         $map_values [1] string represents the capability used for published. Optional.
1068
+	 * @type         $map_values [2] string represents the capability used for "others". Optional.
1069
+	 * @type         $map_values [3] string represents the capability used for private. Optional.
1070
+	 *                               }
1071
+	 * @throws EE_Error
1072
+	 */
1073
+	public function __construct($meta_cap, $map_values)
1074
+	{
1075
+		$this->meta_cap = $meta_cap;
1076
+		//verify there are four args in the $map_values array;
1077
+		if (count($map_values) !== 4) {
1078
+			throw new EE_Error(
1079
+				sprintf(
1080
+					__(
1081
+						'Incoming $map_values array should have a count of four values in it.  This is what was given: %s',
1082
+						'event_espresso'
1083
+					),
1084
+					'<br>' . print_r($map_values, true)
1085
+				)
1086
+			);
1087
+		}
1088
+		//set properties
1089
+		$this->_model = null;
1090
+		$this->_model_name = $map_values[0];
1091
+		$this->published_cap = (string)$map_values[1];
1092
+		$this->others_cap = (string)$map_values[2];
1093
+		$this->private_cap = (string)$map_values[3];
1094
+	}
1095
+
1096
+	/**
1097
+	 * Makes it so this object stops filtering caps
1098
+	 */
1099
+	public function remove_filters()
1100
+	{
1101
+		remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10);
1102
+	}
1103
+
1104
+
1105
+	/**
1106
+	 * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class
1107
+	 *
1108
+	 * @since 4.5.0
1109
+	 * @throws EE_Error
1110
+	 *
1111
+	 * @return void
1112
+	 */
1113
+	public function ensure_is_model()
1114
+	{
1115
+		//is it already instantiated?
1116
+		if ($this->_model instanceof EEM_Base) {
1117
+			return;
1118
+		}
1119
+		//ensure model name is string
1120
+		$this->_model_name = (string)$this->_model_name;
1121
+		//error proof if the name has EEM in it
1122
+		$this->_model_name = str_replace('EEM', '', $this->_model_name);
1123
+		$this->_model = EE_Registry::instance()->load_model($this->_model_name);
1124
+		if (! $this->_model instanceof EEM_Base) {
1125
+			throw new EE_Error(
1126
+				sprintf(
1127
+					__(
1128
+						'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class.   Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s',
1129
+						'event_espresso'
1130
+					),
1131
+					get_class($this),
1132
+					$this->_model
1133
+				)
1134
+			);
1135
+		}
1136
+	}
1137
+
1138
+
1139
+	/**
1140
+	 *
1141
+	 * @see   EE_Meta_Capability_Map::_map_meta_caps() for docs on params.
1142
+	 * @since 4.6.x
1143
+	 *
1144
+	 * @param $caps
1145
+	 * @param $cap
1146
+	 * @param $user_id
1147
+	 * @param $args
1148
+	 *
1149
+	 * @return array
1150
+	 */
1151
+	public function map_meta_caps($caps, $cap, $user_id, $args)
1152
+	{
1153
+		return $this->_map_meta_caps($caps, $cap, $user_id, $args);
1154
+	}
1155
+
1156
+
1157
+	/**
1158
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1159
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1160
+	 *
1161
+	 * @since 4.5.0
1162
+	 * @see   wp-includes/capabilities.php
1163
+	 *
1164
+	 * @param array  $caps    actual users capabilities
1165
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
1166
+	 * @param int    $user_id The user id
1167
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
1168
+	 *
1169
+	 * @return array   actual users capabilities
1170
+	 */
1171
+	abstract protected function _map_meta_caps($caps, $cap, $user_id, $args);
1172 1172
 }
1173 1173
 
1174 1174
 
@@ -1184,81 +1184,81 @@  discard block
 block discarded – undo
1184 1184
 class EE_Meta_Capability_Map_Edit extends EE_Meta_Capability_Map
1185 1185
 {
1186 1186
 
1187
-    /**
1188
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1189
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1190
-     *
1191
-     * @since 4.5.0
1192
-     * @see   wp-includes/capabilities.php
1193
-     *
1194
-     * @param array  $caps    actual users capabilities
1195
-     * @param string $cap     initial capability name that is being checked (the "map" key)
1196
-     * @param int    $user_id The user id
1197
-     * @param array  $args    Adds context to the cap. Typically the object ID.
1198
-     *
1199
-     * @return array   actual users capabilities
1200
-     */
1201
-    protected function _map_meta_caps($caps, $cap, $user_id, $args)
1202
-    {
1203
-        //only process if we're checking our mapped_cap
1204
-        if ($cap !== $this->meta_cap) {
1205
-            return $caps;
1206
-        }
1207
-
1208
-        //okay it is a meta cap so let's first remove that cap from the $caps array.
1209
-        if (($key = array_search($cap, $caps)) !== false) {
1210
-            unset($caps[$key]);
1211
-        }
1212
-
1213
-        //cast $user_id to int for later explicit comparisons
1214
-        $user_id = (int) $user_id;
1215
-
1216
-        /** @var EE_Base_Class $obj */
1217
-        $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1218
-        //if no obj then let's just do cap
1219
-        if (! $obj instanceof EE_Base_Class) {
1220
-            $caps[] = 'do_not_allow';
1221
-            return $caps;
1222
-        }
1223
-        $caps[] = $cap . 's';
1224
-        if ($obj instanceof EE_CPT_Base) {
1225
-            //if the item author is set and the user is the author...
1226
-            if ($obj->wp_user() && $user_id === $obj->wp_user()) {
1227
-                //if obj is published...
1228
-                if ($obj->status() === 'publish') {
1229
-                    $caps[] = $this->published_cap;
1230
-                }
1231
-            } else {
1232
-                //the user is trying to edit someone else's obj
1233
-                if (! empty($this->others_cap)) {
1234
-                    $caps[] = $this->others_cap;
1235
-                }
1236
-                if (! empty($this->published_cap) && $obj->status() === 'publish') {
1237
-                    $caps[] = $this->published_cap;
1238
-                } elseif (! empty($this->private_cap) && $obj->status() === 'private') {
1239
-                    $caps[] = $this->private_cap;
1240
-                }
1241
-            }
1242
-        } else {
1243
-            //not a cpt object so handled differently
1244
-            $has_cap = false;
1245
-            try {
1246
-                $has_cap = method_exists($obj, 'wp_user')
1247
-                           && $obj->wp_user()
1248
-                           && $obj->wp_user() === $user_id;
1249
-            } catch (Exception $e) {
1250
-                if (WP_DEBUG) {
1251
-                    EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1252
-                }
1253
-            }
1254
-            if (! $has_cap) {
1255
-                if (! empty($this->others_cap)) {
1256
-                    $caps[] = $this->others_cap;
1257
-                }
1258
-            }
1259
-        }
1260
-        return $caps;
1261
-    }
1187
+	/**
1188
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1189
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1190
+	 *
1191
+	 * @since 4.5.0
1192
+	 * @see   wp-includes/capabilities.php
1193
+	 *
1194
+	 * @param array  $caps    actual users capabilities
1195
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
1196
+	 * @param int    $user_id The user id
1197
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
1198
+	 *
1199
+	 * @return array   actual users capabilities
1200
+	 */
1201
+	protected function _map_meta_caps($caps, $cap, $user_id, $args)
1202
+	{
1203
+		//only process if we're checking our mapped_cap
1204
+		if ($cap !== $this->meta_cap) {
1205
+			return $caps;
1206
+		}
1207
+
1208
+		//okay it is a meta cap so let's first remove that cap from the $caps array.
1209
+		if (($key = array_search($cap, $caps)) !== false) {
1210
+			unset($caps[$key]);
1211
+		}
1212
+
1213
+		//cast $user_id to int for later explicit comparisons
1214
+		$user_id = (int) $user_id;
1215
+
1216
+		/** @var EE_Base_Class $obj */
1217
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1218
+		//if no obj then let's just do cap
1219
+		if (! $obj instanceof EE_Base_Class) {
1220
+			$caps[] = 'do_not_allow';
1221
+			return $caps;
1222
+		}
1223
+		$caps[] = $cap . 's';
1224
+		if ($obj instanceof EE_CPT_Base) {
1225
+			//if the item author is set and the user is the author...
1226
+			if ($obj->wp_user() && $user_id === $obj->wp_user()) {
1227
+				//if obj is published...
1228
+				if ($obj->status() === 'publish') {
1229
+					$caps[] = $this->published_cap;
1230
+				}
1231
+			} else {
1232
+				//the user is trying to edit someone else's obj
1233
+				if (! empty($this->others_cap)) {
1234
+					$caps[] = $this->others_cap;
1235
+				}
1236
+				if (! empty($this->published_cap) && $obj->status() === 'publish') {
1237
+					$caps[] = $this->published_cap;
1238
+				} elseif (! empty($this->private_cap) && $obj->status() === 'private') {
1239
+					$caps[] = $this->private_cap;
1240
+				}
1241
+			}
1242
+		} else {
1243
+			//not a cpt object so handled differently
1244
+			$has_cap = false;
1245
+			try {
1246
+				$has_cap = method_exists($obj, 'wp_user')
1247
+						   && $obj->wp_user()
1248
+						   && $obj->wp_user() === $user_id;
1249
+			} catch (Exception $e) {
1250
+				if (WP_DEBUG) {
1251
+					EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1252
+				}
1253
+			}
1254
+			if (! $has_cap) {
1255
+				if (! empty($this->others_cap)) {
1256
+					$caps[] = $this->others_cap;
1257
+				}
1258
+			}
1259
+		}
1260
+		return $caps;
1261
+	}
1262 1262
 }
1263 1263
 
1264 1264
 
@@ -1275,24 +1275,24 @@  discard block
 block discarded – undo
1275 1275
 class EE_Meta_Capability_Map_Delete extends EE_Meta_Capability_Map_Edit
1276 1276
 {
1277 1277
 
1278
-    /**
1279
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1280
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1281
-     *
1282
-     * @since 4.5.0
1283
-     * @see   wp-includes/capabilities.php
1284
-     *
1285
-     * @param array  $caps    actual users capabilities
1286
-     * @param string $cap     initial capability name that is being checked (the "map" key)
1287
-     * @param int    $user_id The user id
1288
-     * @param array  $args    Adds context to the cap. Typically the object ID.
1289
-     *
1290
-     * @return array   actual users capabilities
1291
-     */
1292
-    protected function _map_meta_caps($caps, $cap, $user_id, $args)
1293
-    {
1294
-        return parent::_map_meta_caps($caps, $cap, $user_id, $args);
1295
-    }
1278
+	/**
1279
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1280
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1281
+	 *
1282
+	 * @since 4.5.0
1283
+	 * @see   wp-includes/capabilities.php
1284
+	 *
1285
+	 * @param array  $caps    actual users capabilities
1286
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
1287
+	 * @param int    $user_id The user id
1288
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
1289
+	 *
1290
+	 * @return array   actual users capabilities
1291
+	 */
1292
+	protected function _map_meta_caps($caps, $cap, $user_id, $args)
1293
+	{
1294
+		return parent::_map_meta_caps($caps, $cap, $user_id, $args);
1295
+	}
1296 1296
 }
1297 1297
 
1298 1298
 
@@ -1308,85 +1308,85 @@  discard block
 block discarded – undo
1308 1308
 class EE_Meta_Capability_Map_Read extends EE_Meta_Capability_Map
1309 1309
 {
1310 1310
 
1311
-    /**
1312
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1313
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1314
-     *
1315
-     * @since 4.5.0
1316
-     * @see   wp-includes/capabilities.php
1317
-     *
1318
-     * @param array  $caps    actual users capabilities
1319
-     * @param string $cap     initial capability name that is being checked (the "map" key)
1320
-     * @param int    $user_id The user id
1321
-     * @param array  $args    Adds context to the cap. Typically the object ID.
1322
-     *
1323
-     * @return array   actual users capabilities
1324
-     */
1325
-    protected function _map_meta_caps($caps, $cap, $user_id, $args)
1326
-    {
1327
-        //only process if we're checking our mapped cap;
1328
-        if ($cap !== $this->meta_cap) {
1329
-            return $caps;
1330
-        }
1331
-
1332
-        //okay it is a meta cap so let's first remove that cap from the $caps array.
1333
-        if (($key = array_search($cap, $caps)) !== false) {
1334
-            unset($caps[$key]);
1335
-        }
1336
-
1337
-        //cast $user_id to int for later explicit comparisons
1338
-        $user_id = (int) $user_id;
1339
-
1340
-        $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1341
-        //if no obj then let's just do cap
1342
-        if (! $obj instanceof EE_Base_Class) {
1343
-            $caps[] = 'do_not_allow';
1344
-            return $caps;
1345
-        }
1346
-
1347
-        $caps[] = $cap . 's';
1348
-        if ($obj instanceof EE_CPT_Base) {
1349
-            $status_obj = get_post_status_object($obj->status());
1350
-            if ($status_obj->public) {
1351
-                return $caps;
1352
-            }
1353
-            //if the item author is set and the user is not the author...
1354
-            if ($obj->wp_user() && $obj->wp_user() !== $user_id) {
1355
-                if (! empty($this->others_cap)) {
1356
-                    $caps[] = $this->others_cap;
1357
-                }
1358
-            }
1359
-            //yes this means that if users created the private post, they are able to see it regardless of private cap.
1360
-            if ($status_obj->private
1361
-                && ! empty($this->private_cap)
1362
-                && $obj->wp_user() !== $user_id
1363
-            ) {
1364
-                //the user is trying to view a private object for an object they don't own.
1365
-                $caps[] = $this->private_cap;
1366
-            }
1367
-        } else {
1368
-            //not a cpt object so handled differently
1369
-            $has_cap = false;
1370
-            try {
1371
-                $has_cap = method_exists($obj, 'wp_user')
1372
-                           && $obj->wp_user()
1373
-                           && $obj->wp_user() === $user_id;
1374
-            } catch (Exception $e) {
1375
-                if (WP_DEBUG) {
1376
-                    EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1377
-                }
1378
-            }
1379
-            if (! $has_cap) {
1380
-                if (! empty($this->private_cap)) {
1381
-                    $caps[] = $this->private_cap;
1382
-                }
1383
-                if (! empty($this->others_cap)) {
1384
-                    $caps[] = $this->others_cap;
1385
-                }
1386
-            }
1387
-        }
1388
-        return $caps;
1389
-    }
1311
+	/**
1312
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1313
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1314
+	 *
1315
+	 * @since 4.5.0
1316
+	 * @see   wp-includes/capabilities.php
1317
+	 *
1318
+	 * @param array  $caps    actual users capabilities
1319
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
1320
+	 * @param int    $user_id The user id
1321
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
1322
+	 *
1323
+	 * @return array   actual users capabilities
1324
+	 */
1325
+	protected function _map_meta_caps($caps, $cap, $user_id, $args)
1326
+	{
1327
+		//only process if we're checking our mapped cap;
1328
+		if ($cap !== $this->meta_cap) {
1329
+			return $caps;
1330
+		}
1331
+
1332
+		//okay it is a meta cap so let's first remove that cap from the $caps array.
1333
+		if (($key = array_search($cap, $caps)) !== false) {
1334
+			unset($caps[$key]);
1335
+		}
1336
+
1337
+		//cast $user_id to int for later explicit comparisons
1338
+		$user_id = (int) $user_id;
1339
+
1340
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1341
+		//if no obj then let's just do cap
1342
+		if (! $obj instanceof EE_Base_Class) {
1343
+			$caps[] = 'do_not_allow';
1344
+			return $caps;
1345
+		}
1346
+
1347
+		$caps[] = $cap . 's';
1348
+		if ($obj instanceof EE_CPT_Base) {
1349
+			$status_obj = get_post_status_object($obj->status());
1350
+			if ($status_obj->public) {
1351
+				return $caps;
1352
+			}
1353
+			//if the item author is set and the user is not the author...
1354
+			if ($obj->wp_user() && $obj->wp_user() !== $user_id) {
1355
+				if (! empty($this->others_cap)) {
1356
+					$caps[] = $this->others_cap;
1357
+				}
1358
+			}
1359
+			//yes this means that if users created the private post, they are able to see it regardless of private cap.
1360
+			if ($status_obj->private
1361
+				&& ! empty($this->private_cap)
1362
+				&& $obj->wp_user() !== $user_id
1363
+			) {
1364
+				//the user is trying to view a private object for an object they don't own.
1365
+				$caps[] = $this->private_cap;
1366
+			}
1367
+		} else {
1368
+			//not a cpt object so handled differently
1369
+			$has_cap = false;
1370
+			try {
1371
+				$has_cap = method_exists($obj, 'wp_user')
1372
+						   && $obj->wp_user()
1373
+						   && $obj->wp_user() === $user_id;
1374
+			} catch (Exception $e) {
1375
+				if (WP_DEBUG) {
1376
+					EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1377
+				}
1378
+			}
1379
+			if (! $has_cap) {
1380
+				if (! empty($this->private_cap)) {
1381
+					$caps[] = $this->private_cap;
1382
+				}
1383
+				if (! empty($this->others_cap)) {
1384
+					$caps[] = $this->others_cap;
1385
+				}
1386
+			}
1387
+		}
1388
+		return $caps;
1389
+	}
1390 1390
 }
1391 1391
 
1392 1392
 
@@ -1403,56 +1403,56 @@  discard block
 block discarded – undo
1403 1403
 class EE_Meta_Capability_Map_Messages_Cap extends EE_Meta_Capability_Map
1404 1404
 {
1405 1405
 
1406
-    /**
1407
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1408
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1409
-     *
1410
-     * @since 4.5.0
1411
-     * @see   wp-includes/capabilities.php
1412
-     *
1413
-     * @param array  $caps    actual users capabilities
1414
-     * @param string $cap     initial capability name that is being checked (the "map" key)
1415
-     * @param int    $user_id The user id
1416
-     * @param array  $args    Adds context to the cap. Typically the object ID.
1417
-     *
1418
-     * @return array   actual users capabilities
1419
-     */
1420
-    protected function _map_meta_caps($caps, $cap, $user_id, $args)
1421
-    {
1422
-        //only process if we're checking our mapped_cap
1423
-        if ($cap !== $this->meta_cap) {
1424
-            return $caps;
1425
-        }
1426
-
1427
-        //okay it is a meta cap so let's first remove that cap from the $caps array.
1428
-        if (($key = array_search($cap, $caps)) !== false) {
1429
-            unset($caps[$key]);
1430
-        }
1431
-
1432
-        //cast $user_id to int for later explicit comparisons
1433
-        $user_id = (int) $user_id;
1434
-
1435
-        $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1436
-        //if no obj then let's just do cap
1437
-        if (! $obj instanceof EE_Message_Template_Group) {
1438
-            $caps[] = 'do_not_allow';
1439
-            return $caps;
1440
-        }
1441
-        $caps[] = $cap . 's';
1442
-        $is_global = $obj->is_global();
1443
-        if ($obj->wp_user() && $obj->wp_user() === $user_id) {
1444
-            if ($is_global) {
1445
-                $caps[] = $this->private_cap;
1446
-            }
1447
-        } else {
1448
-            if ($is_global) {
1449
-                $caps[] = $this->private_cap;
1450
-            } else {
1451
-                $caps[] = $this->others_cap;
1452
-            }
1453
-        }
1454
-        return $caps;
1455
-    }
1406
+	/**
1407
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1408
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1409
+	 *
1410
+	 * @since 4.5.0
1411
+	 * @see   wp-includes/capabilities.php
1412
+	 *
1413
+	 * @param array  $caps    actual users capabilities
1414
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
1415
+	 * @param int    $user_id The user id
1416
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
1417
+	 *
1418
+	 * @return array   actual users capabilities
1419
+	 */
1420
+	protected function _map_meta_caps($caps, $cap, $user_id, $args)
1421
+	{
1422
+		//only process if we're checking our mapped_cap
1423
+		if ($cap !== $this->meta_cap) {
1424
+			return $caps;
1425
+		}
1426
+
1427
+		//okay it is a meta cap so let's first remove that cap from the $caps array.
1428
+		if (($key = array_search($cap, $caps)) !== false) {
1429
+			unset($caps[$key]);
1430
+		}
1431
+
1432
+		//cast $user_id to int for later explicit comparisons
1433
+		$user_id = (int) $user_id;
1434
+
1435
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1436
+		//if no obj then let's just do cap
1437
+		if (! $obj instanceof EE_Message_Template_Group) {
1438
+			$caps[] = 'do_not_allow';
1439
+			return $caps;
1440
+		}
1441
+		$caps[] = $cap . 's';
1442
+		$is_global = $obj->is_global();
1443
+		if ($obj->wp_user() && $obj->wp_user() === $user_id) {
1444
+			if ($is_global) {
1445
+				$caps[] = $this->private_cap;
1446
+			}
1447
+		} else {
1448
+			if ($is_global) {
1449
+				$caps[] = $this->private_cap;
1450
+			} else {
1451
+				$caps[] = $this->others_cap;
1452
+			}
1453
+		}
1454
+		return $caps;
1455
+	}
1456 1456
 }
1457 1457
 
1458 1458
 
@@ -1469,40 +1469,40 @@  discard block
 block discarded – undo
1469 1469
 class EE_Meta_Capability_Map_Registration_Form_Cap extends EE_Meta_Capability_Map
1470 1470
 {
1471 1471
 
1472
-    /**
1473
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1474
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1475
-     *
1476
-     * @since 4.5.0
1477
-     * @see   wp-includes/capabilities.php
1478
-     * @param array  $caps    actual users capabilities
1479
-     * @param string $cap     initial capability name that is being checked (the "map" key)
1480
-     * @param int    $user_id The user id
1481
-     * @param array  $args    Adds context to the cap. Typically the object ID.
1482
-     * @return array   actual users capabilities
1483
-     */
1484
-    protected function _map_meta_caps($caps, $cap, $user_id, $args)
1485
-    {
1486
-        //only process if we're checking our mapped_cap
1487
-        if ($cap !== $this->meta_cap) {
1488
-            return $caps;
1489
-        }
1490
-        //okay it is a meta cap so let's first remove that cap from the $caps array.
1491
-        if (($key = array_search($cap, $caps)) !== false) {
1492
-            unset($caps[$key]);
1493
-        }
1494
-        $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1495
-        //if no obj then let's just do cap
1496
-        if (! $obj instanceof EE_Base_Class) {
1497
-            $caps[] = 'do_not_allow';
1498
-            return $caps;
1499
-        }
1500
-        $caps[]    = $cap . 's';
1501
-        $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false;
1502
-        $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system;
1503
-        if ($is_system) {
1504
-            $caps[] = $this->private_cap;
1505
-        }
1506
-        return $caps;
1507
-    }
1472
+	/**
1473
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1474
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1475
+	 *
1476
+	 * @since 4.5.0
1477
+	 * @see   wp-includes/capabilities.php
1478
+	 * @param array  $caps    actual users capabilities
1479
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
1480
+	 * @param int    $user_id The user id
1481
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
1482
+	 * @return array   actual users capabilities
1483
+	 */
1484
+	protected function _map_meta_caps($caps, $cap, $user_id, $args)
1485
+	{
1486
+		//only process if we're checking our mapped_cap
1487
+		if ($cap !== $this->meta_cap) {
1488
+			return $caps;
1489
+		}
1490
+		//okay it is a meta cap so let's first remove that cap from the $caps array.
1491
+		if (($key = array_search($cap, $caps)) !== false) {
1492
+			unset($caps[$key]);
1493
+		}
1494
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1495
+		//if no obj then let's just do cap
1496
+		if (! $obj instanceof EE_Base_Class) {
1497
+			$caps[] = 'do_not_allow';
1498
+			return $caps;
1499
+		}
1500
+		$caps[]    = $cap . 's';
1501
+		$is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false;
1502
+		$is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system;
1503
+		if ($is_system) {
1504
+			$caps[] = $this->private_cap;
1505
+		}
1506
+		return $caps;
1507
+	}
1508 1508
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     public static function instance()
86 86
     {
87 87
         //check if instantiated, and if not do so.
88
-        if (! self::$_instance instanceof EE_Capabilities) {
88
+        if ( ! self::$_instance instanceof EE_Capabilities) {
89 89
             self::$_instance = new self();
90 90
         }
91 91
         return self::$_instance;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public function init_caps($reset = false)
119 119
     {
120
-        if(! EE_Maintenance_Mode::instance()->models_can_query()){
120
+        if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
121 121
             return false;
122 122
         }
123 123
         $this->reset = filter_var($reset, FILTER_VALIDATE_BOOLEAN);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
             $this->_get_default_meta_caps_array()
165 165
         );
166 166
         //add filter for map_meta_caps but only if models can query.
167
-        if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) {
167
+        if ( ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) {
168 168
             add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4);
169 169
         }
170 170
     }
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
         if (did_action('AHEE__EE_System__load_espresso_addons__complete')) {
326 326
             //loop through our _meta_caps array
327 327
             foreach ($this->_meta_caps as $meta_map) {
328
-                if (! $meta_map instanceof EE_Meta_Capability_Map) {
328
+                if ( ! $meta_map instanceof EE_Meta_Capability_Map) {
329 329
                     continue;
330 330
                 }
331 331
                 // don't load models if there is no object ID in the args
332
-                if (! empty($args[0])) {
332
+                if ( ! empty($args[0])) {
333 333
                     $meta_map->ensure_is_model();
334 334
                 }
335 335
                 $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args);
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
     private function setupCapabilitiesMap()
632 632
     {
633 633
         // if the initialization process hasn't even started, then we need to call init_caps()
634
-        if($this->initialized === null) {
634
+        if ($this->initialized === null) {
635 635
             return $this->init_caps();
636 636
         }
637 637
         // unless resetting, get caps from db if we haven't already
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
     public function addCaps(array $capabilities_to_add)
668 668
     {
669 669
         // don't do anything if the capabilities map can not be initialized
670
-        if (! $this->setupCapabilitiesMap()) {
670
+        if ( ! $this->setupCapabilitiesMap()) {
671 671
             return false;
672 672
         }
673 673
         // and filter the array so others can get in on the fun during resets
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
     public function removeCaps($caps_map)
711 711
     {
712 712
         // don't do anything if the capabilities map can not be initialized
713
-        if (! $this->setupCapabilitiesMap()) {
713
+        if ( ! $this->setupCapabilitiesMap()) {
714 714
             return false;
715 715
         }
716 716
         $update_capabilities_map = false;
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
         $orig_role = $role;
771 771
         $role = $role instanceof WP_Role ? $role : get_role($role);
772 772
         //if the role isn't available then we create it.
773
-        if (! $role instanceof WP_Role) {
773
+        if ( ! $role instanceof WP_Role) {
774 774
             // if a plugin wants to create a specific role name then they should create the role before
775 775
             // EE_Capabilities does.  Otherwise this function will create the role name from the slug:
776 776
             // - removes any `ee_` namespacing from the start of the slug.
@@ -781,12 +781,12 @@  discard block
 block discarded – undo
781 781
         }
782 782
         if ($role instanceof WP_Role) {
783 783
             // don't do anything if the capabilities map can not be initialized
784
-            if (! $this->setupCapabilitiesMap()) {
784
+            if ( ! $this->setupCapabilitiesMap()) {
785 785
                 return false;
786 786
             }
787
-            if (! $this->capHasBeenAddedToRole($role->name, $cap)) {
787
+            if ( ! $this->capHasBeenAddedToRole($role->name, $cap)) {
788 788
                 $role->add_cap($cap, $grant);
789
-                $this->capabilities_map[ $role->name ][] = $cap;
789
+                $this->capabilities_map[$role->name][] = $cap;
790 790
                 $this->updateCapabilitiesMap($update_capabilities_map);
791 791
                 return true;
792 792
             }
@@ -811,14 +811,14 @@  discard block
 block discarded – undo
811 811
     public function remove_cap_from_role($role, $cap, $update_capabilities_map = true)
812 812
     {
813 813
         // don't do anything if the capabilities map can not be initialized
814
-        if (! $this->setupCapabilitiesMap()) {
814
+        if ( ! $this->setupCapabilitiesMap()) {
815 815
             return false;
816 816
         }
817 817
 
818 818
         $role = $role instanceof WP_Role ? $role : get_role($role);
819 819
         if ($role instanceof WP_Role && $index = $this->capHasBeenAddedToRole($role->name, $cap, true)) {
820 820
             $role->remove_cap($cap);
821
-            unset($this->capabilities_map[ $role->name ][ $index ]);
821
+            unset($this->capabilities_map[$role->name][$index]);
822 822
             $this->updateCapabilitiesMap($update_capabilities_map);
823 823
             return true;
824 824
         }
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
      * @param bool   $get_index
834 834
      * @return bool|mixed
835 835
      */
836
-    private function capHasBeenAddedToRole($role_name='', $cap='', $get_index = false)
836
+    private function capHasBeenAddedToRole($role_name = '', $cap = '', $get_index = false)
837 837
     {
838 838
         if (
839 839
             isset($this->capabilities_map[$role_name])
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
     public function current_user_can($cap, $context, $id = 0)
866 866
     {
867 867
         //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
868
-        $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id);
868
+        $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id);
869 869
         $filtered_cap = apply_filters(
870 870
             'FHEE__EE_Capabilities__current_user_can__cap',
871 871
             $filtered_cap,
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
     public function user_can($user, $cap, $context, $id = 0)
895 895
     {
896 896
         //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
897
-        $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id);
897
+        $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id);
898 898
         $filtered_cap = apply_filters(
899 899
             'FHEE__EE_Capabilities__user_can__cap',
900 900
             $filtered_cap,
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
             : current_user_can($blog_id, $cap);
935 935
         //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
936 936
         $user_can = apply_filters(
937
-            'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context,
937
+            'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context,
938 938
             $user_can,
939 939
             $blog_id,
940 940
             $cap,
@@ -964,14 +964,14 @@  discard block
 block discarded – undo
964 964
      */
965 965
     public function get_ee_capabilities($role = 'administrator')
966 966
     {
967
-        if (! $this->initialized) {
967
+        if ( ! $this->initialized) {
968 968
             $this->init_caps();
969 969
         }
970 970
         if (empty($role)) {
971 971
             return $this->capabilities_map;
972 972
         }
973
-        return isset($this->capabilities_map[ $role ])
974
-            ? $this->capabilities_map[ $role ]
973
+        return isset($this->capabilities_map[$role])
974
+            ? $this->capabilities_map[$role]
975 975
             : array();
976 976
     }
977 977
 
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
                         'event_espresso'
1004 1004
                     ),
1005 1005
                     '$reset',
1006
-                    __METHOD__ . '()',
1006
+                    __METHOD__.'()',
1007 1007
                     'EE_Capabilities::init_caps()',
1008 1008
                     'true'
1009 1009
                 ),
@@ -1081,16 +1081,16 @@  discard block
 block discarded – undo
1081 1081
                         'Incoming $map_values array should have a count of four values in it.  This is what was given: %s',
1082 1082
                         'event_espresso'
1083 1083
                     ),
1084
-                    '<br>' . print_r($map_values, true)
1084
+                    '<br>'.print_r($map_values, true)
1085 1085
                 )
1086 1086
             );
1087 1087
         }
1088 1088
         //set properties
1089 1089
         $this->_model = null;
1090 1090
         $this->_model_name = $map_values[0];
1091
-        $this->published_cap = (string)$map_values[1];
1092
-        $this->others_cap = (string)$map_values[2];
1093
-        $this->private_cap = (string)$map_values[3];
1091
+        $this->published_cap = (string) $map_values[1];
1092
+        $this->others_cap = (string) $map_values[2];
1093
+        $this->private_cap = (string) $map_values[3];
1094 1094
     }
1095 1095
 
1096 1096
     /**
@@ -1117,11 +1117,11 @@  discard block
 block discarded – undo
1117 1117
             return;
1118 1118
         }
1119 1119
         //ensure model name is string
1120
-        $this->_model_name = (string)$this->_model_name;
1120
+        $this->_model_name = (string) $this->_model_name;
1121 1121
         //error proof if the name has EEM in it
1122 1122
         $this->_model_name = str_replace('EEM', '', $this->_model_name);
1123 1123
         $this->_model = EE_Registry::instance()->load_model($this->_model_name);
1124
-        if (! $this->_model instanceof EEM_Base) {
1124
+        if ( ! $this->_model instanceof EEM_Base) {
1125 1125
             throw new EE_Error(
1126 1126
                 sprintf(
1127 1127
                     __(
@@ -1216,11 +1216,11 @@  discard block
 block discarded – undo
1216 1216
         /** @var EE_Base_Class $obj */
1217 1217
         $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1218 1218
         //if no obj then let's just do cap
1219
-        if (! $obj instanceof EE_Base_Class) {
1219
+        if ( ! $obj instanceof EE_Base_Class) {
1220 1220
             $caps[] = 'do_not_allow';
1221 1221
             return $caps;
1222 1222
         }
1223
-        $caps[] = $cap . 's';
1223
+        $caps[] = $cap.'s';
1224 1224
         if ($obj instanceof EE_CPT_Base) {
1225 1225
             //if the item author is set and the user is the author...
1226 1226
             if ($obj->wp_user() && $user_id === $obj->wp_user()) {
@@ -1230,12 +1230,12 @@  discard block
 block discarded – undo
1230 1230
                 }
1231 1231
             } else {
1232 1232
                 //the user is trying to edit someone else's obj
1233
-                if (! empty($this->others_cap)) {
1233
+                if ( ! empty($this->others_cap)) {
1234 1234
                     $caps[] = $this->others_cap;
1235 1235
                 }
1236
-                if (! empty($this->published_cap) && $obj->status() === 'publish') {
1236
+                if ( ! empty($this->published_cap) && $obj->status() === 'publish') {
1237 1237
                     $caps[] = $this->published_cap;
1238
-                } elseif (! empty($this->private_cap) && $obj->status() === 'private') {
1238
+                } elseif ( ! empty($this->private_cap) && $obj->status() === 'private') {
1239 1239
                     $caps[] = $this->private_cap;
1240 1240
                 }
1241 1241
             }
@@ -1251,8 +1251,8 @@  discard block
 block discarded – undo
1251 1251
                     EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1252 1252
                 }
1253 1253
             }
1254
-            if (! $has_cap) {
1255
-                if (! empty($this->others_cap)) {
1254
+            if ( ! $has_cap) {
1255
+                if ( ! empty($this->others_cap)) {
1256 1256
                     $caps[] = $this->others_cap;
1257 1257
                 }
1258 1258
             }
@@ -1339,12 +1339,12 @@  discard block
 block discarded – undo
1339 1339
 
1340 1340
         $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1341 1341
         //if no obj then let's just do cap
1342
-        if (! $obj instanceof EE_Base_Class) {
1342
+        if ( ! $obj instanceof EE_Base_Class) {
1343 1343
             $caps[] = 'do_not_allow';
1344 1344
             return $caps;
1345 1345
         }
1346 1346
 
1347
-        $caps[] = $cap . 's';
1347
+        $caps[] = $cap.'s';
1348 1348
         if ($obj instanceof EE_CPT_Base) {
1349 1349
             $status_obj = get_post_status_object($obj->status());
1350 1350
             if ($status_obj->public) {
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
             }
1353 1353
             //if the item author is set and the user is not the author...
1354 1354
             if ($obj->wp_user() && $obj->wp_user() !== $user_id) {
1355
-                if (! empty($this->others_cap)) {
1355
+                if ( ! empty($this->others_cap)) {
1356 1356
                     $caps[] = $this->others_cap;
1357 1357
                 }
1358 1358
             }
@@ -1376,11 +1376,11 @@  discard block
 block discarded – undo
1376 1376
                     EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1377 1377
                 }
1378 1378
             }
1379
-            if (! $has_cap) {
1380
-                if (! empty($this->private_cap)) {
1379
+            if ( ! $has_cap) {
1380
+                if ( ! empty($this->private_cap)) {
1381 1381
                     $caps[] = $this->private_cap;
1382 1382
                 }
1383
-                if (! empty($this->others_cap)) {
1383
+                if ( ! empty($this->others_cap)) {
1384 1384
                     $caps[] = $this->others_cap;
1385 1385
                 }
1386 1386
             }
@@ -1434,11 +1434,11 @@  discard block
 block discarded – undo
1434 1434
 
1435 1435
         $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1436 1436
         //if no obj then let's just do cap
1437
-        if (! $obj instanceof EE_Message_Template_Group) {
1437
+        if ( ! $obj instanceof EE_Message_Template_Group) {
1438 1438
             $caps[] = 'do_not_allow';
1439 1439
             return $caps;
1440 1440
         }
1441
-        $caps[] = $cap . 's';
1441
+        $caps[] = $cap.'s';
1442 1442
         $is_global = $obj->is_global();
1443 1443
         if ($obj->wp_user() && $obj->wp_user() === $user_id) {
1444 1444
             if ($is_global) {
@@ -1493,11 +1493,11 @@  discard block
 block discarded – undo
1493 1493
         }
1494 1494
         $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1495 1495
         //if no obj then let's just do cap
1496
-        if (! $obj instanceof EE_Base_Class) {
1496
+        if ( ! $obj instanceof EE_Base_Class) {
1497 1497
             $caps[] = 'do_not_allow';
1498 1498
             return $caps;
1499 1499
         }
1500
-        $caps[]    = $cap . 's';
1500
+        $caps[]    = $cap.'s';
1501 1501
         $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false;
1502 1502
         $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system;
1503 1503
         if ($is_system) {
Please login to merge, or discard this patch.
admin/extend/transactions/Extend_Transactions_Admin_Page.core.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@
 block discarded – undo
198 198
      *
199 199
      * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
200 200
      *
201
-     * @return int
201
+     * @return string
202 202
      */
203 203
     private function _revenue_per_event_report($period = '-1 month')
204 204
     {
Please login to merge, or discard this patch.
Indentation   +220 added lines, -220 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
 /**
@@ -32,224 +32,224 @@  discard block
 block discarded – undo
32 32
 {
33 33
 
34 34
 
35
-    /**
36
-     * This is used to hold the reports template data which is setup early in the request.
37
-     * @type array
38
-     */
39
-    protected $_reports_template_data = array();
40
-
41
-    /**
42
-     * @Constructor
43
-     * @access public
44
-     *
45
-     * @param bool $routing
46
-     *
47
-     * @return \Extend_Transactions_Admin_Page
48
-     */
49
-    public function __construct($routing = true)
50
-    {
51
-        parent::__construct($routing);
52
-        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
53
-        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
54
-        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
55
-    }
56
-
57
-
58
-    /**
59
-     *    _extend_page_config
60
-     *
61
-     * @access protected
62
-     * @return void
63
-     */
64
-    protected function _extend_page_config()
65
-    {
66
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
67
-
68
-        $new_page_routes = array(
69
-            'reports' => array(
70
-                'func'       => '_transaction_reports',
71
-                'capability' => 'ee_read_transactions'
72
-            )
73
-        );
74
-
75
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
76
-
77
-        $new_page_config    = array(
78
-            'reports' => array(
79
-                'nav'           => array(
80
-                    'label' => __('Reports', 'event_espresso'),
81
-                    'order' => 20
82
-                ),
83
-                'help_tabs'     => array(
84
-                    'transactions_reports_help_tab' => array(
85
-                        'title'    => __('Transaction Reports', 'event_espresso'),
86
-                        'filename' => 'transactions_reports'
87
-                    )
88
-                ),
89
-                /*'help_tour' => array( 'Transaction_Reports_Help_Tour' ),*/
90
-                'require_nonce' => false
91
-            )
92
-        );
93
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
94
-    }
95
-
96
-
97
-    /**
98
-     *    load_scripts_styles_reports
99
-     *
100
-     * @access public
101
-     * @return void
102
-     */
103
-    public function load_scripts_styles_reports()
104
-    {
105
-        wp_register_script(
106
-            'ee-txn-reports-js',
107
-            TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
108
-            array('google-charts'),
109
-            EVENT_ESPRESSO_VERSION,
110
-            true
111
-        );
112
-        wp_enqueue_script('ee-txn-reports-js');
113
-        $this->_transaction_reports_js_setup();
114
-        EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
115
-    }
116
-
117
-
118
-    /**
119
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
120
-     * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method.
121
-     */
122
-    protected function _transaction_reports_js_setup()
123
-    {
124
-        $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report();
125
-        $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report();
126
-    }
127
-
128
-
129
-    /**
130
-     * _transaction_reports
131
-     *    generates Business Reports regarding Transactions
132
-     *
133
-     * @return void
134
-     */
135
-    protected function _transaction_reports()
136
-    {
137
-        $template_path                              = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
138
-        $this->_admin_page_title                    = __('Transactions', 'event_espresso');
139
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
140
-            $this->_reports_template_data, true);
141
-
142
-        // the final template wrapper
143
-        $this->display_admin_page_with_no_sidebar();
144
-    }
145
-
146
-
147
-    /**
148
-     * _revenue_per_day_report
149
-     * generates Business Report showing Total Revenue per Day.
150
-     *
151
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
152
-     *
153
-     * @return string
154
-     */
155
-    private function _revenue_per_day_report($period = '-1 month')
156
-    {
157
-
158
-        $report_ID = 'txn-admin-revenue-per-day-report-dv';
159
-
160
-        $TXN = EEM_Transaction::instance();
161
-
162
-        $results  = $TXN->get_revenue_per_day_report($period);
163
-        $results  = (array)$results;
164
-        $revenue  = array();
165
-        $subtitle = '';
166
-
167
-        if ($results) {
168
-            $revenue[] = array(
169
-                __('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'),
170
-                __('Total Revenue', 'event_espresso')
171
-            );
172
-            foreach ($results as $result) {
173
-                $revenue[] = array($result->txnDate, (float)$result->revenue);
174
-            }
175
-
176
-            //setup the date range.
177
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
178
-            $ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
179
-            $subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
180
-                $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
181
-        }
182
-
183
-        $report_title = esc_html__('Total Revenue per Day', 'event_espresso');
184
-
185
-        $report_params = array(
186
-            'title'     => $report_title,
187
-            'subtitle'  => $subtitle,
188
-            'id'        => $report_ID,
189
-            'revenue'   => $revenue,
190
-            'noResults' => empty($revenue) || count($revenue) === 1,
191
-            'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
192
-                '<h2>' . $report_title . '</h2><p>', '</p>')
193
-        );
194
-        wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
195
-
196
-        return $report_ID;
197
-    }
198
-
199
-
200
-    /**
201
-     * _revenue_per_event_report
202
-     * generates Business Report showing total revenue per event.
203
-     *
204
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
205
-     *
206
-     * @return int
207
-     */
208
-    private function _revenue_per_event_report($period = '-1 month')
209
-    {
210
-
211
-        $report_ID = 'txn-admin-revenue-per-event-report-dv';
212
-
213
-        $TXN      = EEM_Transaction::instance();
214
-        $results  = $TXN->get_revenue_per_event_report($period);
215
-        $results  = (array)$results;
216
-        $revenue  = array();
217
-        $subtitle = '';
218
-
219
-        if ($results) {
220
-            $revenue[] = array(
221
-                __('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'),
222
-                __('Total Revenue', 'event_espresso')
223
-            );
224
-            foreach ($results as $result) {
225
-                if ($result->revenue > 1) {
226
-                    $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
227
-                    $event_name = wp_trim_words($event_name, 5, '...');
228
-                    $revenue[]  = array($event_name, (float)$result->revenue);
229
-                }
230
-            }
231
-
232
-            //setup the date range.
233
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
234
-            $ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
235
-            $subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
236
-                $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
237
-        }
238
-
239
-        $report_title = esc_html__('Total Revenue per Event', 'event_espresso');
240
-
241
-        $report_params = array(
242
-            'title'     => $report_title,
243
-            'subtitle'  => $subtitle,
244
-            'id'        => $report_ID,
245
-            'revenue'   => $revenue,
246
-            'noResults' => empty($revenue),
247
-            'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
248
-                '<h2>' . $report_title . '</h2><p>', '</p>')
249
-        );
250
-        wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
251
-
252
-        return $report_ID;
253
-    }
35
+	/**
36
+	 * This is used to hold the reports template data which is setup early in the request.
37
+	 * @type array
38
+	 */
39
+	protected $_reports_template_data = array();
40
+
41
+	/**
42
+	 * @Constructor
43
+	 * @access public
44
+	 *
45
+	 * @param bool $routing
46
+	 *
47
+	 * @return \Extend_Transactions_Admin_Page
48
+	 */
49
+	public function __construct($routing = true)
50
+	{
51
+		parent::__construct($routing);
52
+		define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
53
+		define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
54
+		define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
55
+	}
56
+
57
+
58
+	/**
59
+	 *    _extend_page_config
60
+	 *
61
+	 * @access protected
62
+	 * @return void
63
+	 */
64
+	protected function _extend_page_config()
65
+	{
66
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
67
+
68
+		$new_page_routes = array(
69
+			'reports' => array(
70
+				'func'       => '_transaction_reports',
71
+				'capability' => 'ee_read_transactions'
72
+			)
73
+		);
74
+
75
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
76
+
77
+		$new_page_config    = array(
78
+			'reports' => array(
79
+				'nav'           => array(
80
+					'label' => __('Reports', 'event_espresso'),
81
+					'order' => 20
82
+				),
83
+				'help_tabs'     => array(
84
+					'transactions_reports_help_tab' => array(
85
+						'title'    => __('Transaction Reports', 'event_espresso'),
86
+						'filename' => 'transactions_reports'
87
+					)
88
+				),
89
+				/*'help_tour' => array( 'Transaction_Reports_Help_Tour' ),*/
90
+				'require_nonce' => false
91
+			)
92
+		);
93
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
94
+	}
95
+
96
+
97
+	/**
98
+	 *    load_scripts_styles_reports
99
+	 *
100
+	 * @access public
101
+	 * @return void
102
+	 */
103
+	public function load_scripts_styles_reports()
104
+	{
105
+		wp_register_script(
106
+			'ee-txn-reports-js',
107
+			TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
108
+			array('google-charts'),
109
+			EVENT_ESPRESSO_VERSION,
110
+			true
111
+		);
112
+		wp_enqueue_script('ee-txn-reports-js');
113
+		$this->_transaction_reports_js_setup();
114
+		EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
115
+	}
116
+
117
+
118
+	/**
119
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
120
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method.
121
+	 */
122
+	protected function _transaction_reports_js_setup()
123
+	{
124
+		$this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report();
125
+		$this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report();
126
+	}
127
+
128
+
129
+	/**
130
+	 * _transaction_reports
131
+	 *    generates Business Reports regarding Transactions
132
+	 *
133
+	 * @return void
134
+	 */
135
+	protected function _transaction_reports()
136
+	{
137
+		$template_path                              = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
138
+		$this->_admin_page_title                    = __('Transactions', 'event_espresso');
139
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
140
+			$this->_reports_template_data, true);
141
+
142
+		// the final template wrapper
143
+		$this->display_admin_page_with_no_sidebar();
144
+	}
145
+
146
+
147
+	/**
148
+	 * _revenue_per_day_report
149
+	 * generates Business Report showing Total Revenue per Day.
150
+	 *
151
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
152
+	 *
153
+	 * @return string
154
+	 */
155
+	private function _revenue_per_day_report($period = '-1 month')
156
+	{
157
+
158
+		$report_ID = 'txn-admin-revenue-per-day-report-dv';
159
+
160
+		$TXN = EEM_Transaction::instance();
161
+
162
+		$results  = $TXN->get_revenue_per_day_report($period);
163
+		$results  = (array)$results;
164
+		$revenue  = array();
165
+		$subtitle = '';
166
+
167
+		if ($results) {
168
+			$revenue[] = array(
169
+				__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'),
170
+				__('Total Revenue', 'event_espresso')
171
+			);
172
+			foreach ($results as $result) {
173
+				$revenue[] = array($result->txnDate, (float)$result->revenue);
174
+			}
175
+
176
+			//setup the date range.
177
+			$beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
178
+			$ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
179
+			$subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
180
+				$beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
181
+		}
182
+
183
+		$report_title = esc_html__('Total Revenue per Day', 'event_espresso');
184
+
185
+		$report_params = array(
186
+			'title'     => $report_title,
187
+			'subtitle'  => $subtitle,
188
+			'id'        => $report_ID,
189
+			'revenue'   => $revenue,
190
+			'noResults' => empty($revenue) || count($revenue) === 1,
191
+			'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
192
+				'<h2>' . $report_title . '</h2><p>', '</p>')
193
+		);
194
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
195
+
196
+		return $report_ID;
197
+	}
198
+
199
+
200
+	/**
201
+	 * _revenue_per_event_report
202
+	 * generates Business Report showing total revenue per event.
203
+	 *
204
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
205
+	 *
206
+	 * @return int
207
+	 */
208
+	private function _revenue_per_event_report($period = '-1 month')
209
+	{
210
+
211
+		$report_ID = 'txn-admin-revenue-per-event-report-dv';
212
+
213
+		$TXN      = EEM_Transaction::instance();
214
+		$results  = $TXN->get_revenue_per_event_report($period);
215
+		$results  = (array)$results;
216
+		$revenue  = array();
217
+		$subtitle = '';
218
+
219
+		if ($results) {
220
+			$revenue[] = array(
221
+				__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'),
222
+				__('Total Revenue', 'event_espresso')
223
+			);
224
+			foreach ($results as $result) {
225
+				if ($result->revenue > 1) {
226
+					$event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
227
+					$event_name = wp_trim_words($event_name, 5, '...');
228
+					$revenue[]  = array($event_name, (float)$result->revenue);
229
+				}
230
+			}
231
+
232
+			//setup the date range.
233
+			$beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
234
+			$ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
235
+			$subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
236
+				$beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
237
+		}
238
+
239
+		$report_title = esc_html__('Total Revenue per Event', 'event_espresso');
240
+
241
+		$report_params = array(
242
+			'title'     => $report_title,
243
+			'subtitle'  => $subtitle,
244
+			'id'        => $report_ID,
245
+			'revenue'   => $revenue,
246
+			'noResults' => empty($revenue),
247
+			'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
248
+				'<h2>' . $report_title . '</h2><p>', '</p>')
249
+		);
250
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
251
+
252
+		return $report_ID;
253
+	}
254 254
 
255 255
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
     public function __construct($routing = true)
50 50
     {
51 51
         parent::__construct($routing);
52
-        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
53
-        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
54
-        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
52
+        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'transactions/templates/');
53
+        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'transactions/assets/');
54
+        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'transactions/assets/');
55 55
     }
56 56
 
57 57
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     protected function _extend_page_config()
65 65
     {
66
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
66
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'transactions';
67 67
 
68 68
         $new_page_routes = array(
69 69
             'reports' => array(
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     {
105 105
         wp_register_script(
106 106
             'ee-txn-reports-js',
107
-            TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
107
+            TXN_CAF_ASSETS_URL.'ee-transaction-admin-reports.js',
108 108
             array('google-charts'),
109 109
             EVENT_ESPRESSO_VERSION,
110 110
             true
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     protected function _transaction_reports()
136 136
     {
137
-        $template_path                              = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
137
+        $template_path                              = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
138 138
         $this->_admin_page_title                    = __('Transactions', 'event_espresso');
139 139
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
140 140
             $this->_reports_template_data, true);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $TXN = EEM_Transaction::instance();
161 161
 
162 162
         $results  = $TXN->get_revenue_per_day_report($period);
163
-        $results  = (array)$results;
163
+        $results  = (array) $results;
164 164
         $revenue  = array();
165 165
         $subtitle = '';
166 166
 
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
                 __('Total Revenue', 'event_espresso')
171 171
             );
172 172
             foreach ($results as $result) {
173
-                $revenue[] = array($result->txnDate, (float)$result->revenue);
173
+                $revenue[] = array($result->txnDate, (float) $result->revenue);
174 174
             }
175 175
 
176 176
             //setup the date range.
177
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
177
+            $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
178 178
             $ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
179 179
             $subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
180 180
                 $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
             'revenue'   => $revenue,
190 190
             'noResults' => empty($revenue) || count($revenue) === 1,
191 191
             'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
192
-                '<h2>' . $report_title . '</h2><p>', '</p>')
192
+                '<h2>'.$report_title.'</h2><p>', '</p>')
193 193
         );
194 194
         wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
195 195
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
         $TXN      = EEM_Transaction::instance();
214 214
         $results  = $TXN->get_revenue_per_event_report($period);
215
-        $results  = (array)$results;
215
+        $results  = (array) $results;
216 216
         $revenue  = array();
217 217
         $subtitle = '';
218 218
 
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
                 if ($result->revenue > 1) {
226 226
                     $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
227 227
                     $event_name = wp_trim_words($event_name, 5, '...');
228
-                    $revenue[]  = array($event_name, (float)$result->revenue);
228
+                    $revenue[]  = array($event_name, (float) $result->revenue);
229 229
                 }
230 230
             }
231 231
 
232 232
             //setup the date range.
233
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
233
+            $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
234 234
             $ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
235 235
             $subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
236 236
                 $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             'revenue'   => $revenue,
246 246
             'noResults' => empty($revenue),
247 247
             'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
248
-                '<h2>' . $report_title . '</h2><p>', '</p>')
248
+                '<h2>'.$report_title.'</h2><p>', '</p>')
249 249
         );
250 250
         wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
251 251
 
Please login to merge, or discard this patch.
caffeinated/EE_Caf_Messages.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      *
92 92
      * @param  array $dir_ref original array of paths
93 93
      *
94
-     * @return array           appended paths
94
+     * @return string[]           appended paths
95 95
      */
96 96
     public function messages_autoload_paths($dir_ref)
97 97
     {
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
      * @param EE_Question[]  $questions        An array of questions indexed by answer id.
702 702
      * @param EE_Answer[]    $answers          An array of answer objects
703 703
      * @param string         $template         Template content to be parsed.
704
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
704
+     * @param string[]          $valid_shortcodes Valid shortcodes for the template being parsed.
705 705
      * @param array          $extra_data       Extra data that might be used when parsing the template.
706 706
      */
707 707
     protected function _parse_question_list_for_primary_or_recipient_registration(
Please login to merge, or discard this patch.
Indentation   +714 added lines, -714 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since           4.3.2
8 8
  */
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 /**
@@ -22,735 +22,735 @@  discard block
 block discarded – undo
22 22
 {
23 23
     
24 24
     
25
-    /**
26
-     * constructor.
27
-     */
28
-    public function __construct()
29
-    {
30
-        $this->_caf_hooks();
31
-    }
32
-    
33
-    
34
-    /**
35
-     * Contains all the hooks filters for setting up caffeinated messages functionality.
36
-     *
37
-     * @since 4.3.2
38
-     *
39
-     * @return void
40
-     */
41
-    private function _caf_hooks()
42
-    {
43
-        add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
44
-        add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'),
45
-            5, 2);
46
-        add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5,
47
-            2);
48
-        add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5,
49
-            2);
50
-        add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5,
51
-            2);
52
-        add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
53
-        add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5,
54
-            2);
55
-        add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
56
-            array($this, 'new_default_templates'), 5, 7);
57
-        add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5,
58
-            2);
59
-        
60
-        //shortcode parsers
61
-        add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
62
-        add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
63
-        add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes',
64
-            array($this, 'additional_recipient_details_shortcodes'), 5, 2);
65
-        add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after',
66
-            array($this, 'additional_recipient_details_parser'), 5, 5);
67
-        add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
68
-            array($this, 'additional_primary_registration_details_shortcodes'), 5, 2);
69
-        add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
70
-            array($this, 'additional_primary_registration_details_parser'), 5, 5);
71
-        
72
-        /**
73
-         * @since 4.2.0
74
-         */
75
-        add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
76
-        add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
77
-        
78
-        /**
79
-         * @since 4.3.0
80
-         */
81
-        //eat our own dog food!
82
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
83
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
84
-        do_action('EE_Brewing_Regular___messages_caf');
85
-    }
86
-    
87
-    
88
-    /**
89
-     * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
90
-     * messages system.
91
-     *
92
-     * @param  array $dir_ref original array of paths
93
-     *
94
-     * @return array           appended paths
95
-     */
96
-    public function messages_autoload_paths($dir_ref)
97
-    {
98
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
99
-        
100
-        return $dir_ref;
101
-    }
102
-    
103
-    
104
-    public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
105
-    {
106
-        $validator_config['attendee_list'] = array(
107
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
108
-            'required'   => array('[ATTENDEE_LIST]')
109
-        );
110
-        $validator_config['question_list'] = array(
111
-            'shortcodes' => array('question'),
112
-            'required'   => array('[QUESTION_LIST]')
113
-        );
114
-        
115
-        return $validator_config;
116
-    }
117
-    
118
-    
119
-    public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
120
-    {
121
-        $validator_config['attendee_list'] = array(
122
-            'shortcodes' => array('attendee', 'question_list'),
123
-            'required'   => array('[ATTENDEE_LIST]')
124
-        );
125
-        $validator_config['question_list'] = array(
126
-            'shortcodes' => array('question'),
127
-            'required'   => array('[QUESTION_LIST]')
128
-        );
129
-        
130
-        return $validator_config;
131
-    }
132
-    
133
-    
134
-    public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
135
-    {
136
-        $validator_config['attendee_list'] = array(
137
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
138
-            'required'   => array('[ATTENDEE_LIST]')
139
-        );
140
-        $validator_config['question_list'] = array(
141
-            'shortcodes' => array('question'),
142
-            'required'   => array('[QUESTION_LIST]')
143
-        );
144
-        
145
-        return $validator_config;
146
-    }
147
-    
148
-    
149
-    public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
150
-    {
151
-        $template_fields['extra']['content']['question_list'] = array(
152
-            'input'               => 'textarea',
153
-            'label'               => '[QUESTION_LIST]',
154
-            'type'                => 'string',
155
-            'required'            => true,
156
-            'validation'          => true,
157
-            'format'              => '%s',
158
-            'css_class'           => 'large-text',
159
-            'rows'                => '5',
160
-            'shortcodes_required' => array('[QUESTION_LIST]')
161
-        );
162
-        
163
-        return $template_fields;
164
-    }
165
-    
166
-    
167
-    public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
168
-    {
169
-        $template_fields['extra']['content']['question_list'] = array(
170
-            'input'               => 'textarea',
171
-            'label'               => '[QUESTION_LIST]',
172
-            'type'                => 'string',
173
-            'required'            => true,
174
-            'validation'          => true,
175
-            'format'              => '%s',
176
-            'css_class'           => 'large-text',
177
-            'rows'                => '5',
178
-            'shortcodes_required' => array('[QUESTION_LIST]')
179
-        );
180
-        
181
-        return $template_fields;
182
-    }
183
-    
184
-    
185
-    public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
186
-    {
187
-        $template_fields['extra']['content']['question_list'] = array(
188
-            'input'               => 'textarea',
189
-            'label'               => '[QUESTION_LIST]',
190
-            'type'                => 'string',
191
-            'required'            => true,
192
-            'validation'          => true,
193
-            'format'              => '%s',
194
-            'css_class'           => 'large-text',
195
-            'rows'                => '5',
196
-            'shortcodes_required' => array('[QUESTION_LIST]')
197
-        );
198
-        
199
-        return $template_fields;
200
-    }
201
-    
202
-    
203
-    public function new_default_templates(
204
-        $contents,
205
-        $actual_path,
206
-        EE_messenger $messenger,
207
-        EE_message_type $message_type,
208
-        $field,
209
-        $context,
210
-        EE_Messages_Template_Pack $template_pack
211
-    ) {
212
-        
213
-        //we're only modifying templates for the default template pack
214
-        if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
215
-            return $contents;
216
-        }
217
-        
218
-        //the template file name we're replacing contents for.
219
-        $template_file_prefix = $field . '_' . $context;
220
-        $msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
221
-        
222
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
223
-        
224
-        if ($messenger->name == 'email' && $message_type->name == 'registration') {
25
+	/**
26
+	 * constructor.
27
+	 */
28
+	public function __construct()
29
+	{
30
+		$this->_caf_hooks();
31
+	}
32
+    
33
+    
34
+	/**
35
+	 * Contains all the hooks filters for setting up caffeinated messages functionality.
36
+	 *
37
+	 * @since 4.3.2
38
+	 *
39
+	 * @return void
40
+	 */
41
+	private function _caf_hooks()
42
+	{
43
+		add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
44
+		add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'),
45
+			5, 2);
46
+		add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5,
47
+			2);
48
+		add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5,
49
+			2);
50
+		add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5,
51
+			2);
52
+		add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
53
+		add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5,
54
+			2);
55
+		add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
56
+			array($this, 'new_default_templates'), 5, 7);
57
+		add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5,
58
+			2);
59
+        
60
+		//shortcode parsers
61
+		add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
62
+		add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
63
+		add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes',
64
+			array($this, 'additional_recipient_details_shortcodes'), 5, 2);
65
+		add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after',
66
+			array($this, 'additional_recipient_details_parser'), 5, 5);
67
+		add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
68
+			array($this, 'additional_primary_registration_details_shortcodes'), 5, 2);
69
+		add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
70
+			array($this, 'additional_primary_registration_details_parser'), 5, 5);
71
+        
72
+		/**
73
+		 * @since 4.2.0
74
+		 */
75
+		add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
76
+		add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
77
+        
78
+		/**
79
+		 * @since 4.3.0
80
+		 */
81
+		//eat our own dog food!
82
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
83
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
84
+		do_action('EE_Brewing_Regular___messages_caf');
85
+	}
86
+    
87
+    
88
+	/**
89
+	 * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
90
+	 * messages system.
91
+	 *
92
+	 * @param  array $dir_ref original array of paths
93
+	 *
94
+	 * @return array           appended paths
95
+	 */
96
+	public function messages_autoload_paths($dir_ref)
97
+	{
98
+		$dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
99
+        
100
+		return $dir_ref;
101
+	}
102
+    
103
+    
104
+	public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
105
+	{
106
+		$validator_config['attendee_list'] = array(
107
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
108
+			'required'   => array('[ATTENDEE_LIST]')
109
+		);
110
+		$validator_config['question_list'] = array(
111
+			'shortcodes' => array('question'),
112
+			'required'   => array('[QUESTION_LIST]')
113
+		);
114
+        
115
+		return $validator_config;
116
+	}
117
+    
118
+    
119
+	public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
120
+	{
121
+		$validator_config['attendee_list'] = array(
122
+			'shortcodes' => array('attendee', 'question_list'),
123
+			'required'   => array('[ATTENDEE_LIST]')
124
+		);
125
+		$validator_config['question_list'] = array(
126
+			'shortcodes' => array('question'),
127
+			'required'   => array('[QUESTION_LIST]')
128
+		);
129
+        
130
+		return $validator_config;
131
+	}
132
+    
133
+    
134
+	public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
135
+	{
136
+		$validator_config['attendee_list'] = array(
137
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
138
+			'required'   => array('[ATTENDEE_LIST]')
139
+		);
140
+		$validator_config['question_list'] = array(
141
+			'shortcodes' => array('question'),
142
+			'required'   => array('[QUESTION_LIST]')
143
+		);
144
+        
145
+		return $validator_config;
146
+	}
147
+    
148
+    
149
+	public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
150
+	{
151
+		$template_fields['extra']['content']['question_list'] = array(
152
+			'input'               => 'textarea',
153
+			'label'               => '[QUESTION_LIST]',
154
+			'type'                => 'string',
155
+			'required'            => true,
156
+			'validation'          => true,
157
+			'format'              => '%s',
158
+			'css_class'           => 'large-text',
159
+			'rows'                => '5',
160
+			'shortcodes_required' => array('[QUESTION_LIST]')
161
+		);
162
+        
163
+		return $template_fields;
164
+	}
165
+    
166
+    
167
+	public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
168
+	{
169
+		$template_fields['extra']['content']['question_list'] = array(
170
+			'input'               => 'textarea',
171
+			'label'               => '[QUESTION_LIST]',
172
+			'type'                => 'string',
173
+			'required'            => true,
174
+			'validation'          => true,
175
+			'format'              => '%s',
176
+			'css_class'           => 'large-text',
177
+			'rows'                => '5',
178
+			'shortcodes_required' => array('[QUESTION_LIST]')
179
+		);
180
+        
181
+		return $template_fields;
182
+	}
183
+    
184
+    
185
+	public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
186
+	{
187
+		$template_fields['extra']['content']['question_list'] = array(
188
+			'input'               => 'textarea',
189
+			'label'               => '[QUESTION_LIST]',
190
+			'type'                => 'string',
191
+			'required'            => true,
192
+			'validation'          => true,
193
+			'format'              => '%s',
194
+			'css_class'           => 'large-text',
195
+			'rows'                => '5',
196
+			'shortcodes_required' => array('[QUESTION_LIST]')
197
+		);
198
+        
199
+		return $template_fields;
200
+	}
201
+    
202
+    
203
+	public function new_default_templates(
204
+		$contents,
205
+		$actual_path,
206
+		EE_messenger $messenger,
207
+		EE_message_type $message_type,
208
+		$field,
209
+		$context,
210
+		EE_Messages_Template_Pack $template_pack
211
+	) {
212
+        
213
+		//we're only modifying templates for the default template pack
214
+		if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
215
+			return $contents;
216
+		}
217
+        
218
+		//the template file name we're replacing contents for.
219
+		$template_file_prefix = $field . '_' . $context;
220
+		$msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
221
+        
222
+		$base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
223
+        
224
+		if ($messenger->name == 'email' && $message_type->name == 'registration') {
225 225
             
226
-            switch ($template_file_prefix) {
226
+			switch ($template_file_prefix) {
227 227
                 
228
-                case 'question_list_admin' :
229
-                case 'question_list_attendee' :
230
-                case 'question_list_primary_attendee' :
231
-                    $path     = $base_path . $msg_prefix . 'question_list.template.php';
232
-                    $contents = EEH_Template::display_template($path, array(), true);
233
-                    break;
228
+				case 'question_list_admin' :
229
+				case 'question_list_attendee' :
230
+				case 'question_list_primary_attendee' :
231
+					$path     = $base_path . $msg_prefix . 'question_list.template.php';
232
+					$contents = EEH_Template::display_template($path, array(), true);
233
+					break;
234 234
                 
235
-                case 'attendee_list_primary_attendee' :
236
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
237
-                    $contents = EEH_Template::display_template($path, array(), true);
238
-                    break;
235
+				case 'attendee_list_primary_attendee' :
236
+					$path     = $base_path . $msg_prefix . 'attendee_list.template.php';
237
+					$contents = EEH_Template::display_template($path, array(), true);
238
+					break;
239 239
                 
240
-                case 'attendee_list_admin' :
241
-                    $path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
242
-                    $contents = EEH_Template::display_template($path,
243
-                        array(), true);
244
-                    break;
240
+				case 'attendee_list_admin' :
241
+					$path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
242
+					$contents = EEH_Template::display_template($path,
243
+						array(), true);
244
+					break;
245 245
                 
246
-                case 'attendee_list_attendee' :
247
-                    $contents = '';
248
-                    break;
246
+				case 'attendee_list_attendee' :
247
+					$contents = '';
248
+					break;
249 249
                 
250
-                case 'event_list_attendee' :
251
-                    $path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
252
-                    $contents = EEH_Template::display_template($path, array(), true);
253
-                    break;
254
-            }
255
-        } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
256
-            switch ($template_file_prefix) {
250
+				case 'event_list_attendee' :
251
+					$path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
252
+					$contents = EEH_Template::display_template($path, array(), true);
253
+					break;
254
+			}
255
+		} elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
256
+			switch ($template_file_prefix) {
257 257
                 
258
-                case 'content_attendee' :
259
-                    $path     = $base_path . $msg_prefix . 'content.template.php';
260
-                    $contents = EEH_Template::display_template($path, array(), true);
261
-                    break;
258
+				case 'content_attendee' :
259
+					$path     = $base_path . $msg_prefix . 'content.template.php';
260
+					$contents = EEH_Template::display_template($path, array(), true);
261
+					break;
262 262
                 
263
-                case 'newsletter_content_attendee' :
264
-                    $path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
265
-                    $contents = EEH_Template::display_template($path, array(), true);
266
-                    break;
263
+				case 'newsletter_content_attendee' :
264
+					$path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
265
+					$contents = EEH_Template::display_template($path, array(), true);
266
+					break;
267 267
                 
268
-                case 'newsletter_subject_attendee' :
269
-                    $path     = $base_path . $msg_prefix . 'subject.template.php';
270
-                    $contents = EEH_Template::display_template($path, array(), true);
271
-                    break;
272
-            }
273
-        } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274
-            switch ($template_file_prefix) {
275
-                case 'attendee_list_purchaser' :
276
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
277
-                    $contents = EEH_Template::display_template($path, array(), true);
278
-                    break;
279
-            }
280
-        }
281
-        
282
-        return $contents;
283
-        
284
-    }
285
-    
286
-    
287
-    public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
288
-    {
289
-        //make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
290
-        $include_with = array(
291
-            'registration',
292
-            'cancelled_registration',
293
-            'declined_registration',
294
-            'not_approved_registration',
295
-            'payment_declined',
296
-            'payment_failed',
297
-            'payment_cancelled',
298
-            'payment',
299
-            'payment_reminder',
300
-            'pending_approval',
301
-            'registration_summary',
302
-            'invoice',
303
-            'receipt'
304
-        );
305
-        if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
306
-            $contexts = array_keys($msg->get_contexts());
307
-            foreach ($contexts as $context) {
308
-                $valid_shortcodes[$context][] = 'question_list';
309
-                $valid_shortcodes[$context][] = 'question';
310
-            }
311
-        }
312
-        
313
-        return $valid_shortcodes;
314
-    }
315
-    
316
-    
317
-    public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
318
-    {
319
-        $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
320
-            'event_espresso');
321
-        
322
-        return $shortcodes;
323
-    }
324
-    
325
-    
326
-    public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
327
-    {
328
-        
329
-        if (strpos($shortcode,
330
-                '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations)
331
-        ) {
332
-            return $parsed;
333
-        }
334
-        
335
-        //let's get the question from the code.
336
-        $shortcode = str_replace('[ANSWER_*', '', $shortcode);
337
-        $shortcode = trim(str_replace(']', '', $shortcode));
338
-        
339
-        $registration = $data instanceof EE_Registration ? $data : null;
340
-        $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
341
-        
342
-        $aee = $data instanceof EE_Messages_Addressee ? $data : null;
343
-        $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
344
-        
345
-        if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
346
-            return $parsed;
347
-        }
348
-        
349
-        //now let's figure out which question has this text.
350
-        foreach ($aee->questions as $ansid => $question) {
351
-            if (
352
-                $question instanceof EE_Question
353
-                && trim($question->display_text()) == trim($shortcode)
354
-                && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
355
-            ) {
356
-                return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value',
357
-                    'no_wpautop');
358
-            }
359
-        }
360
-        
361
-        //nothing!
362
-        return $parsed;
363
-    }
364
-    
365
-    
366
-    /**
367
-     * Callback for additional shortcodes filter for adding additional datetime shortcodes.
368
-     *
369
-     * @since  4.2
370
-     *
371
-     * @param  array                  $shortcodes         array of shortcodes and
372
-     *                                                    descriptions
373
-     * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
374
-     *
375
-     * @return array                                        array of shortcodes and
376
-     *                                                        descriptions
377
-     */
378
-    public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
379
-    {
380
-        $shortcodes['[DTT_NAME]']          = __('This will be parsed to the Title given for a Datetime',
381
-            'event_espresso');
382
-        $shortcodes['[DTT_DESCRIPTION]']   = __('This will be parsed to the description for a Datetime',
383
-            'event_espresso');
384
-        $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
385
-            'event_espresso');
386
-        
387
-        return $shortcodes;
388
-    }
389
-    
390
-    
391
-    /**
392
-     * Callback for additional shortcodes parser filter used for adding parser for new
393
-     * Datetime shortcodes
394
-     *
395
-     * @since  4.2
396
-     *
397
-     * @param  string                 $parsed     The finished parsed string for the given shortcode.
398
-     * @param  string                 $shortcode  The shortcode being parsed.
399
-     * @param  object                 $data       The incoming data object for the Shortcode Parser.
400
-     * @param  object                 $extra_data The incoming extra date object for the Shortcode
401
-     *                                            Parser.
402
-     * @param  EE_Datetime_Shortcodes $shortcode_parser
403
-     *
404
-     * @return string                   The new parsed string.
405
-     */
406
-    public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
407
-    {
408
-        
409
-        if ( ! $data instanceof EE_Datetime) {
410
-            return ''; //get out because we can only parse with the datetime object.
411
-        }
412
-        
413
-        switch ($shortcode) {
414
-            case '[DTT_NAME]' :
415
-                return $data->name();
416
-                break;
417
-            case '[DTT_DESCRIPTION]' :
418
-                return $data->description();
419
-                break;
420
-            case '[DTT_NAME_OR_DATES]' :
421
-                return $data->get_dtt_display_name(true);
422
-                break;
423
-            default :
424
-                return $parsed;
425
-                break;
426
-        }
427
-    }
428
-    
429
-    
430
-    public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
431
-    {
432
-        $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
433
-            'event_espresso');
434
-        
435
-        return $shortcodes;
436
-    }
437
-    
438
-    
439
-    /**
440
-     * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
441
-     *
442
-     * @param string         $parsed           The original parsed content for the shortcode
443
-     * @param string         $shortcode        The shortcode being parsed
444
-     * @param array          $data             The shortcode parser data array
445
-     * @param array          $extra_data       The shortcode parser extra data array
446
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
447
-     *
448
-     * @return string
449
-     */
450
-    public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
451
-    {
452
-        
453
-        if (array($data) && ! isset($data['data'])) {
454
-            return $parsed;
455
-        }
456
-        
457
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
458
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
459
-        
460
-        if ( ! $recipient instanceof EE_Messages_Addressee) {
461
-            return $parsed;
462
-        }
463
-        
464
-        switch ($shortcode) {
465
-            case '[RECIPIENT_QUESTION_LIST]' :
466
-                $att                       = $recipient->att_obj;
467
-                $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array();
468
-                $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
469
-                $answers                   = array();
268
+				case 'newsletter_subject_attendee' :
269
+					$path     = $base_path . $msg_prefix . 'subject.template.php';
270
+					$contents = EEH_Template::display_template($path, array(), true);
271
+					break;
272
+			}
273
+		} elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274
+			switch ($template_file_prefix) {
275
+				case 'attendee_list_purchaser' :
276
+					$path     = $base_path . $msg_prefix . 'attendee_list.template.php';
277
+					$contents = EEH_Template::display_template($path, array(), true);
278
+					break;
279
+			}
280
+		}
281
+        
282
+		return $contents;
283
+        
284
+	}
285
+    
286
+    
287
+	public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
288
+	{
289
+		//make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
290
+		$include_with = array(
291
+			'registration',
292
+			'cancelled_registration',
293
+			'declined_registration',
294
+			'not_approved_registration',
295
+			'payment_declined',
296
+			'payment_failed',
297
+			'payment_cancelled',
298
+			'payment',
299
+			'payment_reminder',
300
+			'pending_approval',
301
+			'registration_summary',
302
+			'invoice',
303
+			'receipt'
304
+		);
305
+		if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
306
+			$contexts = array_keys($msg->get_contexts());
307
+			foreach ($contexts as $context) {
308
+				$valid_shortcodes[$context][] = 'question_list';
309
+				$valid_shortcodes[$context][] = 'question';
310
+			}
311
+		}
312
+        
313
+		return $valid_shortcodes;
314
+	}
315
+    
316
+    
317
+	public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
318
+	{
319
+		$shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
320
+			'event_espresso');
321
+        
322
+		return $shortcodes;
323
+	}
324
+    
325
+    
326
+	public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
327
+	{
328
+        
329
+		if (strpos($shortcode,
330
+				'[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations)
331
+		) {
332
+			return $parsed;
333
+		}
334
+        
335
+		//let's get the question from the code.
336
+		$shortcode = str_replace('[ANSWER_*', '', $shortcode);
337
+		$shortcode = trim(str_replace(']', '', $shortcode));
338
+        
339
+		$registration = $data instanceof EE_Registration ? $data : null;
340
+		$registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
341
+        
342
+		$aee = $data instanceof EE_Messages_Addressee ? $data : null;
343
+		$aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
344
+        
345
+		if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
346
+			return $parsed;
347
+		}
348
+        
349
+		//now let's figure out which question has this text.
350
+		foreach ($aee->questions as $ansid => $question) {
351
+			if (
352
+				$question instanceof EE_Question
353
+				&& trim($question->display_text()) == trim($shortcode)
354
+				&& isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
355
+			) {
356
+				return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value',
357
+					'no_wpautop');
358
+			}
359
+		}
360
+        
361
+		//nothing!
362
+		return $parsed;
363
+	}
364
+    
365
+    
366
+	/**
367
+	 * Callback for additional shortcodes filter for adding additional datetime shortcodes.
368
+	 *
369
+	 * @since  4.2
370
+	 *
371
+	 * @param  array                  $shortcodes         array of shortcodes and
372
+	 *                                                    descriptions
373
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
374
+	 *
375
+	 * @return array                                        array of shortcodes and
376
+	 *                                                        descriptions
377
+	 */
378
+	public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
379
+	{
380
+		$shortcodes['[DTT_NAME]']          = __('This will be parsed to the Title given for a Datetime',
381
+			'event_espresso');
382
+		$shortcodes['[DTT_DESCRIPTION]']   = __('This will be parsed to the description for a Datetime',
383
+			'event_espresso');
384
+		$shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
385
+			'event_espresso');
386
+        
387
+		return $shortcodes;
388
+	}
389
+    
390
+    
391
+	/**
392
+	 * Callback for additional shortcodes parser filter used for adding parser for new
393
+	 * Datetime shortcodes
394
+	 *
395
+	 * @since  4.2
396
+	 *
397
+	 * @param  string                 $parsed     The finished parsed string for the given shortcode.
398
+	 * @param  string                 $shortcode  The shortcode being parsed.
399
+	 * @param  object                 $data       The incoming data object for the Shortcode Parser.
400
+	 * @param  object                 $extra_data The incoming extra date object for the Shortcode
401
+	 *                                            Parser.
402
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser
403
+	 *
404
+	 * @return string                   The new parsed string.
405
+	 */
406
+	public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
407
+	{
408
+        
409
+		if ( ! $data instanceof EE_Datetime) {
410
+			return ''; //get out because we can only parse with the datetime object.
411
+		}
412
+        
413
+		switch ($shortcode) {
414
+			case '[DTT_NAME]' :
415
+				return $data->name();
416
+				break;
417
+			case '[DTT_DESCRIPTION]' :
418
+				return $data->description();
419
+				break;
420
+			case '[DTT_NAME_OR_DATES]' :
421
+				return $data->get_dtt_display_name(true);
422
+				break;
423
+			default :
424
+				return $parsed;
425
+				break;
426
+		}
427
+	}
428
+    
429
+    
430
+	public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
431
+	{
432
+		$shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
433
+			'event_espresso');
434
+        
435
+		return $shortcodes;
436
+	}
437
+    
438
+    
439
+	/**
440
+	 * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
441
+	 *
442
+	 * @param string         $parsed           The original parsed content for the shortcode
443
+	 * @param string         $shortcode        The shortcode being parsed
444
+	 * @param array          $data             The shortcode parser data array
445
+	 * @param array          $extra_data       The shortcode parser extra data array
446
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
447
+	 *
448
+	 * @return string
449
+	 */
450
+	public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
451
+	{
452
+        
453
+		if (array($data) && ! isset($data['data'])) {
454
+			return $parsed;
455
+		}
456
+        
457
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
458
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
459
+        
460
+		if ( ! $recipient instanceof EE_Messages_Addressee) {
461
+			return $parsed;
462
+		}
463
+        
464
+		switch ($shortcode) {
465
+			case '[RECIPIENT_QUESTION_LIST]' :
466
+				$att                       = $recipient->att_obj;
467
+				$registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array();
468
+				$registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
469
+				$answers                   = array();
470 470
                 
471
-                $template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
472
-                $valid_shortcodes = array('question');
471
+				$template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
472
+				$valid_shortcodes = array('question');
473 473
                 
474
-                //if the context is main_content then get all answers for all registrations on this attendee
475
-                if ($data['data'] instanceof EE_Messages_Addressee) {
474
+				//if the context is main_content then get all answers for all registrations on this attendee
475
+				if ($data['data'] instanceof EE_Messages_Addressee) {
476 476
                     
477
-                    foreach ($registrations_on_attendee as $reg) {
478
-                        if ($reg instanceof EE_Registration) {
479
-                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
480
-                            foreach ($anss as $ans) {
481
-                                if ($ans instanceof EE_Answer) {
482
-                                    $answers[$ans->ID()] = $ans;
483
-                                }
484
-                            }
485
-                        }
486
-                    }
487
-                }
477
+					foreach ($registrations_on_attendee as $reg) {
478
+						if ($reg instanceof EE_Registration) {
479
+							$anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
480
+							foreach ($anss as $ans) {
481
+								if ($ans instanceof EE_Answer) {
482
+									$answers[$ans->ID()] = $ans;
483
+								}
484
+							}
485
+						}
486
+					}
487
+				}
488 488
                 
489
-                //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
490
-                if ($data['data'] instanceof EE_Event) {
491
-                    $event = $data['data'];
492
-                    foreach ($registrations_on_attendee as $reg) {
493
-                        if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
494
-                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
495
-                            foreach ($anss as $ans) {
496
-                                if ($ans instanceof EE_Answer) {
497
-                                    $answers[$ans->ID()] = $ans;
498
-                                }
499
-                            }
500
-                        }
501
-                    }
502
-                }
489
+				//if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
490
+				if ($data['data'] instanceof EE_Event) {
491
+					$event = $data['data'];
492
+					foreach ($registrations_on_attendee as $reg) {
493
+						if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
494
+							$anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
495
+							foreach ($anss as $ans) {
496
+								if ($ans instanceof EE_Answer) {
497
+									$answers[$ans->ID()] = $ans;
498
+								}
499
+							}
500
+						}
501
+					}
502
+				}
503 503
                 
504
-                $questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
504
+				$questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
505 505
                 
506
-                //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507
-                //object on it.
508
-                if ( ! isset( $extra_data['data'] ) ) {
509
-                    $extra_data['data'] = $recipient;
510
-                }
506
+				//if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507
+				//object on it.
508
+				if ( ! isset( $extra_data['data'] ) ) {
509
+					$extra_data['data'] = $recipient;
510
+				}
511 511
                 
512
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
513
-                    $shortcode_parser,
514
-                    $questions,
515
-                    $answers,
516
-                    $template,
517
-                    $valid_shortcodes,
518
-                    $extra_data
519
-                );
520
-                break;
512
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
513
+					$shortcode_parser,
514
+					$questions,
515
+					$answers,
516
+					$template,
517
+					$valid_shortcodes,
518
+					$extra_data
519
+				);
520
+				break;
521 521
             
522
-            default :
523
-                return $parsed;
524
-                break;
525
-        }
526
-    }
527
-    
528
-    
529
-    public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
530
-    {
531
-        $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
532
-            'event_espresso');
533
-        
534
-        return $shortcodes;
535
-    }
536
-    
537
-    
538
-    /**
539
-     * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
540
-     *
541
-     * @param string         $parsed           The original parsed content for the shortcode
542
-     * @param string         $shortcode        The shortcode being parsed
543
-     * @param array          $data             The shortcode parser data array
544
-     * @param array          $extra_data       The shortcode parser extra data array
545
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
546
-     *
547
-     * @return string
548
-     */
549
-    public function additional_primary_registration_details_parser(
550
-        $parsed,
551
-        $shortcode,
552
-        $data,
553
-        $extra_data,
554
-        $shortcode_parser
555
-    ) {
556
-        if (array($data) && ! isset($data['data'])) {
557
-            return $parsed;
558
-        }
559
-        
560
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
561
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
562
-        
563
-        if ( ! $recipient instanceof EE_Messages_Addressee) {
564
-            return $parsed;
565
-        }
566
-        
567
-        switch ($shortcode) {
568
-            case '[PRIMARY_REGISTRANT_QUESTION_LIST]' :
569
-                if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
570
-                    return '';
571
-                }
572
-                $registration     = $recipient->primary_reg_obj;
573
-                $answers = isset($recipient->registrations[$registration->ID()]['ans_objs'])
574
-                    ? $recipient->registrations[$registration->ID()]['ans_objs']
575
-                    : array();
576
-                if (empty($answers)) {
577
-                    return '';
578
-                }
579
-                $template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
580
-                $valid_shortcodes = array('question');
581
-                $answers          = $recipient->registrations[$registration->ID()]['ans_objs'];
582
-                $questions = isset($recipient->questions) ? $recipient->questions : array();
583
-                //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
584
-                //object on it.
585
-                if ( ! isset( $extra_data['data'] ) ){
586
-                    $extra_data['data'] = $recipient;
587
-                }
588
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
589
-                    $shortcode_parser,
590
-                    $questions,
591
-                    $answers,
592
-                    $template,
593
-                    $valid_shortcodes,
594
-                    $extra_data
595
-                );
596
-                break;
522
+			default :
523
+				return $parsed;
524
+				break;
525
+		}
526
+	}
527
+    
528
+    
529
+	public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
530
+	{
531
+		$shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
532
+			'event_espresso');
533
+        
534
+		return $shortcodes;
535
+	}
536
+    
537
+    
538
+	/**
539
+	 * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
540
+	 *
541
+	 * @param string         $parsed           The original parsed content for the shortcode
542
+	 * @param string         $shortcode        The shortcode being parsed
543
+	 * @param array          $data             The shortcode parser data array
544
+	 * @param array          $extra_data       The shortcode parser extra data array
545
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
546
+	 *
547
+	 * @return string
548
+	 */
549
+	public function additional_primary_registration_details_parser(
550
+		$parsed,
551
+		$shortcode,
552
+		$data,
553
+		$extra_data,
554
+		$shortcode_parser
555
+	) {
556
+		if (array($data) && ! isset($data['data'])) {
557
+			return $parsed;
558
+		}
559
+        
560
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
561
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
562
+        
563
+		if ( ! $recipient instanceof EE_Messages_Addressee) {
564
+			return $parsed;
565
+		}
566
+        
567
+		switch ($shortcode) {
568
+			case '[PRIMARY_REGISTRANT_QUESTION_LIST]' :
569
+				if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
570
+					return '';
571
+				}
572
+				$registration     = $recipient->primary_reg_obj;
573
+				$answers = isset($recipient->registrations[$registration->ID()]['ans_objs'])
574
+					? $recipient->registrations[$registration->ID()]['ans_objs']
575
+					: array();
576
+				if (empty($answers)) {
577
+					return '';
578
+				}
579
+				$template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
580
+				$valid_shortcodes = array('question');
581
+				$answers          = $recipient->registrations[$registration->ID()]['ans_objs'];
582
+				$questions = isset($recipient->questions) ? $recipient->questions : array();
583
+				//if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
584
+				//object on it.
585
+				if ( ! isset( $extra_data['data'] ) ){
586
+					$extra_data['data'] = $recipient;
587
+				}
588
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
589
+					$shortcode_parser,
590
+					$questions,
591
+					$answers,
592
+					$template,
593
+					$valid_shortcodes,
594
+					$extra_data
595
+				);
596
+				break;
597 597
             
598
-            default :
599
-                return $parsed;
600
-                break;
601
-        }
602
-    }
603
-    
604
-    
605
-    /**
606
-     * Takes care of registering the  message types that are only available in caffeinated EE.
607
-     *
608
-     * @since   4.3.2
609
-     *
610
-     * @return  void
611
-     */
612
-    public function register_caf_message_types()
613
-    {
614
-        //register newsletter message type
615
-        $setup_args = array(
616
-            'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
617
-            'autoloadpaths'               => array(
618
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
619
-            ),
620
-            'messengers_to_activate_with' => array('email'),
621
-            'messengers_to_validate_with' => array('email'),
622
-            'messengers_supporting_default_template_pack_with' => array('email')
623
-        );
624
-        EE_Register_Message_Type::register('newsletter', $setup_args);
625
-        
626
-        //register payment reminder message type
627
-        $setup_args = array(
628
-            'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
629
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
630
-            'messengers_to_activate_with' => array('email'),
631
-            'messengers_to_validate_with' => array('email'),
632
-            'messengers_supporting_default_template_pack_with' => array('email')
633
-        );
634
-        EE_Register_Message_Type::register('payment_reminder', $setup_args);
635
-        
636
-        //register payment declined message type
637
-        $setup_args = array(
638
-            'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
639
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
640
-            'messengers_to_activate_with' => array('email'),
641
-            'messengers_to_validate_with' => array('email'),
642
-            'messengers_supporting_default_template_pack_with' => array('email')
643
-        );
644
-        EE_Register_Message_Type::register('payment_declined', $setup_args);
645
-        
646
-        //register registration declined message type
647
-        $setup_args = array(
648
-            'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
649
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
650
-            'messengers_to_activate_with' => array('email'),
651
-            'messengers_to_validate_with' => array('email'),
652
-            'messengers_supporting_default_template_pack_with' => array('email')
653
-        );
654
-        EE_Register_Message_Type::register('declined_registration', $setup_args);
655
-        
656
-        //register registration cancelled message type
657
-        $setup_args = array(
658
-            'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
659
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
660
-            'messengers_to_activate_with' => array('email'),
661
-            'messengers_to_validate_with' => array('email'),
662
-            'messengers_supporting_default_template_pack_with' => array('email')
663
-        );
664
-        EE_Register_Message_Type::register('cancelled_registration', $setup_args);
665
-        
666
-        
667
-        //register payment failed message type
668
-        $setup_args = array(
669
-            'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
670
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
671
-            'messengers_to_activate_with' => array('email'),
672
-            'messengers_to_validate_with' => array('email'),
673
-            'messengers_supporting_default_template_pack_with' => array('email')
674
-        );
675
-        EE_Register_Message_Type::register('payment_failed', $setup_args);
676
-        
677
-        //register payment declined message type
678
-        $setup_args = array(
679
-            'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
680
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
681
-            'messengers_to_activate_with' => array('email'),
682
-            'messengers_to_validate_with' => array('email'),
683
-            'messengers_supporting_default_template_pack_with' => array('email')
684
-        );
685
-        EE_Register_Message_Type::register('payment_cancelled', $setup_args);
686
-    }
687
-    
688
-    
689
-    /**
690
-     * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
691
-     *
692
-     * @since   4.3.2
693
-     *
694
-     * @return void
695
-     */
696
-    public function register_caf_shortcodes()
697
-    {
698
-        $setup_args = array(
699
-            'autoloadpaths'                 => array(
700
-                EE_CAF_LIBRARIES . 'shortcodes/'
701
-            ),
702
-            'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
703
-            'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
704
-            'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]')
705
-        );
706
-        EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
707
-    }
708
-    
709
-    
710
-    /**
711
-     * Parses a question list shortcode using given data and template
712
-     *
713
-     * @param \EE_Shortcodes $shortcode_parser
714
-     * @param EE_Question[]  $questions        An array of questions indexed by answer id.
715
-     * @param EE_Answer[]    $answers          An array of answer objects
716
-     * @param string         $template         Template content to be parsed.
717
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
718
-     * @param array          $extra_data       Extra data that might be used when parsing the template.
719
-     */
720
-    protected function _parse_question_list_for_primary_or_recipient_registration(
721
-        $shortcode_parser,
722
-        $questions,
723
-        $answers,
724
-        $template,
725
-        $valid_shortcodes,
726
-        $extra_data
727
-    ) {
728
-        $question_list = '';
729
-        /** @var EEH_Parse_Shortcodes $shortcode_helper */
730
-        $shortcode_helper = $shortcode_parser->get_shortcode_helper();
731
-        foreach ($answers as $answer) {
732
-            if ($answer instanceof EE_Answer) {
733
-                //first see if the question is in our $questions array. If not then try to get from answer object.
734
-                $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
735
-                $question = ! $question instanceof EE_Question ? $answer->question() : $question;
736
-                if (
737
-                    ! $question instanceof EE_Question
738
-                    || (
739
-                        $question instanceof EE_Question
740
-                        && $question->admin_only()
741
-                    )
742
-                ) {
743
-                    continue;
744
-                }
745
-                $question_list .= $shortcode_helper->parse_question_list_template(
746
-                    $template,
747
-                    $answer,
748
-                    $valid_shortcodes,
749
-                    $extra_data
750
-                );
751
-            }
752
-        }
753
-        
754
-        return $question_list;
755
-    }
598
+			default :
599
+				return $parsed;
600
+				break;
601
+		}
602
+	}
603
+    
604
+    
605
+	/**
606
+	 * Takes care of registering the  message types that are only available in caffeinated EE.
607
+	 *
608
+	 * @since   4.3.2
609
+	 *
610
+	 * @return  void
611
+	 */
612
+	public function register_caf_message_types()
613
+	{
614
+		//register newsletter message type
615
+		$setup_args = array(
616
+			'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
617
+			'autoloadpaths'               => array(
618
+				EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
619
+			),
620
+			'messengers_to_activate_with' => array('email'),
621
+			'messengers_to_validate_with' => array('email'),
622
+			'messengers_supporting_default_template_pack_with' => array('email')
623
+		);
624
+		EE_Register_Message_Type::register('newsletter', $setup_args);
625
+        
626
+		//register payment reminder message type
627
+		$setup_args = array(
628
+			'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
629
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
630
+			'messengers_to_activate_with' => array('email'),
631
+			'messengers_to_validate_with' => array('email'),
632
+			'messengers_supporting_default_template_pack_with' => array('email')
633
+		);
634
+		EE_Register_Message_Type::register('payment_reminder', $setup_args);
635
+        
636
+		//register payment declined message type
637
+		$setup_args = array(
638
+			'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
639
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
640
+			'messengers_to_activate_with' => array('email'),
641
+			'messengers_to_validate_with' => array('email'),
642
+			'messengers_supporting_default_template_pack_with' => array('email')
643
+		);
644
+		EE_Register_Message_Type::register('payment_declined', $setup_args);
645
+        
646
+		//register registration declined message type
647
+		$setup_args = array(
648
+			'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
649
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
650
+			'messengers_to_activate_with' => array('email'),
651
+			'messengers_to_validate_with' => array('email'),
652
+			'messengers_supporting_default_template_pack_with' => array('email')
653
+		);
654
+		EE_Register_Message_Type::register('declined_registration', $setup_args);
655
+        
656
+		//register registration cancelled message type
657
+		$setup_args = array(
658
+			'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
659
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
660
+			'messengers_to_activate_with' => array('email'),
661
+			'messengers_to_validate_with' => array('email'),
662
+			'messengers_supporting_default_template_pack_with' => array('email')
663
+		);
664
+		EE_Register_Message_Type::register('cancelled_registration', $setup_args);
665
+        
666
+        
667
+		//register payment failed message type
668
+		$setup_args = array(
669
+			'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
670
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
671
+			'messengers_to_activate_with' => array('email'),
672
+			'messengers_to_validate_with' => array('email'),
673
+			'messengers_supporting_default_template_pack_with' => array('email')
674
+		);
675
+		EE_Register_Message_Type::register('payment_failed', $setup_args);
676
+        
677
+		//register payment declined message type
678
+		$setup_args = array(
679
+			'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
680
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
681
+			'messengers_to_activate_with' => array('email'),
682
+			'messengers_to_validate_with' => array('email'),
683
+			'messengers_supporting_default_template_pack_with' => array('email')
684
+		);
685
+		EE_Register_Message_Type::register('payment_cancelled', $setup_args);
686
+	}
687
+    
688
+    
689
+	/**
690
+	 * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
691
+	 *
692
+	 * @since   4.3.2
693
+	 *
694
+	 * @return void
695
+	 */
696
+	public function register_caf_shortcodes()
697
+	{
698
+		$setup_args = array(
699
+			'autoloadpaths'                 => array(
700
+				EE_CAF_LIBRARIES . 'shortcodes/'
701
+			),
702
+			'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
703
+			'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
704
+			'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]')
705
+		);
706
+		EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
707
+	}
708
+    
709
+    
710
+	/**
711
+	 * Parses a question list shortcode using given data and template
712
+	 *
713
+	 * @param \EE_Shortcodes $shortcode_parser
714
+	 * @param EE_Question[]  $questions        An array of questions indexed by answer id.
715
+	 * @param EE_Answer[]    $answers          An array of answer objects
716
+	 * @param string         $template         Template content to be parsed.
717
+	 * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
718
+	 * @param array          $extra_data       Extra data that might be used when parsing the template.
719
+	 */
720
+	protected function _parse_question_list_for_primary_or_recipient_registration(
721
+		$shortcode_parser,
722
+		$questions,
723
+		$answers,
724
+		$template,
725
+		$valid_shortcodes,
726
+		$extra_data
727
+	) {
728
+		$question_list = '';
729
+		/** @var EEH_Parse_Shortcodes $shortcode_helper */
730
+		$shortcode_helper = $shortcode_parser->get_shortcode_helper();
731
+		foreach ($answers as $answer) {
732
+			if ($answer instanceof EE_Answer) {
733
+				//first see if the question is in our $questions array. If not then try to get from answer object.
734
+				$question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
735
+				$question = ! $question instanceof EE_Question ? $answer->question() : $question;
736
+				if (
737
+					! $question instanceof EE_Question
738
+					|| (
739
+						$question instanceof EE_Question
740
+						&& $question->admin_only()
741
+					)
742
+				) {
743
+					continue;
744
+				}
745
+				$question_list .= $shortcode_helper->parse_question_list_template(
746
+					$template,
747
+					$answer,
748
+					$valid_shortcodes,
749
+					$extra_data
750
+				);
751
+			}
752
+		}
753
+        
754
+		return $question_list;
755
+	}
756 756
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function messages_autoload_paths($dir_ref)
97 97
     {
98
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
98
+        $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/';
99 99
         
100 100
         return $dir_ref;
101 101
     }
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
         }
217 217
         
218 218
         //the template file name we're replacing contents for.
219
-        $template_file_prefix = $field . '_' . $context;
220
-        $msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
219
+        $template_file_prefix = $field.'_'.$context;
220
+        $msg_prefix           = $messenger->name.'_'.$message_type->name.'_';
221 221
         
222
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
222
+        $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/';
223 223
         
224 224
         if ($messenger->name == 'email' && $message_type->name == 'registration') {
225 225
             
@@ -228,17 +228,17 @@  discard block
 block discarded – undo
228 228
                 case 'question_list_admin' :
229 229
                 case 'question_list_attendee' :
230 230
                 case 'question_list_primary_attendee' :
231
-                    $path     = $base_path . $msg_prefix . 'question_list.template.php';
231
+                    $path     = $base_path.$msg_prefix.'question_list.template.php';
232 232
                     $contents = EEH_Template::display_template($path, array(), true);
233 233
                     break;
234 234
                 
235 235
                 case 'attendee_list_primary_attendee' :
236
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
236
+                    $path     = $base_path.$msg_prefix.'attendee_list.template.php';
237 237
                     $contents = EEH_Template::display_template($path, array(), true);
238 238
                     break;
239 239
                 
240 240
                 case 'attendee_list_admin' :
241
-                    $path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
241
+                    $path     = $base_path.$msg_prefix.'attendee_list_admin.template.php';
242 242
                     $contents = EEH_Template::display_template($path,
243 243
                         array(), true);
244 244
                     break;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                     break;
249 249
                 
250 250
                 case 'event_list_attendee' :
251
-                    $path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
251
+                    $path     = $base_path.$msg_prefix.'event_list_attendee.template.php';
252 252
                     $contents = EEH_Template::display_template($path, array(), true);
253 253
                     break;
254 254
             }
@@ -256,24 +256,24 @@  discard block
 block discarded – undo
256 256
             switch ($template_file_prefix) {
257 257
                 
258 258
                 case 'content_attendee' :
259
-                    $path     = $base_path . $msg_prefix . 'content.template.php';
259
+                    $path     = $base_path.$msg_prefix.'content.template.php';
260 260
                     $contents = EEH_Template::display_template($path, array(), true);
261 261
                     break;
262 262
                 
263 263
                 case 'newsletter_content_attendee' :
264
-                    $path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
264
+                    $path     = $base_path.$msg_prefix.'newsletter_content.template.php';
265 265
                     $contents = EEH_Template::display_template($path, array(), true);
266 266
                     break;
267 267
                 
268 268
                 case 'newsletter_subject_attendee' :
269
-                    $path     = $base_path . $msg_prefix . 'subject.template.php';
269
+                    $path     = $base_path.$msg_prefix.'subject.template.php';
270 270
                     $contents = EEH_Template::display_template($path, array(), true);
271 271
                     break;
272 272
             }
273 273
         } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274 274
             switch ($template_file_prefix) {
275 275
                 case 'attendee_list_purchaser' :
276
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
276
+                    $path     = $base_path.$msg_prefix.'attendee_list.template.php';
277 277
                     $contents = EEH_Template::display_template($path, array(), true);
278 278
                     break;
279 279
             }
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
                 
506 506
                 //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507 507
                 //object on it.
508
-                if ( ! isset( $extra_data['data'] ) ) {
508
+                if ( ! isset($extra_data['data'])) {
509 509
                     $extra_data['data'] = $recipient;
510 510
                 }
511 511
                 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
                 if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
570 570
                     return '';
571 571
                 }
572
-                $registration     = $recipient->primary_reg_obj;
572
+                $registration = $recipient->primary_reg_obj;
573 573
                 $answers = isset($recipient->registrations[$registration->ID()]['ans_objs'])
574 574
                     ? $recipient->registrations[$registration->ID()]['ans_objs']
575 575
                     : array();
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
                 $questions = isset($recipient->questions) ? $recipient->questions : array();
583 583
                 //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
584 584
                 //object on it.
585
-                if ( ! isset( $extra_data['data'] ) ){
585
+                if ( ! isset($extra_data['data'])) {
586 586
                     $extra_data['data'] = $recipient;
587 587
                 }
588 588
                 return $this->_parse_question_list_for_primary_or_recipient_registration(
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
         $setup_args = array(
616 616
             'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
617 617
             'autoloadpaths'               => array(
618
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
618
+                EE_CAF_LIBRARIES.'messages/message_type/newsletter/'
619 619
             ),
620 620
             'messengers_to_activate_with' => array('email'),
621 621
             'messengers_to_validate_with' => array('email'),
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
         //register payment reminder message type
627 627
         $setup_args = array(
628 628
             'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
629
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
629
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'),
630 630
             'messengers_to_activate_with' => array('email'),
631 631
             'messengers_to_validate_with' => array('email'),
632 632
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
         //register payment declined message type
637 637
         $setup_args = array(
638 638
             'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
639
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
639
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'),
640 640
             'messengers_to_activate_with' => array('email'),
641 641
             'messengers_to_validate_with' => array('email'),
642 642
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
         //register registration declined message type
647 647
         $setup_args = array(
648 648
             'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
649
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
649
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'),
650 650
             'messengers_to_activate_with' => array('email'),
651 651
             'messengers_to_validate_with' => array('email'),
652 652
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
         //register registration cancelled message type
657 657
         $setup_args = array(
658 658
             'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
659
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
659
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'),
660 660
             'messengers_to_activate_with' => array('email'),
661 661
             'messengers_to_validate_with' => array('email'),
662 662
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
         //register payment failed message type
668 668
         $setup_args = array(
669 669
             'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
670
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
670
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'),
671 671
             'messengers_to_activate_with' => array('email'),
672 672
             'messengers_to_validate_with' => array('email'),
673 673
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
         //register payment declined message type
678 678
         $setup_args = array(
679 679
             'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
680
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
680
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'),
681 681
             'messengers_to_activate_with' => array('email'),
682 682
             'messengers_to_validate_with' => array('email'),
683 683
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
     {
698 698
         $setup_args = array(
699 699
             'autoloadpaths'                 => array(
700
-                EE_CAF_LIBRARIES . 'shortcodes/'
700
+                EE_CAF_LIBRARIES.'shortcodes/'
701 701
             ),
702 702
             'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
703 703
             'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
Please login to merge, or discard this patch.
libraries/messages/data_class/EE_Messages_Preview_incoming_data.class.php 2 patches
Indentation   +553 added lines, -553 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('NO direct script access allowed');
4
+	exit('NO direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -24,585 +24,585 @@  discard block
 block discarded – undo
24 24
 class EE_Messages_Preview_incoming_data extends EE_Messages_incoming_data
25 25
 {
26 26
     
27
-    //some specific properties we need for this class
28
-    private $_events = array();
29
-    private $_attendees = array();
30
-    private $_registrations = array();
27
+	//some specific properties we need for this class
28
+	private $_events = array();
29
+	private $_attendees = array();
30
+	private $_registrations = array();
31 31
     
32 32
     
33
-    /**
34
-     * For the constructor of this special preview class.  We're either looking for an event id or empty data.  If we
35
-     * have an event id (or ids) then we'll use that as the source for the "dummy" data.  If the data is empty then
36
-     * we'll get the first three published events from the users database and use that as a source.
37
-     *
38
-     * @param array $data
39
-     */
40
-    public function __construct($data = array())
41
-    {
42
-        $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array();
43
-        $this->_setup_attendees_events();
44
-        parent::__construct($data);
45
-    }
33
+	/**
34
+	 * For the constructor of this special preview class.  We're either looking for an event id or empty data.  If we
35
+	 * have an event id (or ids) then we'll use that as the source for the "dummy" data.  If the data is empty then
36
+	 * we'll get the first three published events from the users database and use that as a source.
37
+	 *
38
+	 * @param array $data
39
+	 */
40
+	public function __construct($data = array())
41
+	{
42
+		$this->_data = isset($data['event_ids']) ? $data['event_ids'] : array();
43
+		$this->_setup_attendees_events();
44
+		parent::__construct($data);
45
+	}
46 46
     
47 47
     
48
-    /**
49
-     * Returns database safe representation of the data later used to when instantiating this object.
50
-     *
51
-     * @param array $data The incoming data to be prepped.
52
-     *
53
-     * @return array   The prepped data for db
54
-     */
55
-    static public function convert_data_for_persistent_storage($data)
56
-    {
57
-        return $data;
58
-    }
48
+	/**
49
+	 * Returns database safe representation of the data later used to when instantiating this object.
50
+	 *
51
+	 * @param array $data The incoming data to be prepped.
52
+	 *
53
+	 * @return array   The prepped data for db
54
+	 */
55
+	static public function convert_data_for_persistent_storage($data)
56
+	{
57
+		return $data;
58
+	}
59 59
     
60 60
     
61
-    /**
62
-     * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
63
-     * can be sent into this method and converted back into the format used for instantiating with this data handler.
64
-     *
65
-     * @param array $data
66
-     *
67
-     * @return array
68
-     */
69
-    static public function convert_data_from_persistent_storage($data)
70
-    {
71
-        return $data;
72
-    }
61
+	/**
62
+	 * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
63
+	 * can be sent into this method and converted back into the format used for instantiating with this data handler.
64
+	 *
65
+	 * @param array $data
66
+	 *
67
+	 * @return array
68
+	 */
69
+	static public function convert_data_from_persistent_storage($data)
70
+	{
71
+		return $data;
72
+	}
73 73
     
74 74
     
75
-    /**
76
-     * This will just setup the _events property in the expected format.
77
-     *
78
-     * @throws \EE_Error
79
-     */
80
-    private function _setup_attendees_events()
81
-    {
82
-        
83
-        //setup some attendee objects
84
-        $attendees = $this->_get_some_attendees();
85
-        
86
-        //if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids.
87
-        $events = $this->_get_some_events($this->_data);
88
-        
89
-        $answers_n_questions = $this->_get_some_q_and_as();
90
-        
91
-        if (count($events) < 1) {
92
-            throw new EE_Error(__('We can\'t generate a preview for you because there are no active events in your database',
93
-                'event_espresso'));
94
-        }
95
-        
96
-        
97
-        //now let's loop and set up the _events property.  At the same time we'll set up attendee properties.
98
-        
99
-        
100
-        //we'll actually use the generated line_item identifiers for our loop
101
-        $dtts = $tkts = array();
102
-        foreach ($events as $id => $event) {
103
-            if ( ! $event instanceof EE_Event) {
104
-                continue;
105
-            }
106
-            $this->_events[$id]['ID']       = $id;
107
-            $this->_events[$id]['name']     = $event->get('EVT_name');
108
-            $datetime                       = $event->get_first_related('Datetime');
109
-            $tickets                        = $datetime instanceof EE_Datetime ? $datetime->get_many_related('Ticket',
110
-                array('default_where_conditions' => 'none')) : array();
111
-            $this->_events[$id]['event']    = $event;
112
-            $this->_events[$id]['reg_objs'] = array();
113
-            $this->_events[$id]['tkt_objs'] = $tickets;
114
-            $this->_events[$id]['dtt_objs'] = array();
75
+	/**
76
+	 * This will just setup the _events property in the expected format.
77
+	 *
78
+	 * @throws \EE_Error
79
+	 */
80
+	private function _setup_attendees_events()
81
+	{
82
+        
83
+		//setup some attendee objects
84
+		$attendees = $this->_get_some_attendees();
85
+        
86
+		//if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids.
87
+		$events = $this->_get_some_events($this->_data);
88
+        
89
+		$answers_n_questions = $this->_get_some_q_and_as();
90
+        
91
+		if (count($events) < 1) {
92
+			throw new EE_Error(__('We can\'t generate a preview for you because there are no active events in your database',
93
+				'event_espresso'));
94
+		}
95
+        
96
+        
97
+		//now let's loop and set up the _events property.  At the same time we'll set up attendee properties.
98
+        
99
+        
100
+		//we'll actually use the generated line_item identifiers for our loop
101
+		$dtts = $tkts = array();
102
+		foreach ($events as $id => $event) {
103
+			if ( ! $event instanceof EE_Event) {
104
+				continue;
105
+			}
106
+			$this->_events[$id]['ID']       = $id;
107
+			$this->_events[$id]['name']     = $event->get('EVT_name');
108
+			$datetime                       = $event->get_first_related('Datetime');
109
+			$tickets                        = $datetime instanceof EE_Datetime ? $datetime->get_many_related('Ticket',
110
+				array('default_where_conditions' => 'none')) : array();
111
+			$this->_events[$id]['event']    = $event;
112
+			$this->_events[$id]['reg_objs'] = array();
113
+			$this->_events[$id]['tkt_objs'] = $tickets;
114
+			$this->_events[$id]['dtt_objs'] = array();
115 115
             
116
-            $dttcache = array();
117
-            $tkts     = array();
118
-            foreach ($tickets as $ticket) {
119
-                if ( ! $ticket instanceof EE_Ticket) {
120
-                    continue;
121
-                }
122
-                $reldatetime                     = $ticket->datetimes();
123
-                $tkts[$ticket->ID()]             = array();
124
-                $tkts[$ticket->ID()]['ticket']   = $ticket;
125
-                $tkts[$ticket->ID()]['dtt_objs'] = $reldatetime;
126
-                $tkts[$ticket->ID()]['att_objs'] = $attendees;
127
-                $tkts[$ticket->ID()]['count']    = count($attendees);
128
-                $tkts[$ticket->ID()]['EE_Event'] = $event;
129
-                foreach ($reldatetime as $datetime) {
130
-                    if ($datetime instanceof EE_Datetime && ! isset($dtts[$datetime->ID()])) {
131
-                        $this->_events[$id]['dtt_objs'][$datetime->ID()] = $datetime;
132
-                        $dtts[$datetime->ID()]['datetime']               = $datetime;
133
-                        $dtts[$datetime->ID()]['tkt_objs'][]             = $ticket;
134
-                        $dtts[$datetime->ID()]['evt_objs'][]             = $event;
135
-                        $dttcache[$datetime->ID()]                       = $datetime;
136
-                    }
137
-                }
138
-            }
116
+			$dttcache = array();
117
+			$tkts     = array();
118
+			foreach ($tickets as $ticket) {
119
+				if ( ! $ticket instanceof EE_Ticket) {
120
+					continue;
121
+				}
122
+				$reldatetime                     = $ticket->datetimes();
123
+				$tkts[$ticket->ID()]             = array();
124
+				$tkts[$ticket->ID()]['ticket']   = $ticket;
125
+				$tkts[$ticket->ID()]['dtt_objs'] = $reldatetime;
126
+				$tkts[$ticket->ID()]['att_objs'] = $attendees;
127
+				$tkts[$ticket->ID()]['count']    = count($attendees);
128
+				$tkts[$ticket->ID()]['EE_Event'] = $event;
129
+				foreach ($reldatetime as $datetime) {
130
+					if ($datetime instanceof EE_Datetime && ! isset($dtts[$datetime->ID()])) {
131
+						$this->_events[$id]['dtt_objs'][$datetime->ID()] = $datetime;
132
+						$dtts[$datetime->ID()]['datetime']               = $datetime;
133
+						$dtts[$datetime->ID()]['tkt_objs'][]             = $ticket;
134
+						$dtts[$datetime->ID()]['evt_objs'][]             = $event;
135
+						$dttcache[$datetime->ID()]                       = $datetime;
136
+					}
137
+				}
138
+			}
139 139
             
140
-            $this->_events[$id]['total_attendees'] = count($attendees);
141
-            $this->_events[$id]['att_objs']        = $attendees;
140
+			$this->_events[$id]['total_attendees'] = count($attendees);
141
+			$this->_events[$id]['att_objs']        = $attendees;
142 142
             
143
-            //let's also setup the dummy attendees property!
144
-            foreach ($attendees as $att_key => $attendee) {
145
-                if ( ! $attendee instanceof EE_Attendee) {
146
-                    continue;
147
-                }
148
-                $this->_attendees[$att_key]['line_ref'][] = $id;  //so later it can be determined what events this attendee registered for!
149
-                $this->_attendees[$att_key]['evt_objs'][] = $event;
150
-                $this->_attendees[$att_key]['att_obj']    = $attendee;
151
-                //$this->_attendees[$att_key]['registration_id'] = 0;
152
-                $this->_attendees[$att_key]['attendee_email'] = $attendee->email();
153
-                $this->_attendees[$att_key]['tkt_objs']       = $tickets;
154
-                if ($att_key == 999999991) {
155
-                    $this->_attendees[$att_key]['ans_objs'][999]  = $answers_n_questions['answers'][999];
156
-                    $this->_attendees[$att_key]['ans_objs'][1002] = $answers_n_questions['answers'][1002];
157
-                    $this->_attendees[$att_key]['ans_objs'][1005] = $answers_n_questions['answers'][1005];
158
-                } elseif ($att_key == 999999992) {
159
-                    $this->_attendees[$att_key]['ans_objs'][1000] = $answers_n_questions['answers'][1000];
160
-                    $this->_attendees[$att_key]['ans_objs'][1003] = $answers_n_questions['answers'][1003];
161
-                    $this->_attendees[$att_key]['ans_objs'][1006] = $answers_n_questions['answers'][1006];
162
-                } elseif ($att_key == 999999993) {
163
-                    $this->_attendees[$att_key]['ans_objs'][1001] = $answers_n_questions['answers'][1001];
164
-                    $this->_attendees[$att_key]['ans_objs'][1004] = $answers_n_questions['answers'][1004];
165
-                    $this->_attendees[$att_key]['ans_objs'][1007] = $answers_n_questions['answers'][1007];
166
-                }
167
-            }
168
-        }
169
-        
170
-        $this->tickets            = $tkts;
171
-        $this->datetimes          = $dtts;
172
-        $this->answers            = $answers_n_questions['answers'];
173
-        $this->questions          = $answers_n_questions['questions'];
174
-        $this->total_ticket_count = count($tkts) * count($this->_attendees);
175
-        
176
-    }
143
+			//let's also setup the dummy attendees property!
144
+			foreach ($attendees as $att_key => $attendee) {
145
+				if ( ! $attendee instanceof EE_Attendee) {
146
+					continue;
147
+				}
148
+				$this->_attendees[$att_key]['line_ref'][] = $id;  //so later it can be determined what events this attendee registered for!
149
+				$this->_attendees[$att_key]['evt_objs'][] = $event;
150
+				$this->_attendees[$att_key]['att_obj']    = $attendee;
151
+				//$this->_attendees[$att_key]['registration_id'] = 0;
152
+				$this->_attendees[$att_key]['attendee_email'] = $attendee->email();
153
+				$this->_attendees[$att_key]['tkt_objs']       = $tickets;
154
+				if ($att_key == 999999991) {
155
+					$this->_attendees[$att_key]['ans_objs'][999]  = $answers_n_questions['answers'][999];
156
+					$this->_attendees[$att_key]['ans_objs'][1002] = $answers_n_questions['answers'][1002];
157
+					$this->_attendees[$att_key]['ans_objs'][1005] = $answers_n_questions['answers'][1005];
158
+				} elseif ($att_key == 999999992) {
159
+					$this->_attendees[$att_key]['ans_objs'][1000] = $answers_n_questions['answers'][1000];
160
+					$this->_attendees[$att_key]['ans_objs'][1003] = $answers_n_questions['answers'][1003];
161
+					$this->_attendees[$att_key]['ans_objs'][1006] = $answers_n_questions['answers'][1006];
162
+				} elseif ($att_key == 999999993) {
163
+					$this->_attendees[$att_key]['ans_objs'][1001] = $answers_n_questions['answers'][1001];
164
+					$this->_attendees[$att_key]['ans_objs'][1004] = $answers_n_questions['answers'][1004];
165
+					$this->_attendees[$att_key]['ans_objs'][1007] = $answers_n_questions['answers'][1007];
166
+				}
167
+			}
168
+		}
169
+        
170
+		$this->tickets            = $tkts;
171
+		$this->datetimes          = $dtts;
172
+		$this->answers            = $answers_n_questions['answers'];
173
+		$this->questions          = $answers_n_questions['questions'];
174
+		$this->total_ticket_count = count($tkts) * count($this->_attendees);
175
+        
176
+	}
177 177
     
178 178
     
179
-    /**
180
-     * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data
181
-     *
182
-     * @access private
183
-     * @return array an array of attendee objects
184
-     */
185
-    private function _get_some_attendees()
186
-    {
187
-        //let's just setup a dummy array of various attendee details
188
-        $dummy_attendees = array(
189
-            0 => array(
190
-                'Luke',
191
-                'Skywalker',
192
-                '[email protected]',
193
-                '804 Bantha Dr.',
194
-                'Complex 8',
195
-                'Mos Eisley',
196
-                32,
197
-                'US',
198
-                'f0r3e',
199
-                '222-333-4763',
200
-                false,
201
-                '999999991'
202
-            ),
203
-            1 => array(
204
-                'Princess',
205
-                'Leia',
206
-                '[email protected]',
207
-                '1456 Valley Way Boulevard',
208
-                'Suite 9',
209
-                'Alderaan',
210
-                15,
211
-                'US',
212
-                'c1h2c',
213
-                '78-123-111-1111',
214
-                false,
215
-                '999999992'
216
-            ),
217
-            2 => array(
218
-                'Yoda',
219
-                'I Am',
220
-                '[email protected]',
221
-                '4th Tree',
222
-                '5th Knot',
223
-                'Marsh',
224
-                22,
225
-                'US',
226
-                'l18n',
227
-                '999-999-9999',
228
-                false,
229
-                '999999993'
230
-            ),
231
-        );
232
-        
233
-        //let's generate the attendee objects
234
-        $attendees = array();
235
-        $var_array = array(
236
-            'fname',
237
-            'lname',
238
-            'email',
239
-            'address',
240
-            'address2',
241
-            'city',
242
-            'staid',
243
-            'cntry',
244
-            'zip',
245
-            'phone',
246
-            'deleted',
247
-            'attid'
248
-        );
249
-        
250
-        //EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE );
251
-        foreach ($dummy_attendees as $dummy) {
252
-            $att = array_combine($var_array, $dummy);
253
-            extract($att);
254
-            /** @var $fname string */
255
-            /** @var $lname string */
256
-            /** @var $address string */
257
-            /** @var $address2 string */
258
-            /** @var $city string */
259
-            /** @var $staid string */
260
-            /** @var $cntry string */
261
-            /** @var $zip string */
262
-            /** @var $email string */
263
-            /** @var $phone string */
264
-            /** @var $attid string */
265
-            $attendees[$attid] = EE_Attendee::new_instance(
266
-                array(
267
-                    'ATT_fname'    => $fname,
268
-                    'ATT_lname'    => $lname,
269
-                    'ATT_address'  => $address,
270
-                    'ATT_address2' => $address2,
271
-                    'ATT_city'     => $city,
272
-                    'STA_ID'       => $staid,
273
-                    'CNT_ISO'      => $cntry,
274
-                    'ATT_zip'      => $zip,
275
-                    'ATT_email'    => $email,
276
-                    'ATT_phone'    => $phone,
277
-                    'ATT_ID'       => $attid
278
-                )
279
-            );
280
-        }
281
-        
282
-        return $attendees;
283
-    }
179
+	/**
180
+	 * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data
181
+	 *
182
+	 * @access private
183
+	 * @return array an array of attendee objects
184
+	 */
185
+	private function _get_some_attendees()
186
+	{
187
+		//let's just setup a dummy array of various attendee details
188
+		$dummy_attendees = array(
189
+			0 => array(
190
+				'Luke',
191
+				'Skywalker',
192
+				'[email protected]',
193
+				'804 Bantha Dr.',
194
+				'Complex 8',
195
+				'Mos Eisley',
196
+				32,
197
+				'US',
198
+				'f0r3e',
199
+				'222-333-4763',
200
+				false,
201
+				'999999991'
202
+			),
203
+			1 => array(
204
+				'Princess',
205
+				'Leia',
206
+				'[email protected]',
207
+				'1456 Valley Way Boulevard',
208
+				'Suite 9',
209
+				'Alderaan',
210
+				15,
211
+				'US',
212
+				'c1h2c',
213
+				'78-123-111-1111',
214
+				false,
215
+				'999999992'
216
+			),
217
+			2 => array(
218
+				'Yoda',
219
+				'I Am',
220
+				'[email protected]',
221
+				'4th Tree',
222
+				'5th Knot',
223
+				'Marsh',
224
+				22,
225
+				'US',
226
+				'l18n',
227
+				'999-999-9999',
228
+				false,
229
+				'999999993'
230
+			),
231
+		);
232
+        
233
+		//let's generate the attendee objects
234
+		$attendees = array();
235
+		$var_array = array(
236
+			'fname',
237
+			'lname',
238
+			'email',
239
+			'address',
240
+			'address2',
241
+			'city',
242
+			'staid',
243
+			'cntry',
244
+			'zip',
245
+			'phone',
246
+			'deleted',
247
+			'attid'
248
+		);
249
+        
250
+		//EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE );
251
+		foreach ($dummy_attendees as $dummy) {
252
+			$att = array_combine($var_array, $dummy);
253
+			extract($att);
254
+			/** @var $fname string */
255
+			/** @var $lname string */
256
+			/** @var $address string */
257
+			/** @var $address2 string */
258
+			/** @var $city string */
259
+			/** @var $staid string */
260
+			/** @var $cntry string */
261
+			/** @var $zip string */
262
+			/** @var $email string */
263
+			/** @var $phone string */
264
+			/** @var $attid string */
265
+			$attendees[$attid] = EE_Attendee::new_instance(
266
+				array(
267
+					'ATT_fname'    => $fname,
268
+					'ATT_lname'    => $lname,
269
+					'ATT_address'  => $address,
270
+					'ATT_address2' => $address2,
271
+					'ATT_city'     => $city,
272
+					'STA_ID'       => $staid,
273
+					'CNT_ISO'      => $cntry,
274
+					'ATT_zip'      => $zip,
275
+					'ATT_email'    => $email,
276
+					'ATT_phone'    => $phone,
277
+					'ATT_ID'       => $attid
278
+				)
279
+			);
280
+		}
281
+        
282
+		return $attendees;
283
+	}
284 284
     
285 285
     
286
-    /**
287
-     * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id.
288
-     * This will be used in our dummy data setup
289
-     * @return array
290
-     */
291
-    private function _get_some_q_and_as()
292
-    {
293
-        
294
-        
295
-        $quests_array = array(
296
-            0 => array(
297
-                555,
298
-                __('What is your favorite planet?', 'event_espresso'),
299
-                0
300
-            ),
301
-            1 => array(
302
-                556,
303
-                __('What is your favorite food?', 'event_espresso'),
304
-                0
305
-            ),
306
-            2 => array(
307
-                557,
308
-                __('How many lightyears have you travelled', 'event_espresso'),
309
-                0
310
-            )
311
-        );
312
-        
313
-        
314
-        $ans_array = array(
315
-            0 => array(
316
-                999,
317
-                555,
318
-                'Tattoine'
319
-            ),
320
-            1 => array(
321
-                1000,
322
-                555,
323
-                'Alderaan'
324
-            ),
325
-            2 => array(
326
-                1001,
327
-                555,
328
-                'Dantooine'
329
-            ),
330
-            3 => array(
331
-                1002,
332
-                556,
333
-                'Fish Fingers'
334
-            ),
335
-            4 => array(
336
-                1003,
337
-                556,
338
-                'Sushi'
339
-            ),
340
-            5 => array(
341
-                1004,
342
-                556,
343
-                'Water'
344
-            ),
345
-            6 => array(
346
-                1005,
347
-                557,
348
-                'A lot',
349
-            ),
350
-            7 => array(
351
-                1006,
352
-                557,
353
-                "That's none of your business."
354
-            ),
355
-            8 => array(
356
-                1007,
357
-                557,
358
-                "People less travel me then."
359
-            )
360
-        );
361
-        
362
-        $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system');
363
-        $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value');
364
-        
365
-        //EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE );
366
-        //EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE );
367
-        
368
-        $qsts = array();
369
-        //first the questions
370
-        foreach ($quests_array as $qst) {
371
-            $qstobj                  = array_combine($qst_columns, $qst);
372
-            $qsts[$qstobj['QST_ID']] = EE_Question::new_instance($qstobj);
373
-        }
374
-        
375
-        //now the answers (and we'll setup our arrays)
376
-        $q_n_as = array();
377
-        foreach ($ans_array as $ans) {
378
-            $ansobj                             = array_combine($ans_columns, $ans);
379
-            $ansobj                             = EE_Answer::new_instance($ansobj);
380
-            $q_n_as['answers'][$ansobj->ID()]   = $ansobj;
381
-            $q_n_as['questions'][$ansobj->ID()] = $qsts[$ansobj->get('QST_ID')];
382
-        }
383
-        
384
-        return $q_n_as;
385
-        
386
-    }
286
+	/**
287
+	 * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id.
288
+	 * This will be used in our dummy data setup
289
+	 * @return array
290
+	 */
291
+	private function _get_some_q_and_as()
292
+	{
293
+        
294
+        
295
+		$quests_array = array(
296
+			0 => array(
297
+				555,
298
+				__('What is your favorite planet?', 'event_espresso'),
299
+				0
300
+			),
301
+			1 => array(
302
+				556,
303
+				__('What is your favorite food?', 'event_espresso'),
304
+				0
305
+			),
306
+			2 => array(
307
+				557,
308
+				__('How many lightyears have you travelled', 'event_espresso'),
309
+				0
310
+			)
311
+		);
312
+        
313
+        
314
+		$ans_array = array(
315
+			0 => array(
316
+				999,
317
+				555,
318
+				'Tattoine'
319
+			),
320
+			1 => array(
321
+				1000,
322
+				555,
323
+				'Alderaan'
324
+			),
325
+			2 => array(
326
+				1001,
327
+				555,
328
+				'Dantooine'
329
+			),
330
+			3 => array(
331
+				1002,
332
+				556,
333
+				'Fish Fingers'
334
+			),
335
+			4 => array(
336
+				1003,
337
+				556,
338
+				'Sushi'
339
+			),
340
+			5 => array(
341
+				1004,
342
+				556,
343
+				'Water'
344
+			),
345
+			6 => array(
346
+				1005,
347
+				557,
348
+				'A lot',
349
+			),
350
+			7 => array(
351
+				1006,
352
+				557,
353
+				"That's none of your business."
354
+			),
355
+			8 => array(
356
+				1007,
357
+				557,
358
+				"People less travel me then."
359
+			)
360
+		);
361
+        
362
+		$qst_columns = array('QST_ID', 'QST_display_text', 'QST_system');
363
+		$ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value');
364
+        
365
+		//EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE );
366
+		//EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE );
367
+        
368
+		$qsts = array();
369
+		//first the questions
370
+		foreach ($quests_array as $qst) {
371
+			$qstobj                  = array_combine($qst_columns, $qst);
372
+			$qsts[$qstobj['QST_ID']] = EE_Question::new_instance($qstobj);
373
+		}
374
+        
375
+		//now the answers (and we'll setup our arrays)
376
+		$q_n_as = array();
377
+		foreach ($ans_array as $ans) {
378
+			$ansobj                             = array_combine($ans_columns, $ans);
379
+			$ansobj                             = EE_Answer::new_instance($ansobj);
380
+			$q_n_as['answers'][$ansobj->ID()]   = $ansobj;
381
+			$q_n_as['questions'][$ansobj->ID()] = $qsts[$ansobj->get('QST_ID')];
382
+		}
383
+        
384
+		return $q_n_as;
385
+        
386
+	}
387 387
     
388 388
     
389
-    /**
390
-     * Return an array of event objects from the database
391
-     *
392
-     * If event ids are not included then we'll just retrieve the first published event from the database.
393
-     *
394
-     * @param  array $event_ids if set, this will be an array of event ids to obtain events for.
395
-     *
396
-     * @return array    An array of event objects from the db.
397
-     */
398
-    private function _get_some_events($event_ids = array())
399
-    {
400
-        
401
-        //HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed);
402
-        $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id'])
403
-            ? array($_REQUEST['evt_id'])
404
-            : $event_ids;
405
-        
406
-        $limit = ! empty($event_ids)
407
-            ? null
408
-            : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1');
409
-        
410
-        $where = ! empty($event_ids)
411
-            ? array(
412
-                'EVT_ID'                 => array('IN', $event_ids),
413
-                'Datetime.Ticket.TKT_ID' => array('>', 1)
414
-            )
415
-            : array('Datetime.Ticket.TKT_ID' => array('>', 1));
416
-        
417
-        $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit));
418
-        
419
-        return $events;
420
-    }
389
+	/**
390
+	 * Return an array of event objects from the database
391
+	 *
392
+	 * If event ids are not included then we'll just retrieve the first published event from the database.
393
+	 *
394
+	 * @param  array $event_ids if set, this will be an array of event ids to obtain events for.
395
+	 *
396
+	 * @return array    An array of event objects from the db.
397
+	 */
398
+	private function _get_some_events($event_ids = array())
399
+	{
400
+        
401
+		//HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed);
402
+		$event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id'])
403
+			? array($_REQUEST['evt_id'])
404
+			: $event_ids;
405
+        
406
+		$limit = ! empty($event_ids)
407
+			? null
408
+			: apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1');
409
+        
410
+		$where = ! empty($event_ids)
411
+			? array(
412
+				'EVT_ID'                 => array('IN', $event_ids),
413
+				'Datetime.Ticket.TKT_ID' => array('>', 1)
414
+			)
415
+			: array('Datetime.Ticket.TKT_ID' => array('>', 1));
416
+        
417
+		$events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit));
418
+        
419
+		return $events;
420
+	}
421 421
     
422 422
     
423
-    protected function _setup_data()
424
-    {
425
-        
426
-        //need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it!
427
-        if (EE_Registry::instance()->SSN instanceof EE_Session) {
428
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
429
-            $session = EE_Registry::instance()->SSN;
430
-        } else {
431
-            $session = EE_Registry::instance()->load_core('Session');
432
-        }
433
-        $cart = EE_Cart::instance(null, $session);
434
-        
435
-        
436
-        //add tickets to cart
437
-        foreach ($this->tickets as $ticket) {
438
-            $cart->add_ticket_to_cart($ticket['ticket']);
439
-        }
440
-        
441
-        
442
-        //setup txn property
443
-        $this->txn = EE_Transaction::new_instance(
444
-            array(
445
-                'TXN_timestamp'    => time(), //unix timestamp
446
-                'TXN_total'        => 0, //txn_total
447
-                'TXN_paid'         => 0, //txn_paid
448
-                'STS_ID'           => EEM_Transaction::incomplete_status_code, //sts_id
449
-                'TXN_session_data' => null, //dump of txn session object (we're just going to leave blank here)
450
-                'TXN_hash_salt'    => null, //hash salt blank as well
451
-                'TXN_ID'           => 999999
452
-            )
453
-        );
454
-        
455
-        
456
-        //setup reg_objects
457
-        //note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array.
458
-        $this->reg_objs = array();
459
-        $regid          = 9999990;
460
-        foreach ($this->_attendees as $key => $attendee) {
461
-            //note we need to setup reg_objects for each event this attendee belongs to
462
-            $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null;
463
-            $regtxn = $this->txn->ID();
464
-            $regcnt = 1;
465
-            foreach ($attendee['line_ref'] as $evtid) {
466
-                foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) {
467
-                    if ( ! $ticket instanceof EE_Ticket) {
468
-                        continue;
469
-                    }
470
-                    $reg_array                                        = array(
471
-                        'EVT_ID'           => $evtid,
472
-                        'ATT_ID'           => $regatt,
473
-                        'TXN_ID'           => $regtxn,
474
-                        'TKT_ID'           => $ticket->ID(),
475
-                        'STS_ID'           => EEM_Registration::status_id_pending_payment,
476
-                        'REG_date'         => time(),
477
-                        'REG_final_price'  => $ticket->get('TKT_price'),
478
-                        'REG_session'      => 'dummy_session_id',
479
-                        'REG_code'         => $regid . '-dummy-generated-code',
480
-                        'REG_url_link'     => $regcnt . '-daafpapasdlfakasdfpqasdfasdf',
481
-                        'REG_count'        => $regcnt,
482
-                        'REG_group_size'   => $this->_events[$evtid]['total_attendees'],
483
-                        'REG_att_is_going' => true,
484
-                        'REG_ID'           => $regid
485
-                    );
486
-                    $REG_OBJ                                          = EE_Registration::new_instance($reg_array);
487
-                    $this->_attendees[$key]['reg_objs'][$regid]       = $REG_OBJ;
488
-                    $this->_events[$evtid]['reg_objs'][]              = $REG_OBJ;
489
-                    $this->reg_objs[]                                 = $REG_OBJ;
490
-                    $this->tickets[$ticket->ID()]['reg_objs'][$regid] = $REG_OBJ;
423
+	protected function _setup_data()
424
+	{
425
+        
426
+		//need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it!
427
+		if (EE_Registry::instance()->SSN instanceof EE_Session) {
428
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
429
+			$session = EE_Registry::instance()->SSN;
430
+		} else {
431
+			$session = EE_Registry::instance()->load_core('Session');
432
+		}
433
+		$cart = EE_Cart::instance(null, $session);
434
+        
435
+        
436
+		//add tickets to cart
437
+		foreach ($this->tickets as $ticket) {
438
+			$cart->add_ticket_to_cart($ticket['ticket']);
439
+		}
440
+        
441
+        
442
+		//setup txn property
443
+		$this->txn = EE_Transaction::new_instance(
444
+			array(
445
+				'TXN_timestamp'    => time(), //unix timestamp
446
+				'TXN_total'        => 0, //txn_total
447
+				'TXN_paid'         => 0, //txn_paid
448
+				'STS_ID'           => EEM_Transaction::incomplete_status_code, //sts_id
449
+				'TXN_session_data' => null, //dump of txn session object (we're just going to leave blank here)
450
+				'TXN_hash_salt'    => null, //hash salt blank as well
451
+				'TXN_ID'           => 999999
452
+			)
453
+		);
454
+        
455
+        
456
+		//setup reg_objects
457
+		//note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array.
458
+		$this->reg_objs = array();
459
+		$regid          = 9999990;
460
+		foreach ($this->_attendees as $key => $attendee) {
461
+			//note we need to setup reg_objects for each event this attendee belongs to
462
+			$regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null;
463
+			$regtxn = $this->txn->ID();
464
+			$regcnt = 1;
465
+			foreach ($attendee['line_ref'] as $evtid) {
466
+				foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) {
467
+					if ( ! $ticket instanceof EE_Ticket) {
468
+						continue;
469
+					}
470
+					$reg_array                                        = array(
471
+						'EVT_ID'           => $evtid,
472
+						'ATT_ID'           => $regatt,
473
+						'TXN_ID'           => $regtxn,
474
+						'TKT_ID'           => $ticket->ID(),
475
+						'STS_ID'           => EEM_Registration::status_id_pending_payment,
476
+						'REG_date'         => time(),
477
+						'REG_final_price'  => $ticket->get('TKT_price'),
478
+						'REG_session'      => 'dummy_session_id',
479
+						'REG_code'         => $regid . '-dummy-generated-code',
480
+						'REG_url_link'     => $regcnt . '-daafpapasdlfakasdfpqasdfasdf',
481
+						'REG_count'        => $regcnt,
482
+						'REG_group_size'   => $this->_events[$evtid]['total_attendees'],
483
+						'REG_att_is_going' => true,
484
+						'REG_ID'           => $regid
485
+					);
486
+					$REG_OBJ                                          = EE_Registration::new_instance($reg_array);
487
+					$this->_attendees[$key]['reg_objs'][$regid]       = $REG_OBJ;
488
+					$this->_events[$evtid]['reg_objs'][]              = $REG_OBJ;
489
+					$this->reg_objs[]                                 = $REG_OBJ;
490
+					$this->tickets[$ticket->ID()]['reg_objs'][$regid] = $REG_OBJ;
491 491
                     
492
-                    $regcnt++;
493
-                    $regid++;
494
-                }
495
-            }
496
-        }
497
-        
498
-        
499
-        //setup line items!
500
-        $line_item_total = EEH_Line_Item::create_total_line_item($this->txn);
501
-        
502
-        //add tickets
503
-        foreach ($this->tickets as $tktid => $item) {
504
-            $qty    = $item['count'];
505
-            $ticket = $item['ticket'];
506
-            EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty);
507
-        }
508
-        
509
-        $shipping_line_item = EE_Line_Item::new_instance(array(
510
-            'LIN_name'       => __('Shipping Surcharge', 'event_espresso'),
511
-            'LIN_desc'       => __('Sent via Millenium Falcon', 'event_espresso'),
512
-            'LIN_unit_price' => 20,
513
-            'LIN_quantity'   => 1,
514
-            'LIN_is_taxable' => true,
515
-            'LIN_total'      => 20,
516
-            'LIN_type'       => EEM_Line_Item::type_line_item
517
-        ));
518
-        EEH_Line_Item::add_item($line_item_total, $shipping_line_item);
519
-        $this->additional_line_items = array($shipping_line_item);
520
-        
521
-        //now let's add taxes
522
-        EEH_Line_Item::apply_taxes($line_item_total);
523
-        
524
-        //now we should be able to get the items we need from this object
525
-        $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children();
526
-        $line_items       = array();
527
-        foreach ($event_line_items as $line_id => $line_item) {
528
-            if ( ! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') {
529
-                continue;
530
-            }
531
-            $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item);
532
-            foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) {
533
-                if ( ! $ticket_line_item instanceof EE_Line_Item) {
534
-                    continue;
535
-                }
536
-                $this->tickets[$ticket_line_item->OBJ_ID()]['line_item']      = $ticket_line_item;
537
-                $this->tickets[$ticket_line_item->OBJ_ID()]['sub_line_items'] = $ticket_line_item->children();
538
-                $line_items[$ticket_line_item->ID()]['children']              = $ticket_line_item->children();
539
-                $line_items[$ticket_line_item->ID()]['EE_Ticket']             = $this->tickets[$ticket_line_item->OBJ_ID()]['ticket'];
540
-            }
541
-        }
542
-        
543
-        $this->line_items_with_children = $line_items;
544
-        $this->tax_line_items           = $line_item_total->tax_descendants();
545
-        
546
-        //add proper total to transaction object.
547
-        $grand_total                 = $line_item_total->recalculate_total_including_taxes();
548
-        $this->grand_total_line_item = $line_item_total;
549
-        $this->txn->set_total($grand_total);
550
-        
551
-        
552
-        //add additional details for each registration
553
-        foreach ($this->reg_objs as $reg) {
554
-            if ( ! $reg instanceof EE_Registration) {
555
-                continue;
556
-            }
557
-            $this->_registrations[$reg->ID()]['tkt_obj']  = $this->tickets[$reg->get('TKT_ID')]['ticket'];
558
-            $this->_registrations[$reg->ID()]['evt_obj']  = $this->_events[$reg->get('EVT_ID')]['event'];
559
-            $this->_registrations[$reg->ID()]['reg_obj']  = $reg;
560
-            $this->_registrations[$reg->ID()]['ans_objs'] = $this->_attendees[$reg->get('ATT_ID')]['ans_objs'];
561
-            $this->_registrations[$reg->ID()]['att_obj']  = $this->_attendees[$reg->get('ATT_ID')]['att_obj'];
562
-            $this->_registrations[$reg->ID()]['dtt_objs'] = $this->tickets[$reg->get('TKT_ID')]['dtt_objs'];
563
-        }
564
-        
565
-        
566
-        //events and attendees
567
-        $this->events        = $this->_events;
568
-        $this->attendees     = $this->_attendees;
569
-        $this->registrations = $this->_registrations;
570
-        
571
-        $attendees_to_shift = $this->_attendees;
572
-        
573
-        //setup primary attendee property
574
-        $this->primary_attendee_data = array(
575
-            'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
576
-                ? $this->_attendees[999999991]['att_obj']->fname()
577
-                : '',
492
+					$regcnt++;
493
+					$regid++;
494
+				}
495
+			}
496
+		}
497
+        
498
+        
499
+		//setup line items!
500
+		$line_item_total = EEH_Line_Item::create_total_line_item($this->txn);
501
+        
502
+		//add tickets
503
+		foreach ($this->tickets as $tktid => $item) {
504
+			$qty    = $item['count'];
505
+			$ticket = $item['ticket'];
506
+			EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty);
507
+		}
508
+        
509
+		$shipping_line_item = EE_Line_Item::new_instance(array(
510
+			'LIN_name'       => __('Shipping Surcharge', 'event_espresso'),
511
+			'LIN_desc'       => __('Sent via Millenium Falcon', 'event_espresso'),
512
+			'LIN_unit_price' => 20,
513
+			'LIN_quantity'   => 1,
514
+			'LIN_is_taxable' => true,
515
+			'LIN_total'      => 20,
516
+			'LIN_type'       => EEM_Line_Item::type_line_item
517
+		));
518
+		EEH_Line_Item::add_item($line_item_total, $shipping_line_item);
519
+		$this->additional_line_items = array($shipping_line_item);
520
+        
521
+		//now let's add taxes
522
+		EEH_Line_Item::apply_taxes($line_item_total);
523
+        
524
+		//now we should be able to get the items we need from this object
525
+		$event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children();
526
+		$line_items       = array();
527
+		foreach ($event_line_items as $line_id => $line_item) {
528
+			if ( ! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') {
529
+				continue;
530
+			}
531
+			$ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item);
532
+			foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) {
533
+				if ( ! $ticket_line_item instanceof EE_Line_Item) {
534
+					continue;
535
+				}
536
+				$this->tickets[$ticket_line_item->OBJ_ID()]['line_item']      = $ticket_line_item;
537
+				$this->tickets[$ticket_line_item->OBJ_ID()]['sub_line_items'] = $ticket_line_item->children();
538
+				$line_items[$ticket_line_item->ID()]['children']              = $ticket_line_item->children();
539
+				$line_items[$ticket_line_item->ID()]['EE_Ticket']             = $this->tickets[$ticket_line_item->OBJ_ID()]['ticket'];
540
+			}
541
+		}
542
+        
543
+		$this->line_items_with_children = $line_items;
544
+		$this->tax_line_items           = $line_item_total->tax_descendants();
545
+        
546
+		//add proper total to transaction object.
547
+		$grand_total                 = $line_item_total->recalculate_total_including_taxes();
548
+		$this->grand_total_line_item = $line_item_total;
549
+		$this->txn->set_total($grand_total);
550
+        
551
+        
552
+		//add additional details for each registration
553
+		foreach ($this->reg_objs as $reg) {
554
+			if ( ! $reg instanceof EE_Registration) {
555
+				continue;
556
+			}
557
+			$this->_registrations[$reg->ID()]['tkt_obj']  = $this->tickets[$reg->get('TKT_ID')]['ticket'];
558
+			$this->_registrations[$reg->ID()]['evt_obj']  = $this->_events[$reg->get('EVT_ID')]['event'];
559
+			$this->_registrations[$reg->ID()]['reg_obj']  = $reg;
560
+			$this->_registrations[$reg->ID()]['ans_objs'] = $this->_attendees[$reg->get('ATT_ID')]['ans_objs'];
561
+			$this->_registrations[$reg->ID()]['att_obj']  = $this->_attendees[$reg->get('ATT_ID')]['att_obj'];
562
+			$this->_registrations[$reg->ID()]['dtt_objs'] = $this->tickets[$reg->get('TKT_ID')]['dtt_objs'];
563
+		}
564
+        
565
+        
566
+		//events and attendees
567
+		$this->events        = $this->_events;
568
+		$this->attendees     = $this->_attendees;
569
+		$this->registrations = $this->_registrations;
570
+        
571
+		$attendees_to_shift = $this->_attendees;
572
+        
573
+		//setup primary attendee property
574
+		$this->primary_attendee_data = array(
575
+			'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
576
+				? $this->_attendees[999999991]['att_obj']->fname()
577
+				: '',
578 578
             
579
-            'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
580
-                ? $this->_attendees[999999991]['att_obj']->lname()
581
-                : '',
579
+			'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
580
+				? $this->_attendees[999999991]['att_obj']->lname()
581
+				: '',
582 582
             
583
-            'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
584
-                ? $this->_attendees[999999991]['att_obj']->email()
585
-                : '',
583
+			'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
584
+				? $this->_attendees[999999991]['att_obj']->email()
585
+				: '',
586 586
             
587
-            'att_obj' => $this->_attendees[999999991]['att_obj'],
587
+			'att_obj' => $this->_attendees[999999991]['att_obj'],
588 588
             
589
-            'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs'])
590
-        );
589
+			'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs'])
590
+		);
591 591
         
592
-        //reg_info property
593
-        //note this isn't referenced by any shortcode parsers so we'll ignore for now.
594
-        $this->reg_info = array();
592
+		//reg_info property
593
+		//note this isn't referenced by any shortcode parsers so we'll ignore for now.
594
+		$this->reg_info = array();
595 595
         
596
-        //let's set a reg_obj for messengers expecting one.
597
-        $this->reg_obj = array_pop($this->_attendees[999999991]['reg_objs']);
596
+		//let's set a reg_obj for messengers expecting one.
597
+		$this->reg_obj = array_pop($this->_attendees[999999991]['reg_objs']);
598 598
         
599 599
         
600
-        //the below are just dummy items.
601
-        $this->user_id     = 1;
602
-        $this->ip_address  = '192.0.2.1';
603
-        $this->user_agent  = '';
604
-        $this->init_access = time();
605
-        $this->last_access = time();
606
-    }
600
+		//the below are just dummy items.
601
+		$this->user_id     = 1;
602
+		$this->ip_address  = '192.0.2.1';
603
+		$this->user_agent  = '';
604
+		$this->init_access = time();
605
+		$this->last_access = time();
606
+	}
607 607
     
608 608
 } //end EE_Messages_Preview_incoming_data class
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                 if ( ! $attendee instanceof EE_Attendee) {
146 146
                     continue;
147 147
                 }
148
-                $this->_attendees[$att_key]['line_ref'][] = $id;  //so later it can be determined what events this attendee registered for!
148
+                $this->_attendees[$att_key]['line_ref'][] = $id; //so later it can be determined what events this attendee registered for!
149 149
                 $this->_attendees[$att_key]['evt_objs'][] = $event;
150 150
                 $this->_attendees[$att_key]['att_obj']    = $attendee;
151 151
                 //$this->_attendees[$att_key]['registration_id'] = 0;
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
                     if ( ! $ticket instanceof EE_Ticket) {
468 468
                         continue;
469 469
                     }
470
-                    $reg_array                                        = array(
470
+                    $reg_array = array(
471 471
                         'EVT_ID'           => $evtid,
472 472
                         'ATT_ID'           => $regatt,
473 473
                         'TXN_ID'           => $regtxn,
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
                         'REG_date'         => time(),
477 477
                         'REG_final_price'  => $ticket->get('TKT_price'),
478 478
                         'REG_session'      => 'dummy_session_id',
479
-                        'REG_code'         => $regid . '-dummy-generated-code',
480
-                        'REG_url_link'     => $regcnt . '-daafpapasdlfakasdfpqasdfasdf',
479
+                        'REG_code'         => $regid.'-dummy-generated-code',
480
+                        'REG_url_link'     => $regcnt.'-daafpapasdlfakasdfpqasdfasdf',
481 481
                         'REG_count'        => $regcnt,
482 482
                         'REG_group_size'   => $this->_events[$evtid]['total_attendees'],
483 483
                         'REG_att_is_going' => true,
Please login to merge, or discard this patch.
caffeinated/core/libraries/shortcodes/EE_Question_List_Shortcodes.lib.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('NO direct script access allowed');
4
+	exit('NO direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -36,80 +36,80 @@  discard block
 block discarded – undo
36 36
 {
37 37
     
38 38
     
39
-    public function __construct()
40
-    {
41
-        parent::__construct();
42
-    }
39
+	public function __construct()
40
+	{
41
+		parent::__construct();
42
+	}
43 43
     
44 44
     
45
-    protected function _init_props()
46
-    {
47
-        $this->label       = __('Questions and Answers Shortcodes', 'event_espresso');
48
-        $this->description = __('All shortcodes related to custom questions and answers', 'event_espresso');
49
-        $this->_shortcodes = array(
50
-            '[QUESTION_LIST]' => __('This is used to indicate where you want the list of questions and answers to show for the registrant.  You place this within the "[attendee_list]" field.',
51
-                'event_espresso')
52
-        );
53
-    }
45
+	protected function _init_props()
46
+	{
47
+		$this->label       = __('Questions and Answers Shortcodes', 'event_espresso');
48
+		$this->description = __('All shortcodes related to custom questions and answers', 'event_espresso');
49
+		$this->_shortcodes = array(
50
+			'[QUESTION_LIST]' => __('This is used to indicate where you want the list of questions and answers to show for the registrant.  You place this within the "[attendee_list]" field.',
51
+				'event_espresso')
52
+		);
53
+	}
54 54
     
55 55
     
56
-    protected function _parser($shortcode)
57
-    {
56
+	protected function _parser($shortcode)
57
+	{
58 58
         
59 59
         
60
-        switch ($shortcode) {
61
-            case '[QUESTION_LIST]' :
62
-                return $this->_get_question_list();
63
-                break;
64
-        }
60
+		switch ($shortcode) {
61
+			case '[QUESTION_LIST]' :
62
+				return $this->_get_question_list();
63
+				break;
64
+		}
65 65
         
66
-        return '';
67
-    }
66
+		return '';
67
+	}
68 68
     
69 69
     
70
-    protected function _get_question_list()
71
-    {
72
-        $this->_validate_list_requirements();
70
+	protected function _get_question_list()
71
+	{
72
+		$this->_validate_list_requirements();
73 73
         
74
-        //for when [QUESTION_LIST] is used in the [attendee_list] field.
75
-        if ($this->_data['data'] instanceof EE_Registration) {
76
-            return $this->_get_question_answer_list_for_attendee();
77
-        } //for when [QUESTION_LIST] is used in the main content field.
78
-        else if ($this->_data['data'] instanceof EE_Messages_Addressee && $this->_data['data']->reg_obj instanceof EE_Registration) {
79
-            return $this->_get_question_answer_list_for_attendee($this->_data['data']->reg_obj);
80
-        } else {
81
-            return '';
82
-        }
83
-    }
74
+		//for when [QUESTION_LIST] is used in the [attendee_list] field.
75
+		if ($this->_data['data'] instanceof EE_Registration) {
76
+			return $this->_get_question_answer_list_for_attendee();
77
+		} //for when [QUESTION_LIST] is used in the main content field.
78
+		else if ($this->_data['data'] instanceof EE_Messages_Addressee && $this->_data['data']->reg_obj instanceof EE_Registration) {
79
+			return $this->_get_question_answer_list_for_attendee($this->_data['data']->reg_obj);
80
+		} else {
81
+			return '';
82
+		}
83
+	}
84 84
     
85 85
     
86
-    /**
87
-     * Note when we parse the "[question_list]" shortcode for attendees we're actually going to retrieve the list of
88
-     * answers for that attendee since that is what we really need (we can derive the questions from the answers);
89
-     * @return string parsed template.
90
-     */
91
-    private function _get_question_answer_list_for_attendee($reg_obj = null)
92
-    {
93
-        $valid_shortcodes = array('question');
94
-        $reg_obj          = $reg_obj instanceof EE_Registration ? $reg_obj : $this->_data['data'];
95
-        $template         = is_array($this->_data['template']) && isset($this->_data['template']['question_list']) ? $this->_data['template']['question_list'] : '';
96
-        $template         = empty($template) && isset($this->_extra_data['template']['question_list']) ? $this->_extra_data['template']['question_list'] : $template;
97
-        $ans_result       = '';
98
-        $answers          = ! empty($this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs']) ? $this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs'] : array();
99
-        $questions        = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array();
100
-        foreach ($answers as $answer) {
101
-            //first see if the question is in our $questions array.  If not then try to get from answer object
102
-            $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
103
-            $question = ! $question instanceof EE_Question ? $answer->question() : $question;
104
-            if ($question instanceof EE_Question and $question->admin_only()) {
105
-                continue;
106
-            }
107
-            $ans_result .= $this->_shortcode_helper->parse_question_list_template($template, $answer, $valid_shortcodes,
108
-                $this->_extra_data);
109
-        }
86
+	/**
87
+	 * Note when we parse the "[question_list]" shortcode for attendees we're actually going to retrieve the list of
88
+	 * answers for that attendee since that is what we really need (we can derive the questions from the answers);
89
+	 * @return string parsed template.
90
+	 */
91
+	private function _get_question_answer_list_for_attendee($reg_obj = null)
92
+	{
93
+		$valid_shortcodes = array('question');
94
+		$reg_obj          = $reg_obj instanceof EE_Registration ? $reg_obj : $this->_data['data'];
95
+		$template         = is_array($this->_data['template']) && isset($this->_data['template']['question_list']) ? $this->_data['template']['question_list'] : '';
96
+		$template         = empty($template) && isset($this->_extra_data['template']['question_list']) ? $this->_extra_data['template']['question_list'] : $template;
97
+		$ans_result       = '';
98
+		$answers          = ! empty($this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs']) ? $this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs'] : array();
99
+		$questions        = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array();
100
+		foreach ($answers as $answer) {
101
+			//first see if the question is in our $questions array.  If not then try to get from answer object
102
+			$question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
103
+			$question = ! $question instanceof EE_Question ? $answer->question() : $question;
104
+			if ($question instanceof EE_Question and $question->admin_only()) {
105
+				continue;
106
+			}
107
+			$ans_result .= $this->_shortcode_helper->parse_question_list_template($template, $answer, $valid_shortcodes,
108
+				$this->_extra_data);
109
+		}
110 110
         
111
-        return $ans_result;
112
-    }
111
+		return $ans_result;
112
+	}
113 113
     
114 114
     
115 115
 } //end EE_Question_List_Shortcodes class
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@
 block discarded – undo
99 99
         $questions        = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array();
100 100
         foreach ($answers as $answer) {
101 101
             //first see if the question is in our $questions array.  If not then try to get from answer object
102
-            $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
102
+            $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
103 103
             $question = ! $question instanceof EE_Question ? $answer->question() : $question;
104 104
             if ($question instanceof EE_Question and $question->admin_only()) {
105 105
                 continue;
Please login to merge, or discard this patch.