Completed
Branch BUG-10738-inconsistency-in-ses... (8f6fbc)
by
unknown
74:03 queued 63:31
created
acceptance_tests/Page/CoreAdmin.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -13,96 +13,96 @@
 block discarded – undo
13 13
 class CoreAdmin
14 14
 {
15 15
 
16
-    /**
17
-     * @var string
18
-     */
19
-    const URL_PREFIX = 'admin.php?page=';
20
-
21
-
22
-    /**
23
-     * This is the selector for the next page button on list tables.
24
-     * @var string
25
-     */
26
-    const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page';
27
-
28
-
29
-    /**
30
-     * The selector for the search input submit button on list table pages
31
-     * @var string
32
-     */
33
-    const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit';
34
-
35
-
36
-    /**
37
-     * Selector for the screen options dropdown.
38
-     * @var string
39
-     */
40
-    const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link';
41
-
42
-
43
-    /**
44
-     * Selector for the per page field setting selector (found within screen options dropdown)
45
-     * @var string
46
-     */
47
-    const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page';
48
-
49
-
50
-    /**
51
-     * Selector for apply screen options settings.
52
-     * @var string
53
-     */
54
-    const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply';
55
-
56
-
57
-    /**
58
-     * Selector for bulk action select field on list tables.
59
-     */
60
-    const SELECTOR_LIST_TABLE_BULK_ACTION_FIELD = '#bulk-action-selector-';
61
-
62
-
63
-    /**
64
-     * Selector for applying a bulk action.
65
-     */
66
-    const SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY = '#doaction';
67
-
68
-
69
-    /**
70
-     * Get the EE admin url for the given properties.
71
-     * Note, this is JUST the endpoint for the admin route.  It is expected that the actor/test would be calling this
72
-     * with `amOnAdminPage` action.
73
-     *
74
-     * @param string $page
75
-     * @param string $action
76
-     * @param string $additional_params
77
-     * @return string
78
-     */
79
-    public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '')
80
-    {
81
-        $url = self::URL_PREFIX . $page;
82
-        $url .= $action ? '&action=' . $action : '';
83
-        $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : '';
84
-        return $url;
85
-    }
86
-
87
-
88
-    /**
89
-     * Returns the selector for the text tab switcher for a wp-editor instance.
90
-     * @param $field_reference
91
-     * @return string
92
-     */
93
-    public static function wpEditorTextTabSelector($field_reference)
94
-    {
95
-        return '#content-' . $field_reference . '-content-html';
96
-    }
97
-
98
-
99
-    /**
100
-     * Returns the selector for the textarea exposed when clicing the text tab switcher for a wp-editor instance.
101
-     * @param $field_reference
102
-     * @return string
103
-     */
104
-    public static function wpEditorTextAreaSelector($field_reference)
105
-    {
106
-        return '#content-' . $field_reference . '-content';
107
-    }
16
+	/**
17
+	 * @var string
18
+	 */
19
+	const URL_PREFIX = 'admin.php?page=';
20
+
21
+
22
+	/**
23
+	 * This is the selector for the next page button on list tables.
24
+	 * @var string
25
+	 */
26
+	const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page';
27
+
28
+
29
+	/**
30
+	 * The selector for the search input submit button on list table pages
31
+	 * @var string
32
+	 */
33
+	const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit';
34
+
35
+
36
+	/**
37
+	 * Selector for the screen options dropdown.
38
+	 * @var string
39
+	 */
40
+	const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link';
41
+
42
+
43
+	/**
44
+	 * Selector for the per page field setting selector (found within screen options dropdown)
45
+	 * @var string
46
+	 */
47
+	const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page';
48
+
49
+
50
+	/**
51
+	 * Selector for apply screen options settings.
52
+	 * @var string
53
+	 */
54
+	const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply';
55
+
56
+
57
+	/**
58
+	 * Selector for bulk action select field on list tables.
59
+	 */
60
+	const SELECTOR_LIST_TABLE_BULK_ACTION_FIELD = '#bulk-action-selector-';
61
+
62
+
63
+	/**
64
+	 * Selector for applying a bulk action.
65
+	 */
66
+	const SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY = '#doaction';
67
+
68
+
69
+	/**
70
+	 * Get the EE admin url for the given properties.
71
+	 * Note, this is JUST the endpoint for the admin route.  It is expected that the actor/test would be calling this
72
+	 * with `amOnAdminPage` action.
73
+	 *
74
+	 * @param string $page
75
+	 * @param string $action
76
+	 * @param string $additional_params
77
+	 * @return string
78
+	 */
79
+	public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '')
80
+	{
81
+		$url = self::URL_PREFIX . $page;
82
+		$url .= $action ? '&action=' . $action : '';
83
+		$url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : '';
84
+		return $url;
85
+	}
86
+
87
+
88
+	/**
89
+	 * Returns the selector for the text tab switcher for a wp-editor instance.
90
+	 * @param $field_reference
91
+	 * @return string
92
+	 */
93
+	public static function wpEditorTextTabSelector($field_reference)
94
+	{
95
+		return '#content-' . $field_reference . '-content-html';
96
+	}
97
+
98
+
99
+	/**
100
+	 * Returns the selector for the textarea exposed when clicing the text tab switcher for a wp-editor instance.
101
+	 * @param $field_reference
102
+	 * @return string
103
+	 */
104
+	public static function wpEditorTextAreaSelector($field_reference)
105
+	{
106
+		return '#content-' . $field_reference . '-content';
107
+	}
108 108
 }
Please login to merge, or discard this patch.
acceptance_tests/Page/RegistrationsAdmin.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -11,43 +11,43 @@
 block discarded – undo
11 11
  */
12 12
 class RegistrationsAdmin extends CoreAdmin
13 13
 {
14
-    /**
15
-     * @var string
16
-     */
17
-    const REGISTRATION_STATUS_NOT_APPROVED = 'RNA';
14
+	/**
15
+	 * @var string
16
+	 */
17
+	const REGISTRATION_STATUS_NOT_APPROVED = 'RNA';
18 18
 
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    const REGISTRATION_STATUS_APPROVED = 'RAP';
20
+	/**
21
+	 * @var string
22
+	 */
23
+	const REGISTRATION_STATUS_APPROVED = 'RAP';
24 24
 
25 25
 
26
-    /**
27
-     * @var string
28
-     */
29
-    const REGISTRATION_STATUS_PENDING_PAYMENT = 'RPP';
26
+	/**
27
+	 * @var string
28
+	 */
29
+	const REGISTRATION_STATUS_PENDING_PAYMENT = 'RPP';
30 30
 
31 31
 
32 32
 
33
-    /**
34
-     * @param string $additional_params
35
-     * @return string
36
-     */
37
-    public static function registrationsDefaultAdminListTableUrl($additional_params = '')
38
-    {
39
-        return self::adminUrl('espresso_registrations', 'default', $additional_params);
40
-    }
33
+	/**
34
+	 * @param string $additional_params
35
+	 * @return string
36
+	 */
37
+	public static function registrationsDefaultAdminListTableUrl($additional_params = '')
38
+	{
39
+		return self::adminUrl('espresso_registrations', 'default', $additional_params);
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Given a registration id, this will return the selector for all the checkbox for that id.
45
-     * Assumes the view is a Registration list table.
46
-     * @param int $registration_id
47
-     * @return string
48
-     */
49
-    public static function listTableCheckBoxSelectorForRegistrationId($registration_id)
50
-    {
51
-        return "//input[@name='_REG_ID[]' and @value='{$registration_id}']";
52
-    }
43
+	/**
44
+	 * Given a registration id, this will return the selector for all the checkbox for that id.
45
+	 * Assumes the view is a Registration list table.
46
+	 * @param int $registration_id
47
+	 * @return string
48
+	 */
49
+	public static function listTableCheckBoxSelectorForRegistrationId($registration_id)
50
+	{
51
+		return "//input[@name='_REG_ID[]' and @value='{$registration_id}']";
52
+	}
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Page/EventsAdmin.php 1 patch
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -14,267 +14,267 @@
 block discarded – undo
14 14
 class EventsAdmin extends CoreAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * Selector for the Add new Event button in the admin.
19
-     * @var string
20
-     */
21
-    const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
-
23
-
24
-    /**
25
-     * Selector for the Event Title field in the event editor
26
-     * @var string
27
-     */
28
-    const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
-
30
-    /**
31
-     * Selector for the publish submit button in the event editor.
32
-     * @var string
33
-     */
34
-    const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
-
36
-
37
-    /**
38
-     * Selector for the save button in the event editor
39
-     */
40
-    const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post";
41
-
42
-
43
-    /**
44
-     * @var string
45
-     */
46
-    const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status';
47
-
48
-    /**
49
-     * Selector for the view link after publishing an event.
50
-     * @var string
51
-     */
52
-    const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//span[@id='sample-permalink']/a";
53
-
54
-
55
-    /**
56
-     * Selector for the ID of the event in the event editor
57
-     * @var string
58
-     */
59
-    const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
60
-
61
-
62
-    /**
63
-     * Selector for the search input on the event list table page.
64
-     * @var string
65
-     */
66
-    const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
67
-
68
-
69
-
70
-
71
-    /**
72
-     * @param string $additional_params
73
-     * @return string
74
-     */
75
-    public static function defaultEventsListTableUrl($additional_params = '')
76
-    {
77
-        return self::adminUrl('espresso_events', 'default', $additional_params);
78
-    }
79
-
80
-
81
-    /**
82
-     * The selector for the DTTname field for the given row in the event editor.
83
-     * @param int $row_number
84
-     * @return string
85
-     */
86
-    public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
87
-    {
88
-        return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
89
-    }
90
-
91
-
92
-    /**
93
-     * The selector for the DTT_EVT_start field for the given row in the event editor.d
94
-     * @param int $row_number
95
-     * @return string
96
-     */
97
-    public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
98
-    {
99
-        return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
100
-    }
101
-
102
-
103
-    /**
104
-     * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
105
-     *
106
-     * @param string $field_name
107
-     * @param int    $row_number
108
-     * @return string
109
-     */
110
-    public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
111
-    {
112
-        return "//input[@id='event-datetime-$field_name-$row_number']";
113
-    }
114
-
115
-
116
-    /**
117
-     * The selector for the TKT_name field for the given display row in the event editor.
118
-     * @param int $row_number
119
-     * @return string
120
-     */
121
-    public static function eventEditorTicketNameFieldSelector($row_number = 1)
122
-    {
123
-        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
124
-    }
125
-
126
-
127
-    /**
128
-     * Selector for the TKT_base_price field for the given display row in the event editor.
129
-     * @param int $row_number
130
-     * @return string
131
-     */
132
-    public static function eventEditorTicketPriceFieldSelector($row_number = 1)
133
-    {
134
-        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number);
135
-    }
136
-
137
-
138
-    /**
139
-     * Selector for the TKT_qty field for the given display row in the event editor.
140
-     * @param int $row_number
141
-     * @return string
142
-     */
143
-    public static function eventEditorTicketQuantityFieldSelector($row_number = 1)
144
-    {
145
-        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_qty', $row_number);
146
-    }
147
-
148
-
149
-    /**
150
-     * Selector for the advanced details toggle for the ticket for the given display row in the event editor.
151
-     * @param int $row_number
152
-     * @return string
153
-     */
154
-    public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1)
155
-    {
156
-        return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]";
157
-    }
158
-
159
-
160
-    /**
161
-     * Selector for the subtotal amount for the given display row of the ticket in the event editor.
162
-     * @param int $row_number
163
-     * @return string
164
-     */
165
-    public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1)
166
-    {
167
-        return "//span[@id='price-total-amount-$row_number']";
168
-    }
169
-
170
-
171
-    /**
172
-     * Selector for the Total element for the given display row of the ticket in the event editor.
173
-     * @param int $row_number
174
-     * @return string
175
-     */
176
-    public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1)
177
-    {
178
-        return "//span[@id='price-total-amount-$row_number']";
179
-    }
180
-
181
-
182
-    /**
183
-     * Selector for the taxable selector for the ticket for the given display row in the event editor.
184
-     * @param int $row_number
185
-     * @return string
186
-     */
187
-    public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1)
188
-    {
189
-        return "//input[@id='edit-ticket-TKT_taxable-$row_number']";
190
-    }
191
-
192
-
193
-    /**
194
-     * This returns the xpath locater for the Tax amount display container within the advanced settings view for the
195
-     * given ticket (row) and the given tax id (PRC_ID).
196
-     *
197
-     * @param int $tax_id     The PRC_ID for the tax you want the locater for.  Note, this defaults to the default tax
198
-     *                        setup on a fresh install.
199
-     * @param int $row_number What row representing the ticket you want the locator for.
200
-     * @return string
201
-     */
202
-    public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1)
203
-    {
204
-        return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']";
205
-    }
206
-
207
-
208
-    /**
209
-     * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
210
-     * @param     $field_name
211
-     * @param int $row_number
212
-     * @return string
213
-     */
214
-    public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
215
-    {
216
-        return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]";
217
-    }
218
-
219
-
220
-    /**
221
-     * Returns the selector for the event title edit link in the events list table for the given Event Title.
222
-     * @param string $event_title
223
-     * @return string
224
-     */
225
-    public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
226
-    {
227
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
228
-    }
229
-
230
-
231
-    /**
232
-     * Locator for for the ID column in the event list table for a given event title.
233
-     * @param string $event_title
234
-     * @return string
235
-     */
236
-    public static function eventListTableEventIdSelectorForTitle($event_title)
237
-    {
238
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
239
-               . "//ancestor::tr/th[contains(@class, 'check-column')]/input";
240
-    }
241
-
242
-
243
-    /**
244
-     * Locator for the view link in the row of an event list table for the given event title.
245
-     * @param string $event_title
246
-     * @return string
247
-     */
248
-    public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
249
-    {
250
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
251
-               . "//ancestor::td//span[@class='view']/a";
252
-    }
253
-
254
-
255
-    /**
256
-     * Locator for the messenger tab in the Notifications metabox in the event editor.
257
-     * @param string $messenger_slug  The slug for the messenger (it's reference slug).
258
-     * @return string
259
-     */
260
-    public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)
261
-    {
262
-        return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
263
-               . "//a[@rel='ee-tab-$messenger_slug']";
264
-    }
265
-
266
-
267
-    /**
268
-     * Locator for the select input within the notifications metabox.
269
-     * Note, this assumes the tab content for the related messenger is already visible.
270
-     * @param string $message_type_label The message type label (visible string in the table) you want the selector for.
271
-     * @return string
272
-     */
273
-    public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label)
274
-    {
275
-        return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
276
-               . "//table[@class='messages-custom-template-switcher']"
277
-               . "//tr/td[contains(.,'Registration Approved')]"
278
-               . "//ancestor::tr//select[contains(@class,'message-template-selector')]";
279
-    }
17
+	/**
18
+	 * Selector for the Add new Event button in the admin.
19
+	 * @var string
20
+	 */
21
+	const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
+
23
+
24
+	/**
25
+	 * Selector for the Event Title field in the event editor
26
+	 * @var string
27
+	 */
28
+	const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
+
30
+	/**
31
+	 * Selector for the publish submit button in the event editor.
32
+	 * @var string
33
+	 */
34
+	const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
+
36
+
37
+	/**
38
+	 * Selector for the save button in the event editor
39
+	 */
40
+	const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post";
41
+
42
+
43
+	/**
44
+	 * @var string
45
+	 */
46
+	const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status';
47
+
48
+	/**
49
+	 * Selector for the view link after publishing an event.
50
+	 * @var string
51
+	 */
52
+	const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//span[@id='sample-permalink']/a";
53
+
54
+
55
+	/**
56
+	 * Selector for the ID of the event in the event editor
57
+	 * @var string
58
+	 */
59
+	const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
60
+
61
+
62
+	/**
63
+	 * Selector for the search input on the event list table page.
64
+	 * @var string
65
+	 */
66
+	const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
67
+
68
+
69
+
70
+
71
+	/**
72
+	 * @param string $additional_params
73
+	 * @return string
74
+	 */
75
+	public static function defaultEventsListTableUrl($additional_params = '')
76
+	{
77
+		return self::adminUrl('espresso_events', 'default', $additional_params);
78
+	}
79
+
80
+
81
+	/**
82
+	 * The selector for the DTTname field for the given row in the event editor.
83
+	 * @param int $row_number
84
+	 * @return string
85
+	 */
86
+	public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
87
+	{
88
+		return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
89
+	}
90
+
91
+
92
+	/**
93
+	 * The selector for the DTT_EVT_start field for the given row in the event editor.d
94
+	 * @param int $row_number
95
+	 * @return string
96
+	 */
97
+	public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
98
+	{
99
+		return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
100
+	}
101
+
102
+
103
+	/**
104
+	 * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
105
+	 *
106
+	 * @param string $field_name
107
+	 * @param int    $row_number
108
+	 * @return string
109
+	 */
110
+	public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
111
+	{
112
+		return "//input[@id='event-datetime-$field_name-$row_number']";
113
+	}
114
+
115
+
116
+	/**
117
+	 * The selector for the TKT_name field for the given display row in the event editor.
118
+	 * @param int $row_number
119
+	 * @return string
120
+	 */
121
+	public static function eventEditorTicketNameFieldSelector($row_number = 1)
122
+	{
123
+		return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
124
+	}
125
+
126
+
127
+	/**
128
+	 * Selector for the TKT_base_price field for the given display row in the event editor.
129
+	 * @param int $row_number
130
+	 * @return string
131
+	 */
132
+	public static function eventEditorTicketPriceFieldSelector($row_number = 1)
133
+	{
134
+		return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number);
135
+	}
136
+
137
+
138
+	/**
139
+	 * Selector for the TKT_qty field for the given display row in the event editor.
140
+	 * @param int $row_number
141
+	 * @return string
142
+	 */
143
+	public static function eventEditorTicketQuantityFieldSelector($row_number = 1)
144
+	{
145
+		return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_qty', $row_number);
146
+	}
147
+
148
+
149
+	/**
150
+	 * Selector for the advanced details toggle for the ticket for the given display row in the event editor.
151
+	 * @param int $row_number
152
+	 * @return string
153
+	 */
154
+	public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1)
155
+	{
156
+		return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]";
157
+	}
158
+
159
+
160
+	/**
161
+	 * Selector for the subtotal amount for the given display row of the ticket in the event editor.
162
+	 * @param int $row_number
163
+	 * @return string
164
+	 */
165
+	public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1)
166
+	{
167
+		return "//span[@id='price-total-amount-$row_number']";
168
+	}
169
+
170
+
171
+	/**
172
+	 * Selector for the Total element for the given display row of the ticket in the event editor.
173
+	 * @param int $row_number
174
+	 * @return string
175
+	 */
176
+	public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1)
177
+	{
178
+		return "//span[@id='price-total-amount-$row_number']";
179
+	}
180
+
181
+
182
+	/**
183
+	 * Selector for the taxable selector for the ticket for the given display row in the event editor.
184
+	 * @param int $row_number
185
+	 * @return string
186
+	 */
187
+	public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1)
188
+	{
189
+		return "//input[@id='edit-ticket-TKT_taxable-$row_number']";
190
+	}
191
+
192
+
193
+	/**
194
+	 * This returns the xpath locater for the Tax amount display container within the advanced settings view for the
195
+	 * given ticket (row) and the given tax id (PRC_ID).
196
+	 *
197
+	 * @param int $tax_id     The PRC_ID for the tax you want the locater for.  Note, this defaults to the default tax
198
+	 *                        setup on a fresh install.
199
+	 * @param int $row_number What row representing the ticket you want the locator for.
200
+	 * @return string
201
+	 */
202
+	public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1)
203
+	{
204
+		return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']";
205
+	}
206
+
207
+
208
+	/**
209
+	 * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
210
+	 * @param     $field_name
211
+	 * @param int $row_number
212
+	 * @return string
213
+	 */
214
+	public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
215
+	{
216
+		return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]";
217
+	}
218
+
219
+
220
+	/**
221
+	 * Returns the selector for the event title edit link in the events list table for the given Event Title.
222
+	 * @param string $event_title
223
+	 * @return string
224
+	 */
225
+	public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
226
+	{
227
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
228
+	}
229
+
230
+
231
+	/**
232
+	 * Locator for for the ID column in the event list table for a given event title.
233
+	 * @param string $event_title
234
+	 * @return string
235
+	 */
236
+	public static function eventListTableEventIdSelectorForTitle($event_title)
237
+	{
238
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
239
+			   . "//ancestor::tr/th[contains(@class, 'check-column')]/input";
240
+	}
241
+
242
+
243
+	/**
244
+	 * Locator for the view link in the row of an event list table for the given event title.
245
+	 * @param string $event_title
246
+	 * @return string
247
+	 */
248
+	public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
249
+	{
250
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
251
+			   . "//ancestor::td//span[@class='view']/a";
252
+	}
253
+
254
+
255
+	/**
256
+	 * Locator for the messenger tab in the Notifications metabox in the event editor.
257
+	 * @param string $messenger_slug  The slug for the messenger (it's reference slug).
258
+	 * @return string
259
+	 */
260
+	public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)
261
+	{
262
+		return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
263
+			   . "//a[@rel='ee-tab-$messenger_slug']";
264
+	}
265
+
266
+
267
+	/**
268
+	 * Locator for the select input within the notifications metabox.
269
+	 * Note, this assumes the tab content for the related messenger is already visible.
270
+	 * @param string $message_type_label The message type label (visible string in the table) you want the selector for.
271
+	 * @return string
272
+	 */
273
+	public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label)
274
+	{
275
+		return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
276
+			   . "//table[@class='messages-custom-template-switcher']"
277
+			   . "//tr/td[contains(.,'Registration Approved')]"
278
+			   . "//ancestor::tr//select[contains(@class,'message-template-selector')]";
279
+	}
280 280
 }
Please login to merge, or discard this patch.
acceptance_tests/Page/Checkout.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -13,62 +13,62 @@
 block discarded – undo
13 13
 class Checkout
14 14
 {
15 15
 
16
-    /**
17
-     * The class selector for the next step button in the checkout.
18
-     * @var string
19
-     */
20
-    const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn';
16
+	/**
17
+	 * The class selector for the next step button in the checkout.
18
+	 * @var string
19
+	 */
20
+	const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn';
21 21
 
22 22
 
23
-    const PAYMENT_METHOD_STEP_FORM = '#ee-spco-payment_options-reg-step-form';
23
+	const PAYMENT_METHOD_STEP_FORM = '#ee-spco-payment_options-reg-step-form';
24 24
 
25 25
 
26
-    /**
27
-     * @param int $attendee_number
28
-     * @return string
29
-     */
30
-    public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1)
31
-    {
32
-        return self::fieldSelectorForAttendeeNumber('fname', $attendee_number);
33
-    }
26
+	/**
27
+	 * @param int $attendee_number
28
+	 * @return string
29
+	 */
30
+	public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1)
31
+	{
32
+		return self::fieldSelectorForAttendeeNumber('fname', $attendee_number);
33
+	}
34 34
 
35 35
 
36
-    /**
37
-     * @param int $attendee_number
38
-     * @return string
39
-     */
40
-    public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1)
41
-    {
42
-        return self::fieldSelectorForAttendeeNumber('lname', $attendee_number);
43
-    }
36
+	/**
37
+	 * @param int $attendee_number
38
+	 * @return string
39
+	 */
40
+	public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1)
41
+	{
42
+		return self::fieldSelectorForAttendeeNumber('lname', $attendee_number);
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * @param int $attendee_number
48
-     * @return string
49
-     */
50
-    public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1)
51
-    {
52
-        return self::fieldSelectorForAttendeeNumber('email', $attendee_number);
53
-    }
46
+	/**
47
+	 * @param int $attendee_number
48
+	 * @return string
49
+	 */
50
+	public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1)
51
+	{
52
+		return self::fieldSelectorForAttendeeNumber('email', $attendee_number);
53
+	}
54 54
 
55
-    /**
56
-     * @param     $field_name
57
-     * @param int $attendee_number
58
-     * @return string
59
-     */
60
-    public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1)
61
-    {
62
-        return "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]";
63
-    }
55
+	/**
56
+	 * @param     $field_name
57
+	 * @param int $attendee_number
58
+	 * @return string
59
+	 */
60
+	public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1)
61
+	{
62
+		return "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]";
63
+	}
64 64
 
65 65
 
66
-    /**
67
-     * @param string $payment_method_slug Slug for the payment method.
68
-     * @return string
69
-     */
70
-    public static function fieldSelectorForPaymentOption($payment_method_slug)
71
-    {
72
-        return "#ee-available-payment-method-inputs-{$payment_method_slug}";
73
-    }
66
+	/**
67
+	 * @param string $payment_method_slug Slug for the payment method.
68
+	 * @return string
69
+	 */
70
+	public static function fieldSelectorForPaymentOption($payment_method_slug)
71
+	{
72
+		return "#ee-available-payment-method-inputs-{$payment_method_slug}";
73
+	}
74 74
 }
Please login to merge, or discard this patch.
acceptance_tests/Page/MessagesAdmin.php 1 patch
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -14,289 +14,289 @@
 block discarded – undo
14 14
 class MessagesAdmin extends CoreAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * Context slug for the admin messages context.
19
-     */
20
-    const ADMIN_CONTEXT_SLUG = 'admin';
17
+	/**
18
+	 * Context slug for the admin messages context.
19
+	 */
20
+	const ADMIN_CONTEXT_SLUG = 'admin';
21 21
 
22
-    /**
23
-     * Context slug for the primary attendee messages context
24
-     */
25
-    const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
22
+	/**
23
+	 * Context slug for the primary attendee messages context
24
+	 */
25
+	const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
26 26
 
27 27
 
28
-    /**
29
-     * Context slug for the attendee messages context
30
-     */
31
-    const ATTENDEE_CONTEXT_SLUG = 'attendee';
28
+	/**
29
+	 * Context slug for the attendee messages context
30
+	 */
31
+	const ATTENDEE_CONTEXT_SLUG = 'attendee';
32 32
 
33 33
 
34
-    /**
35
-     * Status reference for the EEM_Message::status_sent status.
36
-     */
37
-    const MESSAGE_STATUS_SENT = 'MSN';
34
+	/**
35
+	 * Status reference for the EEM_Message::status_sent status.
36
+	 */
37
+	const MESSAGE_STATUS_SENT = 'MSN';
38 38
 
39 39
 
40
-    /**
41
-     * Message type slug for the Payment Failed message type
42
-     */
43
-    const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
40
+	/**
41
+	 * Message type slug for the Payment Failed message type
42
+	 */
43
+	const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
44 44
 
45 45
 
46
-    /**
47
-     * Message type slug for the Registration Pending Payment message type
48
-     */
49
-    const MESSAGE_TYPE_PENDING_PAYMENT = 'pending_approval';
46
+	/**
47
+	 * Message type slug for the Registration Pending Payment message type
48
+	 */
49
+	const MESSAGE_TYPE_PENDING_PAYMENT = 'pending_approval';
50 50
 
51 51
 
52
-    /**
53
-     * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
54
-     */
55
-    const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR =
56
-        '#global_messages_settings-do-messages-on-same-request';
52
+	/**
53
+	 * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
54
+	 */
55
+	const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR =
56
+		'#global_messages_settings-do-messages-on-same-request';
57 57
 
58 58
 
59
-    /**
60
-     * Selector for the Global Messages Settings submit button in the Messages Settings tab.
61
-     */
62
-    const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
59
+	/**
60
+	 * Selector for the Global Messages Settings submit button in the Messages Settings tab.
61
+	 */
62
+	const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
63 63
 
64 64
 
65
-    /**
66
-     * This is the container where active message types for a messenger are found/dragged to.
67
-     */
68
-    const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types';
65
+	/**
66
+	 * This is the container where active message types for a messenger are found/dragged to.
67
+	 */
68
+	const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types';
69 69
 
70 70
 
71
-    /**
72
-     * Locator for the context switcher selector on the Message Template Editor page.
73
-     */
74
-    const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select";
71
+	/**
72
+	 * Locator for the context switcher selector on the Message Template Editor page.
73
+	 */
74
+	const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select";
75 75
 
76
-
77
-    /**
78
-     * Locator for the context switcher submit button in the Message Template Editor page.
79
-     */
80
-    const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt";
81
-
82
-
83
-    /**
84
-     * Locator for the dialog container used for housing viewed messages in the message activity list table.
85
-     */
86
-    const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content';
87
-
88
-
89
-    /**
90
-     * Returns the selector for the on/off toggle for context on the message template editor.
91
-     */
92
-    const MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE =
93
-        "//div[@class='activate_context_on_off_toggle_container']/div[@class='switch']/label";
94
-
95
-
96
-
97
-    /**
98
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
99
-     *                                  a string.
100
-     * @return string
101
-     */
102
-    public static function messageActivityListTableUrl($additional_params = '')
103
-    {
104
-        return self::adminUrl('espresso_messages', 'default', $additional_params);
105
-    }
106
-
107
-
108
-    /**
109
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
110
-     *                                  a string.
111
-     * @return string
112
-     */
113
-    public static function defaultMessageTemplateListTableUrl($additional_params = '')
114
-    {
115
-        return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
116
-    }
117
-
118
-
119
-    /**
120
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
121
-     *                                  a string.
122
-     * @return string
123
-     */
124
-    public static function customMessageTemplateListTableUrl($additional_params = '')
125
-    {
126
-        return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
127
-    }
128
-
129
-
130
-    /**
131
-     * @return string
132
-     */
133
-    public static function messageSettingsUrl()
134
-    {
135
-        return self::adminUrl('espresso_messages', 'settings');
136
-    }
137
-
138
-
139
-
140
-    public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger(
141
-        $message_type_slug,
142
-        $messenger_slug = 'email'
143
-    ) {
144
-        return "#$message_type_slug-messagetype-$messenger_slug";
145
-    }
146
-
147
-
148
-    /**
149
-     * @param string $message_type_slug
150
-     * @param string $context
151
-     * @return string
152
-     */
153
-    public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
154
-    {
155
-        return $context
156
-            ? '.' . $message_type_slug . '-' . $context . '-edit-link'
157
-            : '.' . $message_type_slug . '-edit-link';
158
-    }
159
-
160
-
161
-    /**
162
-     * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
163
-     *
164
-     * @param        $field
165
-     * @param        $message_type_label
166
-     * @param string $message_status
167
-     * @param string $messenger
168
-     * @param string $context
169
-     * @param string $table_cell_content_for_field
170
-     * @param int    $number_in_set   It's possible that the given parameters could match multiple items in the view.
171
-     *                                This allows you to indicate which item from the set to match.  If this is set to 0
172
-     *                                then all matches for the locator will be returned.
173
-     * @return string
174
-     * @throws \InvalidArgumentException
175
-     */
176
-    public static function messagesActivityListTableCellSelectorFor(
177
-        $field,
178
-        $message_type_label,
179
-        $message_status = self::MESSAGE_STATUS_SENT,
180
-        $messenger = 'Email',
181
-        $context = 'Event Admin',
182
-        $table_cell_content_for_field = '',
183
-        $number_in_set = 1
184
-    ) {
185
-        $selector = "//tbody[@id='the-list']";
186
-        $selector .= "//tr[contains(@class, 'msg-status-$message_status')]"
187
-                     . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
188
-        if ($messenger) {
189
-            $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
190
-        }
191
-        $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
192
-        $selector .= $table_cell_content_for_field
193
-            ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
194
-            : "/ancestor::tr/td[contains(@class, 'column-$field')]";
195
-        return $number_in_set > 0 ? Locator::elementAt($selector, $number_in_set) : $selector;
196
-    }
197
-
198
-
199
-    /**
200
-     * Selector for the Create Custom button found in the message template list table.
201
-     * @param string $message_type_label
202
-     * @param string $messenger_label
203
-     * @return string
204
-     */
205
-    public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label)
206
-    {
207
-        $selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']"
208
-                    . "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]"
209
-                    . "//ancestor::tr/td/a[@class='button button-small']";
210
-        return $selector;
211
-    }
212
-
213
-
214
-    /**
215
-     * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to
216
-     * the FIRST match (which will be the latest message sent if the table is default sorted).
217
-     *
218
-     * @param string $message_type_label    The visible message type label for the row you want to match
219
-     * @param string $message_status        The status of the message for the row you want to match.
220
-     * @param string $messenger             The visible messenger label for the row you want to match.
221
-     * @param string $context               The visible context label for the row you want to match.
222
-     * @param int    $number_in_set         It's possible that the given parameters could match multiple items in the
223
-     *                                      view. This allows you to indicate which item from the set to match.
224
-     * @return string
225
-     * @throws \InvalidArgumentException
226
-     */
227
-    public static function messagesActivityListTableViewButtonSelectorFor(
228
-        $message_type_label,
229
-        $message_status = self::MESSAGE_STATUS_SENT,
230
-        $messenger = 'Email',
231
-        $context = 'Event Admin',
232
-        $number_in_set = 1
233
-    ) {
234
-        $selector = self::messagesActivityListTableCellSelectorFor(
235
-            'action',
236
-            $message_type_label,
237
-            $message_status,
238
-            $messenger,
239
-            $context,
240
-            '',
241
-            $number_in_set
242
-        );
243
-        $selector .= "/a/span[contains(@class, 'ee-message-action-link-view')"
244
-                     . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]";
245
-        return $selector;
246
-    }
247
-
248
-
249
-    /**
250
-     * Locator for the delete action link for a message item in the message activity list table.
251
-     * Note: The link is not visible by default, so the column would need hovered over for the link to appear.
252
-     *
253
-     * @param        $message_type_label
254
-     * @param string $message_status
255
-     * @param string $messenger
256
-     * @param string $context
257
-     * @param int    $number_in_set
258
-     * @return string
259
-     * @throws \InvalidArgumentException
260
-     */
261
-    public static function messagesActivityListTableDeleteActionSelectorFor(
262
-        $message_type_label,
263
-        $message_status = self::MESSAGE_STATUS_SENT,
264
-        $messenger = 'Email',
265
-        $context = 'Event Admin',
266
-        $number_in_set = 1
267
-    ) {
268
-        $selector = self::messagesActivityListTableCellSelectorFor(
269
-            'to',
270
-            $message_type_label,
271
-            $message_status,
272
-            $messenger,
273
-            $context,
274
-            '',
275
-            $number_in_set
276
-        );
277
-        $selector .= "/div/span[@class='delete']/a";
278
-        return $selector;
279
-    }
280
-
281
-
282
-
283
-    /**
284
-     * Returns the input selector for a given field in the message template editor.
285
-     * Assumes one is already viewing the Message Template Editor.
286
-     * @param string     $field
287
-     * @return string
288
-     */
289
-    public static function messageInputFieldSelectorFor($field)
290
-    {
291
-        return "//div[@id='post-body']//input[@id='$field-content']";
292
-    }
293
-
294
-
295
-    /**
296
-     * Wrapper for self::messageInputFieldSelectorFor('to') that takes care of getting the input for the To field.
297
-     */
298
-    public static function messageTemplateToFieldSelector()
299
-    {
300
-        return self::messageInputFieldSelectorFor('to');
301
-    }
76
+
77
+	/**
78
+	 * Locator for the context switcher submit button in the Message Template Editor page.
79
+	 */
80
+	const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt";
81
+
82
+
83
+	/**
84
+	 * Locator for the dialog container used for housing viewed messages in the message activity list table.
85
+	 */
86
+	const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content';
87
+
88
+
89
+	/**
90
+	 * Returns the selector for the on/off toggle for context on the message template editor.
91
+	 */
92
+	const MESSAGES_CONTEXT_ACTIVE_STATE_TOGGLE =
93
+		"//div[@class='activate_context_on_off_toggle_container']/div[@class='switch']/label";
94
+
95
+
96
+
97
+	/**
98
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
99
+	 *                                  a string.
100
+	 * @return string
101
+	 */
102
+	public static function messageActivityListTableUrl($additional_params = '')
103
+	{
104
+		return self::adminUrl('espresso_messages', 'default', $additional_params);
105
+	}
106
+
107
+
108
+	/**
109
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
110
+	 *                                  a string.
111
+	 * @return string
112
+	 */
113
+	public static function defaultMessageTemplateListTableUrl($additional_params = '')
114
+	{
115
+		return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
116
+	}
117
+
118
+
119
+	/**
120
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
121
+	 *                                  a string.
122
+	 * @return string
123
+	 */
124
+	public static function customMessageTemplateListTableUrl($additional_params = '')
125
+	{
126
+		return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
127
+	}
128
+
129
+
130
+	/**
131
+	 * @return string
132
+	 */
133
+	public static function messageSettingsUrl()
134
+	{
135
+		return self::adminUrl('espresso_messages', 'settings');
136
+	}
137
+
138
+
139
+
140
+	public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger(
141
+		$message_type_slug,
142
+		$messenger_slug = 'email'
143
+	) {
144
+		return "#$message_type_slug-messagetype-$messenger_slug";
145
+	}
146
+
147
+
148
+	/**
149
+	 * @param string $message_type_slug
150
+	 * @param string $context
151
+	 * @return string
152
+	 */
153
+	public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
154
+	{
155
+		return $context
156
+			? '.' . $message_type_slug . '-' . $context . '-edit-link'
157
+			: '.' . $message_type_slug . '-edit-link';
158
+	}
159
+
160
+
161
+	/**
162
+	 * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
163
+	 *
164
+	 * @param        $field
165
+	 * @param        $message_type_label
166
+	 * @param string $message_status
167
+	 * @param string $messenger
168
+	 * @param string $context
169
+	 * @param string $table_cell_content_for_field
170
+	 * @param int    $number_in_set   It's possible that the given parameters could match multiple items in the view.
171
+	 *                                This allows you to indicate which item from the set to match.  If this is set to 0
172
+	 *                                then all matches for the locator will be returned.
173
+	 * @return string
174
+	 * @throws \InvalidArgumentException
175
+	 */
176
+	public static function messagesActivityListTableCellSelectorFor(
177
+		$field,
178
+		$message_type_label,
179
+		$message_status = self::MESSAGE_STATUS_SENT,
180
+		$messenger = 'Email',
181
+		$context = 'Event Admin',
182
+		$table_cell_content_for_field = '',
183
+		$number_in_set = 1
184
+	) {
185
+		$selector = "//tbody[@id='the-list']";
186
+		$selector .= "//tr[contains(@class, 'msg-status-$message_status')]"
187
+					 . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
188
+		if ($messenger) {
189
+			$selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
190
+		}
191
+		$selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
192
+		$selector .= $table_cell_content_for_field
193
+			? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
194
+			: "/ancestor::tr/td[contains(@class, 'column-$field')]";
195
+		return $number_in_set > 0 ? Locator::elementAt($selector, $number_in_set) : $selector;
196
+	}
197
+
198
+
199
+	/**
200
+	 * Selector for the Create Custom button found in the message template list table.
201
+	 * @param string $message_type_label
202
+	 * @param string $messenger_label
203
+	 * @return string
204
+	 */
205
+	public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label)
206
+	{
207
+		$selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']"
208
+					. "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]"
209
+					. "//ancestor::tr/td/a[@class='button button-small']";
210
+		return $selector;
211
+	}
212
+
213
+
214
+	/**
215
+	 * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to
216
+	 * the FIRST match (which will be the latest message sent if the table is default sorted).
217
+	 *
218
+	 * @param string $message_type_label    The visible message type label for the row you want to match
219
+	 * @param string $message_status        The status of the message for the row you want to match.
220
+	 * @param string $messenger             The visible messenger label for the row you want to match.
221
+	 * @param string $context               The visible context label for the row you want to match.
222
+	 * @param int    $number_in_set         It's possible that the given parameters could match multiple items in the
223
+	 *                                      view. This allows you to indicate which item from the set to match.
224
+	 * @return string
225
+	 * @throws \InvalidArgumentException
226
+	 */
227
+	public static function messagesActivityListTableViewButtonSelectorFor(
228
+		$message_type_label,
229
+		$message_status = self::MESSAGE_STATUS_SENT,
230
+		$messenger = 'Email',
231
+		$context = 'Event Admin',
232
+		$number_in_set = 1
233
+	) {
234
+		$selector = self::messagesActivityListTableCellSelectorFor(
235
+			'action',
236
+			$message_type_label,
237
+			$message_status,
238
+			$messenger,
239
+			$context,
240
+			'',
241
+			$number_in_set
242
+		);
243
+		$selector .= "/a/span[contains(@class, 'ee-message-action-link-view')"
244
+					 . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]";
245
+		return $selector;
246
+	}
247
+
248
+
249
+	/**
250
+	 * Locator for the delete action link for a message item in the message activity list table.
251
+	 * Note: The link is not visible by default, so the column would need hovered over for the link to appear.
252
+	 *
253
+	 * @param        $message_type_label
254
+	 * @param string $message_status
255
+	 * @param string $messenger
256
+	 * @param string $context
257
+	 * @param int    $number_in_set
258
+	 * @return string
259
+	 * @throws \InvalidArgumentException
260
+	 */
261
+	public static function messagesActivityListTableDeleteActionSelectorFor(
262
+		$message_type_label,
263
+		$message_status = self::MESSAGE_STATUS_SENT,
264
+		$messenger = 'Email',
265
+		$context = 'Event Admin',
266
+		$number_in_set = 1
267
+	) {
268
+		$selector = self::messagesActivityListTableCellSelectorFor(
269
+			'to',
270
+			$message_type_label,
271
+			$message_status,
272
+			$messenger,
273
+			$context,
274
+			'',
275
+			$number_in_set
276
+		);
277
+		$selector .= "/div/span[@class='delete']/a";
278
+		return $selector;
279
+	}
280
+
281
+
282
+
283
+	/**
284
+	 * Returns the input selector for a given field in the message template editor.
285
+	 * Assumes one is already viewing the Message Template Editor.
286
+	 * @param string     $field
287
+	 * @return string
288
+	 */
289
+	public static function messageInputFieldSelectorFor($field)
290
+	{
291
+		return "//div[@id='post-body']//input[@id='$field-content']";
292
+	}
293
+
294
+
295
+	/**
296
+	 * Wrapper for self::messageInputFieldSelectorFor('to') that takes care of getting the input for the To field.
297
+	 */
298
+	public static function messageTemplateToFieldSelector()
299
+	{
300
+		return self::messageInputFieldSelectorFor('to');
301
+	}
302 302
 }
303 303
\ No newline at end of file
Please login to merge, or discard this patch.
core/libraries/messages/EE_message_type.lib.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -825,7 +825,7 @@
 block discarded – undo
825 825
      * Takes care of setting up the addressee object(s) for the primary attendee.
826 826
      *
827 827
      * @access protected
828
-     * @return array of EE_Addressee objects
828
+     * @return EE_Messages_Addressee[] of EE_Addressee objects
829 829
      */
830 830
     protected function _primary_attendee_addressees()
831 831
     {
Please login to merge, or discard this patch.
Indentation   +895 added lines, -895 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
 
@@ -18,906 +18,906 @@  discard block
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * message type child classes will set what contexts are associated with the message type via this array.
23
-     * format:
24
-     * array(
25
-     * 'context' => array(
26
-     *        'label' => __('Context Label', 'event_espresso'),
27
-     *        'description' => __('Context description (for help popups)', 'event_espresso')
28
-     *    ));
29
-     *
30
-     * @var array
31
-     */
32
-    protected $_contexts = array();
33
-
34
-
35
-    /**
36
-     * This property is used to define what the display label will be for contexts (eg. "Recipients", "Themes" etc.)
37
-     * Format:
38
-     * array( 'label' => 'something', 'plural' => 'somethings', 'description' => 'something' );
39
-     *
40
-     * @var array
41
-     */
42
-    protected $_context_label;
43
-
44
-
45
-    /** MESSAGE ASSEMBLING PROPERTIES **/
46
-    /**
47
-     * This parameter simply holds all the message objects for retrieval by the controller and sending to the messenger.
48
-     *
49
-     * @var array of message objects.
50
-     */
51
-    public $messages = array();
52
-
53
-    /**
54
-     * The following holds the templates that will be used to assemble the message object for the messenger.
55
-     *
56
-     * @var array
57
-     */
58
-    protected $_templates;
59
-
60
-
61
-    /**
62
-     * If a specific template is being parsed, this will hold the message template group GRP_ID for that template.
63
-     *
64
-     * @var int.
65
-     */
66
-    protected $_GRP_ID;
67
-
68
-
69
-    /** OTHER INFO PROPERTIES **/
70
-    /**
71
-     * This will hold the count of the message objects in the messages array. This could be used for determining if
72
-     * batching/queueing is needed.
73
-     *
74
-     * @var int
75
-     */
76
-    public $count = 0;
77
-
78
-
79
-    /**
80
-     * This is set via the `do_messenger_hooks` method and contains the messenger being used to send the message of
81
-     * this message type at time of sending.
82
-     *
83
-     * @var EE_messenger
84
-     */
85
-    protected $_active_messenger;
86
-
87
-
88
-    /**
89
-     * This will hold the shortcode_replace instance for handling replacement of shortcodes in the various templates
90
-     *
91
-     * @var object
92
-     */
93
-    protected $_shortcode_replace;
94
-
95
-
96
-    /**
97
-     * The purpose for this property is to simply allow message types to indicate if the message generated is intended
98
-     * for only single context.  Child message types should redefine this variable (if necessary) in the
99
-     * _set_data_Handler() method.
100
-     *
101
-     * @var boolean
102
-     */
103
-    protected $_single_message = false;
104
-
105
-
106
-    /**
107
-     * This will hold an array of specific reg_ids that are receiving messages.
108
-     *
109
-     * @since 4.7.x
110
-     * @var array
111
-     */
112
-    protected $_regs_for_sending = array();
113
-
114
-
115
-    /**
116
-     * This holds the data passed to this class from the controller and also the final processed data.
117
-     *
118
-     * @var object
119
-     */
120
-    protected $_data;
121
-
122
-
123
-    /**
124
-     * this is just a flag indicating whether we're in preview mode or not.
125
-     *
126
-     * @var bool
127
-     */
128
-    protected $_preview = false;
129
-
130
-
131
-    /**
132
-     * This just holds defaults for addressee data that children merge with their data array setup
133
-     *
134
-     * @var array
135
-     */
136
-    protected $_default_addressee_data;
137
-
138
-
139
-    /**
140
-     * Child classes declare through this property what handler they want to use for the incoming data and this string
141
-     * is used to instantiate the EE_Messages_incoming_data child class for that handler.
142
-     *
143
-     * @var string
144
-     */
145
-    protected $_data_handler;
146
-
147
-
148
-    /**
149
-     * This holds any specific fields for holding any settings related to a message type (if any needed)
150
-     *
151
-     * @var array
152
-     */
153
-    protected $_admin_settings_fields = array();
154
-
155
-    /**
156
-     * this property will hold any existing setting that may have been set in the admin.
157
-     *
158
-     * @var array
159
-     */
160
-    protected $_existing_admin_settings = array();
161
-
162
-
163
-    /**
164
-     * This is used to designate the generating and alternative sending messengers for a message type.  It is set via
165
-     * set_with_messengers() on construct. Note, generating messenger also acts as a sending messenger for this message
166
-     * type.  However ONLY the generating messengers are used for creating templates for this message type. Should be
167
-     * in this format:
168
-     * {
169
-     *
170
-     * @type string $generating_messenger the name of the generating messenger.  Generating
171
-     *                                          messengers are used for generating templates,
172
-     *                                          doing validation and defining valid shortcodes.
173
-     *      {
174
-     * @type string $sending_messenger    values are the name(s) for the sending
175
-     *                                              messengers.  sending messengers are
176
-     *                                              just valid delivery vehicles that will utilize
177
-     *                                              the templates (and generated EE_message
178
-     *                                              objects from the generating messengers).
179
-     *      }
180
-     * }
181
-     * @since                             4.5.0
182
-     * @var array
183
-     */
184
-    protected $_with_messengers = array();
185
-
186
-
187
-    /**
188
-     * This holds the addressees in an array indexed by context for later retrieval when assembling the message objects.
189
-     *
190
-     * @access protected
191
-     * @var array
192
-     */
193
-    protected $_addressees = array();
194
-
195
-
196
-    /**
197
-     * This allows each message type to set what alternate messenger&message type combination can be used for fallback
198
-     * default templates if there are no specific ones defined for this messenger and message type.  Should be in the
199
-     * format:
200
-     * array(
201
-     *      'messenger' => 'message_type',
202
-     *      'another_messenger' => another_message_type
203
-     * );
204
-     * This is set in the message type constructor.
205
-     *
206
-     * @var array
207
-     */
208
-    protected $_master_templates = array();
209
-
210
-
211
-    /**
212
-     * This holds whatever the set template pack is for a message template group when generating messages.
213
-     *
214
-     * @since 4.5.0
215
-     * @var EE_Messages_Template_Pack
216
-     */
217
-    protected $_template_pack;
218
-
219
-
220
-    /**
221
-     * This holds whatever the set variation is for a message template group when generating messages.
222
-     *
223
-     * @since 4.5.0
224
-     * @var string
225
-     */
226
-    protected $_variation;
227
-
228
-
229
-    /**
230
-     * EE_message_type constructor.
231
-     */
232
-    public function __construct()
233
-    {
234
-        $this->_messages_item_type = 'message_type';
235
-        $this->_set_contexts();
236
-        $this->_set_with_messengers();
237
-        parent::__construct();
238
-    }
239
-
240
-
241
-    /**
242
-     * This sets the data handler for the message type.  It must be used to define the _data_handler property.  It is
243
-     * called when messages are setup.
244
-     *
245
-     * @abstract
246
-     * @access protected
247
-     * @return void
248
-     */
249
-    abstract protected function _set_data_handler();
250
-
251
-
252
-    /**
253
-     * This method should return a EE_Base_Class object (or array of EE_Base_Class objects) for the given context and
254
-     * ID (which should be the primary key id for the base class).  Client code doesn't have to know what a message
255
-     * type's data handler is.
256
-     *
257
-     * @since 4.5.0
258
-     * @param string          $context      This should be a string matching a valid context for the message type.
259
-     * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
260
-     *                                      guessing a url).
261
-     * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
262
-     *                                      EE_Base_Class_Object
263
-     * @return mixed ( EE_Base_Class||EE_Base_Class[] )
264
-     */
265
-    abstract protected function _get_data_for_context($context, EE_Registration $registration, $id);
266
-
267
-
268
-    /**
269
-     * _set_contexts
270
-     * This sets up the contexts associated with the message_type
271
-     *
272
-     * @abstract
273
-     * @access  protected
274
-     * @return  void
275
-     */
276
-    abstract protected function _set_contexts();
277
-
278
-
279
-    /**
280
-     * This is used to get the "id" value fo the msg_trigger_url generated by get_url_trigger().
281
-     * In most cases, child classes don't need anything, (hence the default of 0), however if there is a specific
282
-     * EE_Base_Class that is required in generating a message for a message type recipient then the message
283
-     * type should override this method and use the given params to generate the correct ID.
284
-     *
285
-     * @param string          $context      The message type context.
286
-     * @param EE_Registration $registration Registration object
287
-     * @deprecated 4.9.0
288
-     * @return int
289
-     */
290
-    protected function _get_id_for_msg_url($context, EE_Registration $registration)
291
-    {
292
-        return 0;
293
-    }
294
-
295
-
296
-    /**
297
-     * This sets up any action/filter hooks this message type puts in place for a specific messenger.  Note that by
298
-     * default this does nothing.  Child classes will need to override if they want to add specific hooks for a
299
-     * messenger.
300
-     *
301
-     * @since 1.0.0
302
-     * @return void
303
-     */
304
-    protected function _do_messenger_hooks()
305
-    {
306
-        return;
307
-    }
308
-
309
-
310
-    /**
311
-     * This is a public wrapper for the protected _do_messenger_hooks() method.
312
-     * For backward compat reasons, this was done rather than making the protected method public.
313
-     *
314
-     * @param   EE_messenger $messenger This is used to set the $_active_messenger property, so message types are able
315
-     *                                  to know what messenger is being used to send the message at the time of
316
-     *                                  sending.
317
-     * @since 4.9.0
318
-     */
319
-    public function do_messenger_hooks($messenger = null)
320
-    {
321
-        $this->_active_messenger = $messenger;
322
-        $this->_do_messenger_hooks();
323
-    }
324
-
325
-
326
-    /**
327
-     * This method returns whether this message type should always generate a new copy
328
-     * when requested, or if links can be to the already generated copy.
329
-     * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table.
330
-     * Child classes should override this if different from the default of false.
331
-     *
332
-     * @return bool     false means can link to generated EE_Message.  true must regenerate.
333
-     */
334
-    public function always_generate()
335
-    {
336
-        return false;
337
-    }
338
-
339
-
340
-    /**
341
-     * Returns the priority for the message type.
342
-     * Priorities are defined as constants on EEM_Message.  Currently there are three priorities:
343
-     * - EEM_Message::priority_high
344
-     * - EEM_Message::priority_medium
345
-     * - EEM_Message::priority_low
346
-     * Priority is used to determine the weight the message type is given when queuing for generation and/or sending.
347
-     *
348
-     * @see    EEM_Message for more phpdocs on priority.
349
-     *         The default priority for all message_types is EEM_Message::priority_low.  Message Types wanting to give
350
-     *         a higher priority must override this method. Also note, messengers are able to override priorities
351
-     *         queuing instructions if their "send_now" flag is set to true. An example of this is the HTML messenger
352
-     *         which displays things in the browser.
353
-     * @since  4.9.0
354
-     * @return int
355
-     */
356
-    public function get_priority()
357
-    {
358
-        return EEM_Message::priority_low;
359
-    }
360
-
361
-
362
-    /**
363
-     * This runs the _set_data_handler() method for message types and then returns what got set.
364
-     *
365
-     * @param mixed $data This sets the data property for the message type with the incoming data used for generating.
366
-     * @return string (the reference for the data handler) (will be an empty string if could not be determined).
367
-     */
368
-    public function get_data_handler($data)
369
-    {
370
-        $this->_data = $data;
371
-        $this->_set_data_handler();
372
-        return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this);
373
-    }
374
-
375
-
376
-    /**
377
-     * This is called externally to reset the value of the $_data property for the message type.
378
-     * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
379
-     * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called
380
-     * (and for back compat reasons). This particular method is used in
381
-     * EE_Messages_Generator::_reset_current_properties to ensure that the internal _data on the message type is
382
-     * cleaned before subsequent EE_Message generation in the same request.
383
-     *
384
-     * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
385
-     *            ensure that there is no manipulation of the _data property during run time so there's a clear
386
-     *            expectation of what it is.  Likely we need to ensure that _data is not persisted IN the message type
387
-     *            at all.
388
-     * @internal  Plugin authors, do not implement this method, it is subject to change.
389
-     * @since     4.9
390
-     */
391
-    public function reset_data()
392
-    {
393
-        $this->_data = null;
394
-    }
395
-
396
-
397
-    /**
398
-     * This does some validation of incoming params gets the url trigger from the defined method in the specific child
399
-     * class and then filters the results.
400
-     *
401
-     * @param string          $context           The message type context
402
-     * @param string          $sending_messenger The sending messenger
403
-     * @param EE_Registration $registration      Registration object
404
-     * @throws EE_Error
405
-     * @deprecated  4.9.0  Likely 4.9.10 or 4.10.0 will remove this method completely
406
-     * @return string          generated url
407
-     */
408
-    public function get_url_trigger($context, $sending_messenger, EE_Registration $registration)
409
-    {
410
-        //validate context
411
-        //valid context?
412
-        if (! isset($this->_contexts[$context])) {
413
-            throw new EE_Error(
414
-                sprintf(
415
-                    __('The context %s is not a valid context for %s.', 'event_espresso'),
416
-                    $context,
417
-                    get_class($this)
418
-                )
419
-            );
420
-        }
421
-        //valid sending_messenger?
422
-        $not_valid_msgr = false;
423
-        foreach ($this->_with_messengers as $generating => $sendings) {
424
-            if (empty($sendings) || array_search($sending_messenger, $sendings) === false) {
425
-                $not_valid_msgr = true;
426
-            }
427
-        }
428
-        if ($not_valid_msgr) {
429
-            throw new EE_Error(
430
-                sprintf(
431
-                    __(
432
-                        'The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.',
433
-                        'event_espresso'
434
-                    ),
435
-                    $sending_messenger,
436
-                    get_class($this)
437
-                )
438
-            );
439
-        }
440
-        return EEH_MSG_Template::generate_url_trigger(
441
-            $sending_messenger,
442
-            $this->_active_messenger->name,
443
-            $context,
444
-            $this->name,
445
-            $registration,
446
-            $this->_GRP_ID,
447
-            $this->_get_id_for_msg_url($context, $registration)
448
-        );
449
-    }
450
-
451
-
452
-    /**
453
-     * Wrapper for _get_data_for_context() that handles some validation before calling the main class and also allows
454
-     * for filtering. This is (currently) called by the EED_Messages module.
455
-     *
456
-     * @since 4.5.0
457
-     * @throws EE_Error
458
-     * @param string          $context      This should be a string matching a valid context for the message type.
459
-     * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
460
-     *                                      guessing a url).
461
-     * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
462
-     *                                      EE_Base_Class_Object
463
-     * @return mixed (EE_Base_Class||EE_Base_Class[])
464
-     */
465
-    public function get_data_for_context($context, EE_Registration $registration, $id = 0)
466
-    {
467
-        //valid context?
468
-        if (! isset($this->_contexts[$context])) {
469
-            throw new EE_Error(
470
-                sprintf(
471
-                    __('The context %s is not a valid context for %s.', 'event_espresso'),
472
-                    $context,
473
-                    get_class($this)
474
-                )
475
-            );
476
-        }
477
-        //get data and apply global and class specific filters on it.
478
-        $data = apply_filters(
479
-            'FHEE__EE_message_type__get_data_for_context__data',
480
-            $this->_get_data_for_context($context, $registration, $id),
481
-            $this
482
-        );
483
-        $data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this);
484
-        //if empty then something went wrong!
485
-        if (empty($data)) {
486
-            throw new EE_Error(
487
-                sprintf(
488
-                    __(
489
-                        'There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.',
490
-                        'event_espresso'
491
-                    ),
492
-                    $id,
493
-                    $this->name
494
-                )
495
-            );
496
-        }
497
-        return $data;
498
-    }
499
-
500
-
501
-    /**
502
-     * This returns the contents of the _data property.
503
-     * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
504
-     * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called.
505
-     *
506
-     * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
507
-     *            ensure that there is no manipulation of the _data property during run time so there's a clear
508
-     *            expectation of what it is.
509
-     * @internal  Plugin authors, do not implement this method, it is subject to change.
510
-     * @return mixed
511
-     */
512
-    public function get_data()
513
-    {
514
-        return $this->_data;
515
-    }
516
-
517
-
518
-    /**
519
-     * used to set the $_with_messengers property. (this is a default, child classes SHOULD override)
520
-     *
521
-     * @see   property definition for description of setup.
522
-     * @since 4.5.0
523
-     * @abstract
524
-     * @return void
525
-     */
526
-    protected function _set_with_messengers()
527
-    {
528
-        $this->_with_messengers = array(
529
-            'email' => array('html'),
530
-        );
531
-    }
532
-
533
-
534
-    /**
535
-     * Return the value of the _with_messengers property
536
-     *
537
-     * @since 4.5.0
538
-     * @return array
539
-     */
540
-    public function with_messengers()
541
-    {
542
-        return apply_filters(
543
-            'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this),
544
-            $this->_with_messengers
545
-        );
546
-    }
547
-
548
-
549
-    /**
550
-     * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class
551
-     * callback function if that page is registered via the `_admin_registered_page` property set by the child class.
552
-     * *
553
-     *
554
-     * @param string $page       the slug of the EE admin page
555
-     * @param array  $messengers an array of active messenger objects
556
-     * @param string $action     the page action (to allow for more specific handling - i.e. edit vs. add pages)
557
-     * @param array  $extra      This is just an extra argument that can be used to pass additional data for setting up
558
-     *                           page content.
559
-     * @access public
560
-     * @return string
561
-     */
562
-    public function get_message_type_admin_page_content(
563
-        $page,
564
-        $action = null,
565
-        $extra = array(),
566
-        $messengers = array()
567
-    ) {
568
-        //we can also further refine the context by action (if present).
569
-        return $this->_get_admin_page_content($page, $action, $extra, $messengers);
570
-    }
571
-
572
-
573
-    /**
574
-     * @return array
575
-     */
576
-    public function get_contexts()
577
-    {
578
-        return $this->_contexts;
579
-    }
580
-
581
-
582
-    /**
583
-     * This just returns the context label for a given context (as set in $_context_label property)
584
-     *
585
-     * @access public
586
-     * @return array
587
-     */
588
-    public function get_context_label()
589
-    {
590
-        return $this->_context_label;
591
-    }
592
-
593
-
594
-    /**
595
-     * This just returns the (filtered) _master_templates property.
596
-     *
597
-     * @see property definition for documentation.
598
-     * @return array
599
-     */
600
-    public function get_master_templates()
601
-    {
602
-        //first class specific filter then filter that by the global filter.
603
-        $master_templates = apply_filters(
604
-            'FHEE__' . get_class($this) . '__get_master_templates',
605
-            $this->_master_templates
606
-        );
607
-        return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
608
-    }
609
-
610
-
611
-    /**
612
-     * Accepts an incoming data handler which contains data for processing, and returns an array of
613
-     * EE_Messages_Addressee objects.
614
-     *
615
-     * @param EE_Messages_incoming_data $data
616
-     * @param string                    $context Limit addressees to specific context.
617
-     * @return array   An array indexed by context where each context is an array of EE_Messages_Addressee objects for
618
-     *                                           that context
619
-     */
620
-    public function get_addressees(EE_Messages_incoming_data $data, $context = '')
621
-    {
622
-        //override _data
623
-        $this->_data       = $data;
624
-        $addressees        = array();
625
-        $original_contexts = $this->_contexts;
626
-        //if incoming context then limit to that context
627
-        if (! empty($context)) {
628
-            $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : '';
629
-            if (! empty($cntxt)) {
630
-                $this->_contexts           = array();
631
-                $this->_contexts[$context] = $cntxt;
632
-            }
633
-        }
634
-        $this->_set_default_addressee_data();
635
-        if ($this->_process_data()) {
636
-            $addressees = $this->_addressees;
637
-        }
638
-
639
-        //reset contexts and addressees
640
-        $this->_contexts   = $original_contexts;
641
-        $this->_addressees = array();
642
-        return $addressees;
643
-    }
644
-
645
-
646
-    /**
647
-     * processes the data object so we get
648
-     *
649
-     * @throws EE_Error
650
-     * @return bool  true means data was processed successfully, false means not.
651
-     */
652
-    protected function _process_data()
653
-    {
654
-        //at a minimum, we NEED EE_Attendee objects.
655
-        if (empty($this->_data->attendees)) {
656
-            return false;  //there's no data to process!
657
-        }
658
-        // process addressees for each context.  Child classes will have to have methods for
659
-        // each context defined to handle the processing of the data object within them
660
-        foreach ($this->_contexts as $context => $details) {
661
-            $xpctd_method = '_' . $context . '_addressees';
662
-            if (! method_exists($this, $xpctd_method)) {
663
-                throw new EE_Error(
664
-                    sprintf(
665
-                        __(
666
-                            'The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present',
667
-                            'event_espresso'
668
-                        ),
669
-                        $this->label['singular'],
670
-                        $xpctd_method
671
-                    )
672
-                );
673
-            }
674
-            $this->_addressees[$context] = call_user_func(array($this, $xpctd_method));
675
-        }
676
-        return true; //data was processed successfully.
677
-    }
678
-
679
-
680
-    /**
681
-     * sets the default_addressee_data property,
682
-     *
683
-     * @access private
684
-     * @return void
685
-     */
686
-    private function _set_default_addressee_data()
687
-    {
688
-        $this->_default_addressee_data = array(
689
-            'billing'                  => $this->_data->billing,
690
-            'taxes'                    => $this->_data->taxes,
691
-            'tax_line_items'           => $this->_data->tax_line_items,
692
-            'additional_line_items'    => $this->_data->additional_line_items,
693
-            'grand_total_line_item'    => $this->_data->grand_total_line_item,
694
-            'txn'                      => $this->_data->txn,
695
-            'payments'                 => $this->_data->payments,
696
-            'payment'                  => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment
697
-                ? $this->_data->payment
698
-                : null,
699
-            'reg_objs'                 => $this->_data->reg_objs,
700
-            'registrations'            => $this->_data->registrations,
701
-            'datetimes'                => $this->_data->datetimes,
702
-            'tickets'                  => $this->_data->tickets,
703
-            'line_items_with_children' => $this->_data->line_items_with_children,
704
-            'questions'                => $this->_data->questions,
705
-            'answers'                  => $this->_data->answers,
706
-            'txn_status'               => $this->_data->txn_status,
707
-            'total_ticket_count'       => $this->_data->total_ticket_count,
708
-        );
709
-        if (is_array($this->_data->primary_attendee_data)) {
710
-            $this->_default_addressee_data                    = array_merge(
711
-                $this->_default_addressee_data,
712
-                $this->_data->primary_attendee_data
713
-            );
714
-            $this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj'];
715
-            $this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj'];
716
-        }
717
-    }
718
-
719
-
720
-
721
-    /********************
21
+	/**
22
+	 * message type child classes will set what contexts are associated with the message type via this array.
23
+	 * format:
24
+	 * array(
25
+	 * 'context' => array(
26
+	 *        'label' => __('Context Label', 'event_espresso'),
27
+	 *        'description' => __('Context description (for help popups)', 'event_espresso')
28
+	 *    ));
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $_contexts = array();
33
+
34
+
35
+	/**
36
+	 * This property is used to define what the display label will be for contexts (eg. "Recipients", "Themes" etc.)
37
+	 * Format:
38
+	 * array( 'label' => 'something', 'plural' => 'somethings', 'description' => 'something' );
39
+	 *
40
+	 * @var array
41
+	 */
42
+	protected $_context_label;
43
+
44
+
45
+	/** MESSAGE ASSEMBLING PROPERTIES **/
46
+	/**
47
+	 * This parameter simply holds all the message objects for retrieval by the controller and sending to the messenger.
48
+	 *
49
+	 * @var array of message objects.
50
+	 */
51
+	public $messages = array();
52
+
53
+	/**
54
+	 * The following holds the templates that will be used to assemble the message object for the messenger.
55
+	 *
56
+	 * @var array
57
+	 */
58
+	protected $_templates;
59
+
60
+
61
+	/**
62
+	 * If a specific template is being parsed, this will hold the message template group GRP_ID for that template.
63
+	 *
64
+	 * @var int.
65
+	 */
66
+	protected $_GRP_ID;
67
+
68
+
69
+	/** OTHER INFO PROPERTIES **/
70
+	/**
71
+	 * This will hold the count of the message objects in the messages array. This could be used for determining if
72
+	 * batching/queueing is needed.
73
+	 *
74
+	 * @var int
75
+	 */
76
+	public $count = 0;
77
+
78
+
79
+	/**
80
+	 * This is set via the `do_messenger_hooks` method and contains the messenger being used to send the message of
81
+	 * this message type at time of sending.
82
+	 *
83
+	 * @var EE_messenger
84
+	 */
85
+	protected $_active_messenger;
86
+
87
+
88
+	/**
89
+	 * This will hold the shortcode_replace instance for handling replacement of shortcodes in the various templates
90
+	 *
91
+	 * @var object
92
+	 */
93
+	protected $_shortcode_replace;
94
+
95
+
96
+	/**
97
+	 * The purpose for this property is to simply allow message types to indicate if the message generated is intended
98
+	 * for only single context.  Child message types should redefine this variable (if necessary) in the
99
+	 * _set_data_Handler() method.
100
+	 *
101
+	 * @var boolean
102
+	 */
103
+	protected $_single_message = false;
104
+
105
+
106
+	/**
107
+	 * This will hold an array of specific reg_ids that are receiving messages.
108
+	 *
109
+	 * @since 4.7.x
110
+	 * @var array
111
+	 */
112
+	protected $_regs_for_sending = array();
113
+
114
+
115
+	/**
116
+	 * This holds the data passed to this class from the controller and also the final processed data.
117
+	 *
118
+	 * @var object
119
+	 */
120
+	protected $_data;
121
+
122
+
123
+	/**
124
+	 * this is just a flag indicating whether we're in preview mode or not.
125
+	 *
126
+	 * @var bool
127
+	 */
128
+	protected $_preview = false;
129
+
130
+
131
+	/**
132
+	 * This just holds defaults for addressee data that children merge with their data array setup
133
+	 *
134
+	 * @var array
135
+	 */
136
+	protected $_default_addressee_data;
137
+
138
+
139
+	/**
140
+	 * Child classes declare through this property what handler they want to use for the incoming data and this string
141
+	 * is used to instantiate the EE_Messages_incoming_data child class for that handler.
142
+	 *
143
+	 * @var string
144
+	 */
145
+	protected $_data_handler;
146
+
147
+
148
+	/**
149
+	 * This holds any specific fields for holding any settings related to a message type (if any needed)
150
+	 *
151
+	 * @var array
152
+	 */
153
+	protected $_admin_settings_fields = array();
154
+
155
+	/**
156
+	 * this property will hold any existing setting that may have been set in the admin.
157
+	 *
158
+	 * @var array
159
+	 */
160
+	protected $_existing_admin_settings = array();
161
+
162
+
163
+	/**
164
+	 * This is used to designate the generating and alternative sending messengers for a message type.  It is set via
165
+	 * set_with_messengers() on construct. Note, generating messenger also acts as a sending messenger for this message
166
+	 * type.  However ONLY the generating messengers are used for creating templates for this message type. Should be
167
+	 * in this format:
168
+	 * {
169
+	 *
170
+	 * @type string $generating_messenger the name of the generating messenger.  Generating
171
+	 *                                          messengers are used for generating templates,
172
+	 *                                          doing validation and defining valid shortcodes.
173
+	 *      {
174
+	 * @type string $sending_messenger    values are the name(s) for the sending
175
+	 *                                              messengers.  sending messengers are
176
+	 *                                              just valid delivery vehicles that will utilize
177
+	 *                                              the templates (and generated EE_message
178
+	 *                                              objects from the generating messengers).
179
+	 *      }
180
+	 * }
181
+	 * @since                             4.5.0
182
+	 * @var array
183
+	 */
184
+	protected $_with_messengers = array();
185
+
186
+
187
+	/**
188
+	 * This holds the addressees in an array indexed by context for later retrieval when assembling the message objects.
189
+	 *
190
+	 * @access protected
191
+	 * @var array
192
+	 */
193
+	protected $_addressees = array();
194
+
195
+
196
+	/**
197
+	 * This allows each message type to set what alternate messenger&message type combination can be used for fallback
198
+	 * default templates if there are no specific ones defined for this messenger and message type.  Should be in the
199
+	 * format:
200
+	 * array(
201
+	 *      'messenger' => 'message_type',
202
+	 *      'another_messenger' => another_message_type
203
+	 * );
204
+	 * This is set in the message type constructor.
205
+	 *
206
+	 * @var array
207
+	 */
208
+	protected $_master_templates = array();
209
+
210
+
211
+	/**
212
+	 * This holds whatever the set template pack is for a message template group when generating messages.
213
+	 *
214
+	 * @since 4.5.0
215
+	 * @var EE_Messages_Template_Pack
216
+	 */
217
+	protected $_template_pack;
218
+
219
+
220
+	/**
221
+	 * This holds whatever the set variation is for a message template group when generating messages.
222
+	 *
223
+	 * @since 4.5.0
224
+	 * @var string
225
+	 */
226
+	protected $_variation;
227
+
228
+
229
+	/**
230
+	 * EE_message_type constructor.
231
+	 */
232
+	public function __construct()
233
+	{
234
+		$this->_messages_item_type = 'message_type';
235
+		$this->_set_contexts();
236
+		$this->_set_with_messengers();
237
+		parent::__construct();
238
+	}
239
+
240
+
241
+	/**
242
+	 * This sets the data handler for the message type.  It must be used to define the _data_handler property.  It is
243
+	 * called when messages are setup.
244
+	 *
245
+	 * @abstract
246
+	 * @access protected
247
+	 * @return void
248
+	 */
249
+	abstract protected function _set_data_handler();
250
+
251
+
252
+	/**
253
+	 * This method should return a EE_Base_Class object (or array of EE_Base_Class objects) for the given context and
254
+	 * ID (which should be the primary key id for the base class).  Client code doesn't have to know what a message
255
+	 * type's data handler is.
256
+	 *
257
+	 * @since 4.5.0
258
+	 * @param string          $context      This should be a string matching a valid context for the message type.
259
+	 * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
260
+	 *                                      guessing a url).
261
+	 * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
262
+	 *                                      EE_Base_Class_Object
263
+	 * @return mixed ( EE_Base_Class||EE_Base_Class[] )
264
+	 */
265
+	abstract protected function _get_data_for_context($context, EE_Registration $registration, $id);
266
+
267
+
268
+	/**
269
+	 * _set_contexts
270
+	 * This sets up the contexts associated with the message_type
271
+	 *
272
+	 * @abstract
273
+	 * @access  protected
274
+	 * @return  void
275
+	 */
276
+	abstract protected function _set_contexts();
277
+
278
+
279
+	/**
280
+	 * This is used to get the "id" value fo the msg_trigger_url generated by get_url_trigger().
281
+	 * In most cases, child classes don't need anything, (hence the default of 0), however if there is a specific
282
+	 * EE_Base_Class that is required in generating a message for a message type recipient then the message
283
+	 * type should override this method and use the given params to generate the correct ID.
284
+	 *
285
+	 * @param string          $context      The message type context.
286
+	 * @param EE_Registration $registration Registration object
287
+	 * @deprecated 4.9.0
288
+	 * @return int
289
+	 */
290
+	protected function _get_id_for_msg_url($context, EE_Registration $registration)
291
+	{
292
+		return 0;
293
+	}
294
+
295
+
296
+	/**
297
+	 * This sets up any action/filter hooks this message type puts in place for a specific messenger.  Note that by
298
+	 * default this does nothing.  Child classes will need to override if they want to add specific hooks for a
299
+	 * messenger.
300
+	 *
301
+	 * @since 1.0.0
302
+	 * @return void
303
+	 */
304
+	protected function _do_messenger_hooks()
305
+	{
306
+		return;
307
+	}
308
+
309
+
310
+	/**
311
+	 * This is a public wrapper for the protected _do_messenger_hooks() method.
312
+	 * For backward compat reasons, this was done rather than making the protected method public.
313
+	 *
314
+	 * @param   EE_messenger $messenger This is used to set the $_active_messenger property, so message types are able
315
+	 *                                  to know what messenger is being used to send the message at the time of
316
+	 *                                  sending.
317
+	 * @since 4.9.0
318
+	 */
319
+	public function do_messenger_hooks($messenger = null)
320
+	{
321
+		$this->_active_messenger = $messenger;
322
+		$this->_do_messenger_hooks();
323
+	}
324
+
325
+
326
+	/**
327
+	 * This method returns whether this message type should always generate a new copy
328
+	 * when requested, or if links can be to the already generated copy.
329
+	 * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table.
330
+	 * Child classes should override this if different from the default of false.
331
+	 *
332
+	 * @return bool     false means can link to generated EE_Message.  true must regenerate.
333
+	 */
334
+	public function always_generate()
335
+	{
336
+		return false;
337
+	}
338
+
339
+
340
+	/**
341
+	 * Returns the priority for the message type.
342
+	 * Priorities are defined as constants on EEM_Message.  Currently there are three priorities:
343
+	 * - EEM_Message::priority_high
344
+	 * - EEM_Message::priority_medium
345
+	 * - EEM_Message::priority_low
346
+	 * Priority is used to determine the weight the message type is given when queuing for generation and/or sending.
347
+	 *
348
+	 * @see    EEM_Message for more phpdocs on priority.
349
+	 *         The default priority for all message_types is EEM_Message::priority_low.  Message Types wanting to give
350
+	 *         a higher priority must override this method. Also note, messengers are able to override priorities
351
+	 *         queuing instructions if their "send_now" flag is set to true. An example of this is the HTML messenger
352
+	 *         which displays things in the browser.
353
+	 * @since  4.9.0
354
+	 * @return int
355
+	 */
356
+	public function get_priority()
357
+	{
358
+		return EEM_Message::priority_low;
359
+	}
360
+
361
+
362
+	/**
363
+	 * This runs the _set_data_handler() method for message types and then returns what got set.
364
+	 *
365
+	 * @param mixed $data This sets the data property for the message type with the incoming data used for generating.
366
+	 * @return string (the reference for the data handler) (will be an empty string if could not be determined).
367
+	 */
368
+	public function get_data_handler($data)
369
+	{
370
+		$this->_data = $data;
371
+		$this->_set_data_handler();
372
+		return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this);
373
+	}
374
+
375
+
376
+	/**
377
+	 * This is called externally to reset the value of the $_data property for the message type.
378
+	 * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
379
+	 * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called
380
+	 * (and for back compat reasons). This particular method is used in
381
+	 * EE_Messages_Generator::_reset_current_properties to ensure that the internal _data on the message type is
382
+	 * cleaned before subsequent EE_Message generation in the same request.
383
+	 *
384
+	 * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
385
+	 *            ensure that there is no manipulation of the _data property during run time so there's a clear
386
+	 *            expectation of what it is.  Likely we need to ensure that _data is not persisted IN the message type
387
+	 *            at all.
388
+	 * @internal  Plugin authors, do not implement this method, it is subject to change.
389
+	 * @since     4.9
390
+	 */
391
+	public function reset_data()
392
+	{
393
+		$this->_data = null;
394
+	}
395
+
396
+
397
+	/**
398
+	 * This does some validation of incoming params gets the url trigger from the defined method in the specific child
399
+	 * class and then filters the results.
400
+	 *
401
+	 * @param string          $context           The message type context
402
+	 * @param string          $sending_messenger The sending messenger
403
+	 * @param EE_Registration $registration      Registration object
404
+	 * @throws EE_Error
405
+	 * @deprecated  4.9.0  Likely 4.9.10 or 4.10.0 will remove this method completely
406
+	 * @return string          generated url
407
+	 */
408
+	public function get_url_trigger($context, $sending_messenger, EE_Registration $registration)
409
+	{
410
+		//validate context
411
+		//valid context?
412
+		if (! isset($this->_contexts[$context])) {
413
+			throw new EE_Error(
414
+				sprintf(
415
+					__('The context %s is not a valid context for %s.', 'event_espresso'),
416
+					$context,
417
+					get_class($this)
418
+				)
419
+			);
420
+		}
421
+		//valid sending_messenger?
422
+		$not_valid_msgr = false;
423
+		foreach ($this->_with_messengers as $generating => $sendings) {
424
+			if (empty($sendings) || array_search($sending_messenger, $sendings) === false) {
425
+				$not_valid_msgr = true;
426
+			}
427
+		}
428
+		if ($not_valid_msgr) {
429
+			throw new EE_Error(
430
+				sprintf(
431
+					__(
432
+						'The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.',
433
+						'event_espresso'
434
+					),
435
+					$sending_messenger,
436
+					get_class($this)
437
+				)
438
+			);
439
+		}
440
+		return EEH_MSG_Template::generate_url_trigger(
441
+			$sending_messenger,
442
+			$this->_active_messenger->name,
443
+			$context,
444
+			$this->name,
445
+			$registration,
446
+			$this->_GRP_ID,
447
+			$this->_get_id_for_msg_url($context, $registration)
448
+		);
449
+	}
450
+
451
+
452
+	/**
453
+	 * Wrapper for _get_data_for_context() that handles some validation before calling the main class and also allows
454
+	 * for filtering. This is (currently) called by the EED_Messages module.
455
+	 *
456
+	 * @since 4.5.0
457
+	 * @throws EE_Error
458
+	 * @param string          $context      This should be a string matching a valid context for the message type.
459
+	 * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
460
+	 *                                      guessing a url).
461
+	 * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
462
+	 *                                      EE_Base_Class_Object
463
+	 * @return mixed (EE_Base_Class||EE_Base_Class[])
464
+	 */
465
+	public function get_data_for_context($context, EE_Registration $registration, $id = 0)
466
+	{
467
+		//valid context?
468
+		if (! isset($this->_contexts[$context])) {
469
+			throw new EE_Error(
470
+				sprintf(
471
+					__('The context %s is not a valid context for %s.', 'event_espresso'),
472
+					$context,
473
+					get_class($this)
474
+				)
475
+			);
476
+		}
477
+		//get data and apply global and class specific filters on it.
478
+		$data = apply_filters(
479
+			'FHEE__EE_message_type__get_data_for_context__data',
480
+			$this->_get_data_for_context($context, $registration, $id),
481
+			$this
482
+		);
483
+		$data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this);
484
+		//if empty then something went wrong!
485
+		if (empty($data)) {
486
+			throw new EE_Error(
487
+				sprintf(
488
+					__(
489
+						'There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.',
490
+						'event_espresso'
491
+					),
492
+					$id,
493
+					$this->name
494
+				)
495
+			);
496
+		}
497
+		return $data;
498
+	}
499
+
500
+
501
+	/**
502
+	 * This returns the contents of the _data property.
503
+	 * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
504
+	 * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called.
505
+	 *
506
+	 * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
507
+	 *            ensure that there is no manipulation of the _data property during run time so there's a clear
508
+	 *            expectation of what it is.
509
+	 * @internal  Plugin authors, do not implement this method, it is subject to change.
510
+	 * @return mixed
511
+	 */
512
+	public function get_data()
513
+	{
514
+		return $this->_data;
515
+	}
516
+
517
+
518
+	/**
519
+	 * used to set the $_with_messengers property. (this is a default, child classes SHOULD override)
520
+	 *
521
+	 * @see   property definition for description of setup.
522
+	 * @since 4.5.0
523
+	 * @abstract
524
+	 * @return void
525
+	 */
526
+	protected function _set_with_messengers()
527
+	{
528
+		$this->_with_messengers = array(
529
+			'email' => array('html'),
530
+		);
531
+	}
532
+
533
+
534
+	/**
535
+	 * Return the value of the _with_messengers property
536
+	 *
537
+	 * @since 4.5.0
538
+	 * @return array
539
+	 */
540
+	public function with_messengers()
541
+	{
542
+		return apply_filters(
543
+			'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this),
544
+			$this->_with_messengers
545
+		);
546
+	}
547
+
548
+
549
+	/**
550
+	 * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class
551
+	 * callback function if that page is registered via the `_admin_registered_page` property set by the child class.
552
+	 * *
553
+	 *
554
+	 * @param string $page       the slug of the EE admin page
555
+	 * @param array  $messengers an array of active messenger objects
556
+	 * @param string $action     the page action (to allow for more specific handling - i.e. edit vs. add pages)
557
+	 * @param array  $extra      This is just an extra argument that can be used to pass additional data for setting up
558
+	 *                           page content.
559
+	 * @access public
560
+	 * @return string
561
+	 */
562
+	public function get_message_type_admin_page_content(
563
+		$page,
564
+		$action = null,
565
+		$extra = array(),
566
+		$messengers = array()
567
+	) {
568
+		//we can also further refine the context by action (if present).
569
+		return $this->_get_admin_page_content($page, $action, $extra, $messengers);
570
+	}
571
+
572
+
573
+	/**
574
+	 * @return array
575
+	 */
576
+	public function get_contexts()
577
+	{
578
+		return $this->_contexts;
579
+	}
580
+
581
+
582
+	/**
583
+	 * This just returns the context label for a given context (as set in $_context_label property)
584
+	 *
585
+	 * @access public
586
+	 * @return array
587
+	 */
588
+	public function get_context_label()
589
+	{
590
+		return $this->_context_label;
591
+	}
592
+
593
+
594
+	/**
595
+	 * This just returns the (filtered) _master_templates property.
596
+	 *
597
+	 * @see property definition for documentation.
598
+	 * @return array
599
+	 */
600
+	public function get_master_templates()
601
+	{
602
+		//first class specific filter then filter that by the global filter.
603
+		$master_templates = apply_filters(
604
+			'FHEE__' . get_class($this) . '__get_master_templates',
605
+			$this->_master_templates
606
+		);
607
+		return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
608
+	}
609
+
610
+
611
+	/**
612
+	 * Accepts an incoming data handler which contains data for processing, and returns an array of
613
+	 * EE_Messages_Addressee objects.
614
+	 *
615
+	 * @param EE_Messages_incoming_data $data
616
+	 * @param string                    $context Limit addressees to specific context.
617
+	 * @return array   An array indexed by context where each context is an array of EE_Messages_Addressee objects for
618
+	 *                                           that context
619
+	 */
620
+	public function get_addressees(EE_Messages_incoming_data $data, $context = '')
621
+	{
622
+		//override _data
623
+		$this->_data       = $data;
624
+		$addressees        = array();
625
+		$original_contexts = $this->_contexts;
626
+		//if incoming context then limit to that context
627
+		if (! empty($context)) {
628
+			$cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : '';
629
+			if (! empty($cntxt)) {
630
+				$this->_contexts           = array();
631
+				$this->_contexts[$context] = $cntxt;
632
+			}
633
+		}
634
+		$this->_set_default_addressee_data();
635
+		if ($this->_process_data()) {
636
+			$addressees = $this->_addressees;
637
+		}
638
+
639
+		//reset contexts and addressees
640
+		$this->_contexts   = $original_contexts;
641
+		$this->_addressees = array();
642
+		return $addressees;
643
+	}
644
+
645
+
646
+	/**
647
+	 * processes the data object so we get
648
+	 *
649
+	 * @throws EE_Error
650
+	 * @return bool  true means data was processed successfully, false means not.
651
+	 */
652
+	protected function _process_data()
653
+	{
654
+		//at a minimum, we NEED EE_Attendee objects.
655
+		if (empty($this->_data->attendees)) {
656
+			return false;  //there's no data to process!
657
+		}
658
+		// process addressees for each context.  Child classes will have to have methods for
659
+		// each context defined to handle the processing of the data object within them
660
+		foreach ($this->_contexts as $context => $details) {
661
+			$xpctd_method = '_' . $context . '_addressees';
662
+			if (! method_exists($this, $xpctd_method)) {
663
+				throw new EE_Error(
664
+					sprintf(
665
+						__(
666
+							'The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present',
667
+							'event_espresso'
668
+						),
669
+						$this->label['singular'],
670
+						$xpctd_method
671
+					)
672
+				);
673
+			}
674
+			$this->_addressees[$context] = call_user_func(array($this, $xpctd_method));
675
+		}
676
+		return true; //data was processed successfully.
677
+	}
678
+
679
+
680
+	/**
681
+	 * sets the default_addressee_data property,
682
+	 *
683
+	 * @access private
684
+	 * @return void
685
+	 */
686
+	private function _set_default_addressee_data()
687
+	{
688
+		$this->_default_addressee_data = array(
689
+			'billing'                  => $this->_data->billing,
690
+			'taxes'                    => $this->_data->taxes,
691
+			'tax_line_items'           => $this->_data->tax_line_items,
692
+			'additional_line_items'    => $this->_data->additional_line_items,
693
+			'grand_total_line_item'    => $this->_data->grand_total_line_item,
694
+			'txn'                      => $this->_data->txn,
695
+			'payments'                 => $this->_data->payments,
696
+			'payment'                  => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment
697
+				? $this->_data->payment
698
+				: null,
699
+			'reg_objs'                 => $this->_data->reg_objs,
700
+			'registrations'            => $this->_data->registrations,
701
+			'datetimes'                => $this->_data->datetimes,
702
+			'tickets'                  => $this->_data->tickets,
703
+			'line_items_with_children' => $this->_data->line_items_with_children,
704
+			'questions'                => $this->_data->questions,
705
+			'answers'                  => $this->_data->answers,
706
+			'txn_status'               => $this->_data->txn_status,
707
+			'total_ticket_count'       => $this->_data->total_ticket_count,
708
+		);
709
+		if (is_array($this->_data->primary_attendee_data)) {
710
+			$this->_default_addressee_data                    = array_merge(
711
+				$this->_default_addressee_data,
712
+				$this->_data->primary_attendee_data
713
+			);
714
+			$this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj'];
715
+			$this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj'];
716
+		}
717
+	}
718
+
719
+
720
+
721
+	/********************
722 722
      * setup default shared addressee object/contexts
723 723
      * These can be utilized simply by defining the context in the child message type.
724 724
      * They can also be overridden if a specific message type needs to do something different for that context.
725 725
      ****************/
726
-    /**
727
-     * see abstract declaration in parent class for details, children message types can
728
-     * override these valid shortcodes if desired (we include all for all contexts by default).
729
-     */
730
-    protected function _set_valid_shortcodes()
731
-    {
732
-        $all_shortcodes = array(
733
-            'attendee_list',
734
-            'attendee',
735
-            'datetime_list',
736
-            'datetime',
737
-            'event_list',
738
-            'event_meta',
739
-            'event',
740
-            'organization',
741
-            'recipient_details',
742
-            'recipient_list',
743
-            'ticket_list',
744
-            'ticket',
745
-            'transaction',
746
-            'venue',
747
-            'primary_registration_details',
748
-            'primary_registration_list',
749
-            'event_author',
750
-            'email',
751
-            'messenger',
752
-        );
753
-        $contexts       = $this->get_contexts();
754
-        foreach ($contexts as $context => $details) {
755
-            $this->_valid_shortcodes[$context] = $all_shortcodes;
756
-            //make sure non admin context does not include the event_author shortcodes
757
-            if ($context != 'admin') {
758
-                if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) {
759
-                    unset($this->_valid_shortcodes[$context][$key]);
760
-                }
761
-            }
762
-        }
763
-        // make sure admin context does not include the recipient_details shortcodes
764
-        // IF we have admin context hooked in message types might not have that context.
765
-        if (! empty($this->_valid_shortcodes['admin'])) {
766
-            if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
767
-                unset($this->_valid_shortcodes['admin'][$key]);
768
-            }
769
-            //make sure admin context does not include the recipient_details shortcodes
770
-            if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) {
771
-                unset($this->_valid_shortcodes['admin'][$key]);
772
-            }
773
-        }
774
-    }
775
-
776
-
777
-    /**
778
-     * Used by Validators to modify the valid shortcodes.
779
-     *
780
-     * @param  array $new_config array of valid shortcodes (by context)
781
-     * @return void               sets valid_shortcodes property
782
-     */
783
-    public function reset_valid_shortcodes_config($new_config)
784
-    {
785
-        foreach ($new_config as $context => $shortcodes) {
786
-            $this->_valid_shortcodes[$context] = $shortcodes;
787
-        }
788
-    }
789
-
790
-
791
-    /**
792
-     * returns an array of addressee objects for event_admins
793
-     *
794
-     * @access protected
795
-     * @return array array of EE_Messages_Addressee objects
796
-     */
797
-    protected function _admin_addressees()
798
-    {
799
-        $admin_events = array();
800
-        $addressees   = array();
801
-        // first we need to get the event admin user id for all the events
802
-        // and setup an addressee object for each unique admin user.
803
-        foreach ($this->_data->events as $line_ref => $event) {
804
-            $admin_id = $this->_get_event_admin_id($event['ID']);
805
-            //make sure we are just including the events that belong to this admin!
806
-            $admin_events[$admin_id][$line_ref] = $event;
807
-        }
808
-        //k now we can loop through the event_admins and setup the addressee data.
809
-        foreach ($admin_events as $admin_id => $event_details) {
810
-            $aee          = array(
811
-                'user_id'        => $admin_id,
812
-                'events'         => $event_details,
813
-                'attendees'      => $this->_data->attendees,
814
-                'recipient_id'   => $admin_id,
815
-                'recipient_type' => 'WP_User',
816
-            );
817
-            $aee          = array_merge($this->_default_addressee_data, $aee);
818
-            $addressees[] = new EE_Messages_Addressee($aee);
819
-        }
820
-        return $addressees;
821
-    }
822
-
823
-
824
-    /**
825
-     * Takes care of setting up the addressee object(s) for the primary attendee.
826
-     *
827
-     * @access protected
828
-     * @return array of EE_Addressee objects
829
-     */
830
-    protected function _primary_attendee_addressees()
831
-    {
832
-        $aee                   = $this->_default_addressee_data;
833
-        $aee['events']         = $this->_data->events;
834
-        $aee['attendees']      = $this->_data->attendees;
835
-        $aee['recipient_id']   = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0;
836
-        $aee['recipient_type'] = 'Attendee';
837
-        //great now we can instantiate the $addressee object and return (as an array);
838
-        $add[] = new EE_Messages_Addressee($aee);
839
-        return $add;
840
-    }
841
-
842
-
843
-    /**
844
-     * Takes care of setting up the addressee object(s) for the registered attendees
845
-     *
846
-     * @access protected
847
-     * @return array of EE_Addressee objects
848
-     */
849
-    protected function _attendee_addressees()
850
-    {
851
-        $add = array();
852
-        //we just have to loop through the attendees.  We'll also set the attached events for each attendee.
853
-        //use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we?
854
-        $already_processed = array();
855
-        foreach ($this->_data->attendees as $att_id => $details) {
856
-            //set the attendee array to blank on each loop;
857
-            $aee = array();
858
-            if (isset($this->_data->reg_obj)
859
-                && ($this->_data->reg_obj->attendee_ID() != $att_id)
860
-                && $this->_single_message
861
-            ) {
862
-                continue;
863
-            }
864
-            // is $this->_regs_for_sending present?
865
-            // If so, let's make sure we ONLY generate addressee for registrations in that array.
866
-            if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
867
-                $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
868
-                if (empty($regs_allowed)) {
869
-                    continue;
870
-                }
871
-            }
872
-            if (
873
-                in_array($details['attendee_email'], $already_processed)
874
-                && apply_filters(
875
-                    'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends',
876
-                    true,
877
-                    $this->_data,
878
-                    $this
879
-                )
880
-            ) {
881
-                continue;
882
-            }
883
-            $already_processed[] = $details['attendee_email'];
884
-            foreach ($details as $item => $value) {
885
-                $aee[$item] = $value;
886
-                if ($item == 'line_ref') {
887
-                    foreach ($value as $event_id) {
888
-                        $aee['events'][$event_id] = $this->_data->events[$event_id];
889
-                    }
890
-                }
891
-                if ($item == 'attendee_email') {
892
-                    $aee['attendee_email'] = $value;
893
-                }
894
-                /*if ( $item == 'registration_id' ) {
726
+	/**
727
+	 * see abstract declaration in parent class for details, children message types can
728
+	 * override these valid shortcodes if desired (we include all for all contexts by default).
729
+	 */
730
+	protected function _set_valid_shortcodes()
731
+	{
732
+		$all_shortcodes = array(
733
+			'attendee_list',
734
+			'attendee',
735
+			'datetime_list',
736
+			'datetime',
737
+			'event_list',
738
+			'event_meta',
739
+			'event',
740
+			'organization',
741
+			'recipient_details',
742
+			'recipient_list',
743
+			'ticket_list',
744
+			'ticket',
745
+			'transaction',
746
+			'venue',
747
+			'primary_registration_details',
748
+			'primary_registration_list',
749
+			'event_author',
750
+			'email',
751
+			'messenger',
752
+		);
753
+		$contexts       = $this->get_contexts();
754
+		foreach ($contexts as $context => $details) {
755
+			$this->_valid_shortcodes[$context] = $all_shortcodes;
756
+			//make sure non admin context does not include the event_author shortcodes
757
+			if ($context != 'admin') {
758
+				if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) {
759
+					unset($this->_valid_shortcodes[$context][$key]);
760
+				}
761
+			}
762
+		}
763
+		// make sure admin context does not include the recipient_details shortcodes
764
+		// IF we have admin context hooked in message types might not have that context.
765
+		if (! empty($this->_valid_shortcodes['admin'])) {
766
+			if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
767
+				unset($this->_valid_shortcodes['admin'][$key]);
768
+			}
769
+			//make sure admin context does not include the recipient_details shortcodes
770
+			if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) {
771
+				unset($this->_valid_shortcodes['admin'][$key]);
772
+			}
773
+		}
774
+	}
775
+
776
+
777
+	/**
778
+	 * Used by Validators to modify the valid shortcodes.
779
+	 *
780
+	 * @param  array $new_config array of valid shortcodes (by context)
781
+	 * @return void               sets valid_shortcodes property
782
+	 */
783
+	public function reset_valid_shortcodes_config($new_config)
784
+	{
785
+		foreach ($new_config as $context => $shortcodes) {
786
+			$this->_valid_shortcodes[$context] = $shortcodes;
787
+		}
788
+	}
789
+
790
+
791
+	/**
792
+	 * returns an array of addressee objects for event_admins
793
+	 *
794
+	 * @access protected
795
+	 * @return array array of EE_Messages_Addressee objects
796
+	 */
797
+	protected function _admin_addressees()
798
+	{
799
+		$admin_events = array();
800
+		$addressees   = array();
801
+		// first we need to get the event admin user id for all the events
802
+		// and setup an addressee object for each unique admin user.
803
+		foreach ($this->_data->events as $line_ref => $event) {
804
+			$admin_id = $this->_get_event_admin_id($event['ID']);
805
+			//make sure we are just including the events that belong to this admin!
806
+			$admin_events[$admin_id][$line_ref] = $event;
807
+		}
808
+		//k now we can loop through the event_admins and setup the addressee data.
809
+		foreach ($admin_events as $admin_id => $event_details) {
810
+			$aee          = array(
811
+				'user_id'        => $admin_id,
812
+				'events'         => $event_details,
813
+				'attendees'      => $this->_data->attendees,
814
+				'recipient_id'   => $admin_id,
815
+				'recipient_type' => 'WP_User',
816
+			);
817
+			$aee          = array_merge($this->_default_addressee_data, $aee);
818
+			$addressees[] = new EE_Messages_Addressee($aee);
819
+		}
820
+		return $addressees;
821
+	}
822
+
823
+
824
+	/**
825
+	 * Takes care of setting up the addressee object(s) for the primary attendee.
826
+	 *
827
+	 * @access protected
828
+	 * @return array of EE_Addressee objects
829
+	 */
830
+	protected function _primary_attendee_addressees()
831
+	{
832
+		$aee                   = $this->_default_addressee_data;
833
+		$aee['events']         = $this->_data->events;
834
+		$aee['attendees']      = $this->_data->attendees;
835
+		$aee['recipient_id']   = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0;
836
+		$aee['recipient_type'] = 'Attendee';
837
+		//great now we can instantiate the $addressee object and return (as an array);
838
+		$add[] = new EE_Messages_Addressee($aee);
839
+		return $add;
840
+	}
841
+
842
+
843
+	/**
844
+	 * Takes care of setting up the addressee object(s) for the registered attendees
845
+	 *
846
+	 * @access protected
847
+	 * @return array of EE_Addressee objects
848
+	 */
849
+	protected function _attendee_addressees()
850
+	{
851
+		$add = array();
852
+		//we just have to loop through the attendees.  We'll also set the attached events for each attendee.
853
+		//use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we?
854
+		$already_processed = array();
855
+		foreach ($this->_data->attendees as $att_id => $details) {
856
+			//set the attendee array to blank on each loop;
857
+			$aee = array();
858
+			if (isset($this->_data->reg_obj)
859
+				&& ($this->_data->reg_obj->attendee_ID() != $att_id)
860
+				&& $this->_single_message
861
+			) {
862
+				continue;
863
+			}
864
+			// is $this->_regs_for_sending present?
865
+			// If so, let's make sure we ONLY generate addressee for registrations in that array.
866
+			if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
867
+				$regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
868
+				if (empty($regs_allowed)) {
869
+					continue;
870
+				}
871
+			}
872
+			if (
873
+				in_array($details['attendee_email'], $already_processed)
874
+				&& apply_filters(
875
+					'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends',
876
+					true,
877
+					$this->_data,
878
+					$this
879
+				)
880
+			) {
881
+				continue;
882
+			}
883
+			$already_processed[] = $details['attendee_email'];
884
+			foreach ($details as $item => $value) {
885
+				$aee[$item] = $value;
886
+				if ($item == 'line_ref') {
887
+					foreach ($value as $event_id) {
888
+						$aee['events'][$event_id] = $this->_data->events[$event_id];
889
+					}
890
+				}
891
+				if ($item == 'attendee_email') {
892
+					$aee['attendee_email'] = $value;
893
+				}
894
+				/*if ( $item == 'registration_id' ) {
895 895
                     $aee['attendee_registration_id'] = $value;
896 896
                 }/**/
897
-            }
898
-            // note the FIRST reg object in this array is the one
899
-            // we'll use for this attendee as the primary registration for this attendee.
900
-            $aee['reg_obj']        = reset($this->_data->attendees[$att_id]['reg_objs']);
901
-            $aee['attendees']      = $this->_data->attendees;
902
-            $aee['recipient_id']   = $att_id;
903
-            $aee['recipient_type'] = 'Attendee';
904
-            //merge in the primary attendee data
905
-            $aee   = array_merge($this->_default_addressee_data, $aee);
906
-            $add[] = new EE_Messages_Addressee($aee);
907
-        }
908
-        return $add;
909
-    }
910
-
911
-
912
-    /**
913
-     * @param $event_id
914
-     * @return int
915
-     */
916
-    protected function _get_event_admin_id($event_id)
917
-    {
918
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
919
-        return $event instanceof EE_Event ? $event->wp_user() : 0;
920
-    }
897
+			}
898
+			// note the FIRST reg object in this array is the one
899
+			// we'll use for this attendee as the primary registration for this attendee.
900
+			$aee['reg_obj']        = reset($this->_data->attendees[$att_id]['reg_objs']);
901
+			$aee['attendees']      = $this->_data->attendees;
902
+			$aee['recipient_id']   = $att_id;
903
+			$aee['recipient_type'] = 'Attendee';
904
+			//merge in the primary attendee data
905
+			$aee   = array_merge($this->_default_addressee_data, $aee);
906
+			$add[] = new EE_Messages_Addressee($aee);
907
+		}
908
+		return $add;
909
+	}
910
+
911
+
912
+	/**
913
+	 * @param $event_id
914
+	 * @return int
915
+	 */
916
+	protected function _get_event_admin_id($event_id)
917
+	{
918
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
919
+		return $event instanceof EE_Event ? $event->wp_user() : 0;
920
+	}
921 921
 
922 922
 
923 923
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     {
410 410
         //validate context
411 411
         //valid context?
412
-        if (! isset($this->_contexts[$context])) {
412
+        if ( ! isset($this->_contexts[$context])) {
413 413
             throw new EE_Error(
414 414
                 sprintf(
415 415
                     __('The context %s is not a valid context for %s.', 'event_espresso'),
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     public function get_data_for_context($context, EE_Registration $registration, $id = 0)
466 466
     {
467 467
         //valid context?
468
-        if (! isset($this->_contexts[$context])) {
468
+        if ( ! isset($this->_contexts[$context])) {
469 469
             throw new EE_Error(
470 470
                 sprintf(
471 471
                     __('The context %s is not a valid context for %s.', 'event_espresso'),
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
             $this->_get_data_for_context($context, $registration, $id),
481 481
             $this
482 482
         );
483
-        $data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this);
483
+        $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this);
484 484
         //if empty then something went wrong!
485 485
         if (empty($data)) {
486 486
             throw new EE_Error(
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
     public function with_messengers()
541 541
     {
542 542
         return apply_filters(
543
-            'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this),
543
+            'FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this),
544 544
             $this->_with_messengers
545 545
         );
546 546
     }
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
     {
602 602
         //first class specific filter then filter that by the global filter.
603 603
         $master_templates = apply_filters(
604
-            'FHEE__' . get_class($this) . '__get_master_templates',
604
+            'FHEE__'.get_class($this).'__get_master_templates',
605 605
             $this->_master_templates
606 606
         );
607 607
         return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
@@ -624,9 +624,9 @@  discard block
 block discarded – undo
624 624
         $addressees        = array();
625 625
         $original_contexts = $this->_contexts;
626 626
         //if incoming context then limit to that context
627
-        if (! empty($context)) {
627
+        if ( ! empty($context)) {
628 628
             $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : '';
629
-            if (! empty($cntxt)) {
629
+            if ( ! empty($cntxt)) {
630 630
                 $this->_contexts           = array();
631 631
                 $this->_contexts[$context] = $cntxt;
632 632
             }
@@ -653,13 +653,13 @@  discard block
 block discarded – undo
653 653
     {
654 654
         //at a minimum, we NEED EE_Attendee objects.
655 655
         if (empty($this->_data->attendees)) {
656
-            return false;  //there's no data to process!
656
+            return false; //there's no data to process!
657 657
         }
658 658
         // process addressees for each context.  Child classes will have to have methods for
659 659
         // each context defined to handle the processing of the data object within them
660 660
         foreach ($this->_contexts as $context => $details) {
661
-            $xpctd_method = '_' . $context . '_addressees';
662
-            if (! method_exists($this, $xpctd_method)) {
661
+            $xpctd_method = '_'.$context.'_addressees';
662
+            if ( ! method_exists($this, $xpctd_method)) {
663 663
                 throw new EE_Error(
664 664
                     sprintf(
665 665
                         __(
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
             'total_ticket_count'       => $this->_data->total_ticket_count,
708 708
         );
709 709
         if (is_array($this->_data->primary_attendee_data)) {
710
-            $this->_default_addressee_data                    = array_merge(
710
+            $this->_default_addressee_data = array_merge(
711 711
                 $this->_default_addressee_data,
712 712
                 $this->_data->primary_attendee_data
713 713
             );
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
             'email',
751 751
             'messenger',
752 752
         );
753
-        $contexts       = $this->get_contexts();
753
+        $contexts = $this->get_contexts();
754 754
         foreach ($contexts as $context => $details) {
755 755
             $this->_valid_shortcodes[$context] = $all_shortcodes;
756 756
             //make sure non admin context does not include the event_author shortcodes
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         }
763 763
         // make sure admin context does not include the recipient_details shortcodes
764 764
         // IF we have admin context hooked in message types might not have that context.
765
-        if (! empty($this->_valid_shortcodes['admin'])) {
765
+        if ( ! empty($this->_valid_shortcodes['admin'])) {
766 766
             if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
767 767
                 unset($this->_valid_shortcodes['admin'][$key]);
768 768
             }
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
         }
808 808
         //k now we can loop through the event_admins and setup the addressee data.
809 809
         foreach ($admin_events as $admin_id => $event_details) {
810
-            $aee          = array(
810
+            $aee = array(
811 811
                 'user_id'        => $admin_id,
812 812
                 'events'         => $event_details,
813 813
                 'attendees'      => $this->_data->attendees,
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
             }
864 864
             // is $this->_regs_for_sending present?
865 865
             // If so, let's make sure we ONLY generate addressee for registrations in that array.
866
-            if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
866
+            if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
867 867
                 $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
868 868
                 if (empty($regs_allowed)) {
869 869
                     continue;
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.027');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.027');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Indentation   +1343 added lines, -1343 removed lines patch added patch discarded remove patch
@@ -17,1351 +17,1351 @@
 block discarded – undo
17 17
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step
18 18
 {
19 19
 
20
-    /**
21
-     * @type bool $_print_copy_info
22
-     */
23
-    private $_print_copy_info = false;
24
-
25
-    /**
26
-     * @type array $_attendee_data
27
-     */
28
-    private $_attendee_data = array();
29
-
30
-    /**
31
-     * @type array $_required_questions
32
-     */
33
-    private $_required_questions = array();
34
-
35
-    /**
36
-     * @type array $_registration_answers
37
-     */
38
-    private $_registration_answers = array();
39
-
40
-
41
-    /**
42
-     *    class constructor
43
-     *
44
-     * @access    public
45
-     * @param    EE_Checkout $checkout
46
-     */
47
-    public function __construct(EE_Checkout $checkout)
48
-    {
49
-        $this->_slug     = 'attendee_information';
50
-        $this->_name     = esc_html__('Attendee Information', 'event_espresso');
51
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
52
-        $this->checkout  = $checkout;
53
-        $this->_reset_success_message();
54
-        $this->set_instructions(
55
-            esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
56
-        );
57
-    }
58
-
59
-
60
-    public function translate_js_strings()
61
-    {
62
-        EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
63
-            ' is a required question.',
64
-            'event_espresso'
65
-        );
66
-        EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
67
-            ' is a required question. Please enter a value for at least one of the options.',
68
-            'event_espresso'
69
-        );
70
-        EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
71
-            'Please answer all required questions correctly before proceeding.',
72
-            'event_espresso'
73
-        );
74
-        EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
75
-            esc_html__(
76
-                'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
77
-                'event_espresso'
78
-            ),
79
-            '<br/>'
80
-        );
81
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
82
-            'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
83
-            'event_espresso'
84
-        );
85
-        EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
86
-            'You must enter a valid email address.',
87
-            'event_espresso'
88
-        );
89
-        EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
90
-            'You must enter a valid email address and answer all other required questions before you can proceed.',
91
-            'event_espresso'
92
-        );
93
-    }
94
-
95
-
96
-    public function enqueue_styles_and_scripts()
97
-    {
98
-    }
99
-
100
-
101
-    /**
102
-     * @return boolean
103
-     */
104
-    public function initialize_reg_step()
105
-    {
106
-        return true;
107
-    }
108
-
109
-
110
-    /**
111
-     * @return EE_Form_Section_Proper
112
-     * @throws EE_Error
113
-     * @throws InvalidArgumentException
114
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
115
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
116
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
117
-     */
118
-    public function generate_reg_form()
119
-    {
120
-        $this->_print_copy_info = false;
121
-        $primary_registrant     = null;
122
-        // autoload Line_Item_Display classes
123
-        EEH_Autoloader::register_line_item_display_autoloaders();
124
-        $Line_Item_Display = new EE_Line_Item_Display();
125
-        // calculate taxes
126
-        $Line_Item_Display->display_line_item(
127
-            $this->checkout->cart->get_grand_total(),
128
-            array('set_tax_rate' => true)
129
-        );
130
-        /** @var $subsections EE_Form_Section_Proper[] */
131
-        $subsections   = array(
132
-            'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
133
-        );
134
-        $template_args = array(
135
-            'revisit'       => $this->checkout->revisit,
136
-            'registrations' => array(),
137
-            'ticket_count'  => array(),
138
-        );
139
-        // grab the saved registrations from the transaction
140
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
141
-        if ($registrations) {
142
-            foreach ($registrations as $registration) {
143
-                // can this registration be processed during this visit ?
144
-                if ($registration instanceof EE_Registration
145
-                    && $this->checkout->visit_allows_processing_of_this_registration($registration)
146
-                ) {
147
-                    $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
148
-                    if (! $this->checkout->admin_request) {
149
-                        $template_args['registrations'][$registration->reg_url_link()]    = $registration;
150
-                        $template_args['ticket_count'][$registration->ticket()->ID()]     = isset(
151
-                            $template_args['ticket_count'][$registration->ticket()->ID()]
152
-                        )
153
-                            ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
154
-                            : 1;
155
-                        $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
156
-                            $this->checkout->cart->get_grand_total(),
157
-                            'Ticket',
158
-                            array($registration->ticket()->ID())
159
-                        );
160
-                        $ticket_line_item = is_array($ticket_line_item)
161
-                            ? reset($ticket_line_item)
162
-                            : $ticket_line_item;
163
-                        $template_args['ticket_line_item'][$registration->ticket()->ID()] =
164
-                            $Line_Item_Display->display_line_item($ticket_line_item);
165
-                    }
166
-                    if ($registration->is_primary_registrant()) {
167
-                        $primary_registrant = $registration->reg_url_link();
168
-                    }
169
-                }
170
-            }
171
-            // print_copy_info ?
172
-            if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
173
-                // TODO: add admin option for toggling copy attendee info,
174
-                // then use that value to change $this->_print_copy_info
175
-                $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
176
-                    ? $this->_copy_attendee_info_form()
177
-                    : $this->_auto_copy_attendee_info();
178
-                // generate hidden input
179
-                if (isset($subsections[$primary_registrant])
180
-                    && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
181
-                ) {
182
-                    $subsections[$primary_registrant]->add_subsections(
183
-                        $copy_options,
184
-                        'primary_registrant',
185
-                        false
186
-                    );
187
-                }
188
-            }
189
-        }
190
-
191
-        return new EE_Form_Section_Proper(
192
-            array(
193
-                'name'            => $this->reg_form_name(),
194
-                'html_id'         => $this->reg_form_name(),
195
-                'subsections'     => $subsections,
196
-                'layout_strategy' => $this->checkout->admin_request ?
197
-                    new EE_Div_Per_Section_Layout() :
198
-                    new EE_Template_Layout(
199
-                        array(
200
-                            'layout_template_file' => $this->_template, // layout_template
201
-                            'template_args'        => $template_args,
202
-                        )
203
-                    ),
204
-            )
205
-        );
206
-    }
207
-
208
-
209
-    /**
210
-     * @param EE_Registration $registration
211
-     * @return EE_Form_Section_Base
212
-     * @throws EE_Error
213
-     * @throws InvalidArgumentException
214
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
215
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
216
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
217
-     */
218
-    private function _registrations_reg_form(EE_Registration $registration)
219
-    {
220
-        static $attendee_nmbr = 1;
221
-        $form_args = array();
222
-        // verify that registration has valid event
223
-        if ($registration->event() instanceof EE_Event) {
224
-            $question_groups = $registration->event()->question_groups(
225
-                apply_filters(
226
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
227
-                    array(
228
-                        array(
229
-                            'Event.EVT_ID'                     => $registration->event()->ID(),
230
-                            'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false,
231
-                        ),
232
-                        'order_by' => array('QSG_order' => 'ASC'),
233
-                    ),
234
-                    $registration,
235
-                    $this
236
-                )
237
-            );
238
-            if ($question_groups) {
239
-                // array of params to pass to parent constructor
240
-                $form_args = array(
241
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
242
-                    'html_class'      => 'ee-reg-form-attendee-dv',
243
-                    'html_style'      => $this->checkout->admin_request
244
-                        ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
245
-                        : '',
246
-                    'subsections'     => array(),
247
-                    'layout_strategy' => new EE_Fieldset_Section_Layout(
248
-                        array(
249
-                            'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
250
-                            'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr),
251
-                        )
252
-                    ),
253
-                );
254
-                foreach ($question_groups as $question_group) {
255
-                    if ($question_group instanceof EE_Question_Group) {
256
-                        $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
257
-                            $registration,
258
-                            $question_group
259
-                        );
260
-                    }
261
-                }
262
-                // add hidden input
263
-                $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
264
-                    $registration
265
-                );
266
-                // if we have question groups for additional attendees, then display the copy options
267
-                $this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
268
-                if ($registration->is_primary_registrant()) {
269
-                    // generate hidden input
270
-                    $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs(
271
-                        $registration
272
-                    );
273
-                }
274
-            }
275
-        }
276
-        $attendee_nmbr++;
277
-        return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : new EE_Form_Section_HTML();
278
-    }
279
-
280
-
281
-    /**
282
-     * _additional_attendee_reg_info_input
283
-     *
284
-     * @access public
285
-     * @param EE_Registration $registration
286
-     * @param bool            $additional_attendee_reg_info
287
-     * @return    EE_Form_Input_Base
288
-     * @throws \EE_Error
289
-     */
290
-    private function _additional_attendee_reg_info_input(
291
-        EE_Registration $registration,
292
-        $additional_attendee_reg_info = true
293
-    ) {
294
-        // generate hidden input
295
-        return new EE_Hidden_Input(
296
-            array(
297
-                'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
298
-                'default' => $additional_attendee_reg_info,
299
-            )
300
-        );
301
-    }
302
-
303
-
304
-    /**
305
-     * @param EE_Registration   $registration
306
-     * @param EE_Question_Group $question_group
307
-     * @return EE_Form_Section_Proper
308
-     * @throws EE_Error
309
-     * @throws InvalidArgumentException
310
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
311
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
312
-     */
313
-    private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group)
314
-    {
315
-        // array of params to pass to parent constructor
316
-        $form_args = array(
317
-            'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
318
-            'html_class'      => $this->checkout->admin_request
319
-                ? 'form-table ee-reg-form-qstn-grp-dv'
320
-                : 'ee-reg-form-qstn-grp-dv',
321
-            'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
322
-            'subsections'     => array(
323
-                'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
324
-            ),
325
-            'layout_strategy' => $this->checkout->admin_request
326
-                ? new EE_Admin_Two_Column_Layout()
327
-                : new EE_Div_Per_Section_Layout(),
328
-        );
329
-        // where params
330
-        $query_params = array('QST_deleted' => 0);
331
-        // don't load admin only questions on the frontend
332
-        if (! $this->checkout->admin_request) {
333
-            $query_params['QST_admin_only'] = array('!=', true);
334
-        }
335
-        $questions = $question_group->get_many_related(
336
-            'Question',
337
-            apply_filters(
338
-                'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
339
-                array(
340
-                    $query_params,
341
-                    'order_by' => array(
342
-                        'Question_Group_Question.QGQ_order' => 'ASC',
343
-                    ),
344
-                ),
345
-                $question_group,
346
-                $registration,
347
-                $this
348
-            )
349
-        );
350
-        // filter for additional content before questions
351
-        $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(
352
-            apply_filters(
353
-                'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
354
-                '',
355
-                $registration,
356
-                $question_group,
357
-                $this
358
-            )
359
-        );
360
-        // loop thru questions
361
-        foreach ($questions as $question) {
362
-            if ($question instanceof EE_Question) {
363
-                $identifier                            = $question->is_system_question()
364
-                    ? $question->system_ID()
365
-                    : $question->ID();
366
-                $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
367
-            }
368
-        }
369
-        $form_args['subsections'] = apply_filters(
370
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
371
-            $form_args['subsections'],
372
-            $registration,
373
-            $question_group,
374
-            $this
375
-        );
376
-        // filter for additional content after questions
377
-        $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(
378
-            apply_filters(
379
-                'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
380
-                '',
381
-                $registration,
382
-                $question_group,
383
-                $this
384
-            )
385
-        );
20
+	/**
21
+	 * @type bool $_print_copy_info
22
+	 */
23
+	private $_print_copy_info = false;
24
+
25
+	/**
26
+	 * @type array $_attendee_data
27
+	 */
28
+	private $_attendee_data = array();
29
+
30
+	/**
31
+	 * @type array $_required_questions
32
+	 */
33
+	private $_required_questions = array();
34
+
35
+	/**
36
+	 * @type array $_registration_answers
37
+	 */
38
+	private $_registration_answers = array();
39
+
40
+
41
+	/**
42
+	 *    class constructor
43
+	 *
44
+	 * @access    public
45
+	 * @param    EE_Checkout $checkout
46
+	 */
47
+	public function __construct(EE_Checkout $checkout)
48
+	{
49
+		$this->_slug     = 'attendee_information';
50
+		$this->_name     = esc_html__('Attendee Information', 'event_espresso');
51
+		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
52
+		$this->checkout  = $checkout;
53
+		$this->_reset_success_message();
54
+		$this->set_instructions(
55
+			esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
56
+		);
57
+	}
58
+
59
+
60
+	public function translate_js_strings()
61
+	{
62
+		EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
63
+			' is a required question.',
64
+			'event_espresso'
65
+		);
66
+		EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
67
+			' is a required question. Please enter a value for at least one of the options.',
68
+			'event_espresso'
69
+		);
70
+		EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
71
+			'Please answer all required questions correctly before proceeding.',
72
+			'event_espresso'
73
+		);
74
+		EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
75
+			esc_html__(
76
+				'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
77
+				'event_espresso'
78
+			),
79
+			'<br/>'
80
+		);
81
+		EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
82
+			'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
83
+			'event_espresso'
84
+		);
85
+		EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
86
+			'You must enter a valid email address.',
87
+			'event_espresso'
88
+		);
89
+		EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
90
+			'You must enter a valid email address and answer all other required questions before you can proceed.',
91
+			'event_espresso'
92
+		);
93
+	}
94
+
95
+
96
+	public function enqueue_styles_and_scripts()
97
+	{
98
+	}
99
+
100
+
101
+	/**
102
+	 * @return boolean
103
+	 */
104
+	public function initialize_reg_step()
105
+	{
106
+		return true;
107
+	}
108
+
109
+
110
+	/**
111
+	 * @return EE_Form_Section_Proper
112
+	 * @throws EE_Error
113
+	 * @throws InvalidArgumentException
114
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
115
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
116
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
117
+	 */
118
+	public function generate_reg_form()
119
+	{
120
+		$this->_print_copy_info = false;
121
+		$primary_registrant     = null;
122
+		// autoload Line_Item_Display classes
123
+		EEH_Autoloader::register_line_item_display_autoloaders();
124
+		$Line_Item_Display = new EE_Line_Item_Display();
125
+		// calculate taxes
126
+		$Line_Item_Display->display_line_item(
127
+			$this->checkout->cart->get_grand_total(),
128
+			array('set_tax_rate' => true)
129
+		);
130
+		/** @var $subsections EE_Form_Section_Proper[] */
131
+		$subsections   = array(
132
+			'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
133
+		);
134
+		$template_args = array(
135
+			'revisit'       => $this->checkout->revisit,
136
+			'registrations' => array(),
137
+			'ticket_count'  => array(),
138
+		);
139
+		// grab the saved registrations from the transaction
140
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
141
+		if ($registrations) {
142
+			foreach ($registrations as $registration) {
143
+				// can this registration be processed during this visit ?
144
+				if ($registration instanceof EE_Registration
145
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
146
+				) {
147
+					$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
148
+					if (! $this->checkout->admin_request) {
149
+						$template_args['registrations'][$registration->reg_url_link()]    = $registration;
150
+						$template_args['ticket_count'][$registration->ticket()->ID()]     = isset(
151
+							$template_args['ticket_count'][$registration->ticket()->ID()]
152
+						)
153
+							? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
154
+							: 1;
155
+						$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
156
+							$this->checkout->cart->get_grand_total(),
157
+							'Ticket',
158
+							array($registration->ticket()->ID())
159
+						);
160
+						$ticket_line_item = is_array($ticket_line_item)
161
+							? reset($ticket_line_item)
162
+							: $ticket_line_item;
163
+						$template_args['ticket_line_item'][$registration->ticket()->ID()] =
164
+							$Line_Item_Display->display_line_item($ticket_line_item);
165
+					}
166
+					if ($registration->is_primary_registrant()) {
167
+						$primary_registrant = $registration->reg_url_link();
168
+					}
169
+				}
170
+			}
171
+			// print_copy_info ?
172
+			if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
173
+				// TODO: add admin option for toggling copy attendee info,
174
+				// then use that value to change $this->_print_copy_info
175
+				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
176
+					? $this->_copy_attendee_info_form()
177
+					: $this->_auto_copy_attendee_info();
178
+				// generate hidden input
179
+				if (isset($subsections[$primary_registrant])
180
+					&& $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
181
+				) {
182
+					$subsections[$primary_registrant]->add_subsections(
183
+						$copy_options,
184
+						'primary_registrant',
185
+						false
186
+					);
187
+				}
188
+			}
189
+		}
190
+
191
+		return new EE_Form_Section_Proper(
192
+			array(
193
+				'name'            => $this->reg_form_name(),
194
+				'html_id'         => $this->reg_form_name(),
195
+				'subsections'     => $subsections,
196
+				'layout_strategy' => $this->checkout->admin_request ?
197
+					new EE_Div_Per_Section_Layout() :
198
+					new EE_Template_Layout(
199
+						array(
200
+							'layout_template_file' => $this->_template, // layout_template
201
+							'template_args'        => $template_args,
202
+						)
203
+					),
204
+			)
205
+		);
206
+	}
207
+
208
+
209
+	/**
210
+	 * @param EE_Registration $registration
211
+	 * @return EE_Form_Section_Base
212
+	 * @throws EE_Error
213
+	 * @throws InvalidArgumentException
214
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
215
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
216
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
217
+	 */
218
+	private function _registrations_reg_form(EE_Registration $registration)
219
+	{
220
+		static $attendee_nmbr = 1;
221
+		$form_args = array();
222
+		// verify that registration has valid event
223
+		if ($registration->event() instanceof EE_Event) {
224
+			$question_groups = $registration->event()->question_groups(
225
+				apply_filters(
226
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters',
227
+					array(
228
+						array(
229
+							'Event.EVT_ID'                     => $registration->event()->ID(),
230
+							'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false,
231
+						),
232
+						'order_by' => array('QSG_order' => 'ASC'),
233
+					),
234
+					$registration,
235
+					$this
236
+				)
237
+			);
238
+			if ($question_groups) {
239
+				// array of params to pass to parent constructor
240
+				$form_args = array(
241
+					'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
242
+					'html_class'      => 'ee-reg-form-attendee-dv',
243
+					'html_style'      => $this->checkout->admin_request
244
+						? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
245
+						: '',
246
+					'subsections'     => array(),
247
+					'layout_strategy' => new EE_Fieldset_Section_Layout(
248
+						array(
249
+							'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
250
+							'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr),
251
+						)
252
+					),
253
+				);
254
+				foreach ($question_groups as $question_group) {
255
+					if ($question_group instanceof EE_Question_Group) {
256
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
257
+							$registration,
258
+							$question_group
259
+						);
260
+					}
261
+				}
262
+				// add hidden input
263
+				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
264
+					$registration
265
+				);
266
+				// if we have question groups for additional attendees, then display the copy options
267
+				$this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
268
+				if ($registration->is_primary_registrant()) {
269
+					// generate hidden input
270
+					$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs(
271
+						$registration
272
+					);
273
+				}
274
+			}
275
+		}
276
+		$attendee_nmbr++;
277
+		return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : new EE_Form_Section_HTML();
278
+	}
279
+
280
+
281
+	/**
282
+	 * _additional_attendee_reg_info_input
283
+	 *
284
+	 * @access public
285
+	 * @param EE_Registration $registration
286
+	 * @param bool            $additional_attendee_reg_info
287
+	 * @return    EE_Form_Input_Base
288
+	 * @throws \EE_Error
289
+	 */
290
+	private function _additional_attendee_reg_info_input(
291
+		EE_Registration $registration,
292
+		$additional_attendee_reg_info = true
293
+	) {
294
+		// generate hidden input
295
+		return new EE_Hidden_Input(
296
+			array(
297
+				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
298
+				'default' => $additional_attendee_reg_info,
299
+			)
300
+		);
301
+	}
302
+
303
+
304
+	/**
305
+	 * @param EE_Registration   $registration
306
+	 * @param EE_Question_Group $question_group
307
+	 * @return EE_Form_Section_Proper
308
+	 * @throws EE_Error
309
+	 * @throws InvalidArgumentException
310
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
311
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
312
+	 */
313
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group)
314
+	{
315
+		// array of params to pass to parent constructor
316
+		$form_args = array(
317
+			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
318
+			'html_class'      => $this->checkout->admin_request
319
+				? 'form-table ee-reg-form-qstn-grp-dv'
320
+				: 'ee-reg-form-qstn-grp-dv',
321
+			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
322
+			'subsections'     => array(
323
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
324
+			),
325
+			'layout_strategy' => $this->checkout->admin_request
326
+				? new EE_Admin_Two_Column_Layout()
327
+				: new EE_Div_Per_Section_Layout(),
328
+		);
329
+		// where params
330
+		$query_params = array('QST_deleted' => 0);
331
+		// don't load admin only questions on the frontend
332
+		if (! $this->checkout->admin_request) {
333
+			$query_params['QST_admin_only'] = array('!=', true);
334
+		}
335
+		$questions = $question_group->get_many_related(
336
+			'Question',
337
+			apply_filters(
338
+				'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params',
339
+				array(
340
+					$query_params,
341
+					'order_by' => array(
342
+						'Question_Group_Question.QGQ_order' => 'ASC',
343
+					),
344
+				),
345
+				$question_group,
346
+				$registration,
347
+				$this
348
+			)
349
+		);
350
+		// filter for additional content before questions
351
+		$form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML(
352
+			apply_filters(
353
+				'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
354
+				'',
355
+				$registration,
356
+				$question_group,
357
+				$this
358
+			)
359
+		);
360
+		// loop thru questions
361
+		foreach ($questions as $question) {
362
+			if ($question instanceof EE_Question) {
363
+				$identifier                            = $question->is_system_question()
364
+					? $question->system_ID()
365
+					: $question->ID();
366
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
367
+			}
368
+		}
369
+		$form_args['subsections'] = apply_filters(
370
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array',
371
+			$form_args['subsections'],
372
+			$registration,
373
+			$question_group,
374
+			$this
375
+		);
376
+		// filter for additional content after questions
377
+		$form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML(
378
+			apply_filters(
379
+				'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
380
+				'',
381
+				$registration,
382
+				$question_group,
383
+				$this
384
+			)
385
+		);
386 386
 //		d( $form_args );
387
-        $question_group_reg_form = new EE_Form_Section_Proper($form_args);
388
-        return apply_filters(
389
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
390
-            $question_group_reg_form,
391
-            $registration,
392
-            $question_group,
393
-            $this
394
-        );
395
-    }
396
-
397
-
398
-    /**
399
-     * @access public
400
-     * @param EE_Question_Group $question_group
401
-     * @return    EE_Form_Section_HTML
402
-     */
403
-    private function _question_group_header(EE_Question_Group $question_group)
404
-    {
405
-        $html = '';
406
-        // group_name
407
-        if ($question_group->show_group_name() && $question_group->name() !== '') {
408
-            if ($this->checkout->admin_request) {
409
-                $html .= EEH_HTML::br();
410
-                $html .= EEH_HTML::h3(
411
-                    $question_group->name(),
412
-                    '',
413
-                    'ee-reg-form-qstn-grp-title title',
414
-                    'font-size: 1.3em; padding-left:0;'
415
-                );
416
-            } else {
417
-                $html .= EEH_HTML::h4(
418
-                    $question_group->name(),
419
-                    '',
420
-                    'ee-reg-form-qstn-grp-title section-title'
421
-                );
422
-            }
423
-        }
424
-        // group_desc
425
-        if ($question_group->show_group_desc() && $question_group->desc() !== '') {
426
-            $html .= EEH_HTML::p(
427
-                $question_group->desc(),
428
-                '',
429
-                $this->checkout->admin_request
430
-                    ? 'ee-reg-form-qstn-grp-desc-pg'
431
-                    : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
432
-            );
433
-        }
434
-        return new EE_Form_Section_HTML($html);
435
-    }
436
-
437
-
438
-    /**
439
-     * @access public
440
-     * @return    EE_Form_Section_Proper
441
-     * @throws \EE_Error
442
-     */
443
-    private function _copy_attendee_info_form()
444
-    {
445
-        // array of params to pass to parent constructor
446
-        return new EE_Form_Section_Proper(
447
-            array(
448
-                'subsections'     => $this->_copy_attendee_info_inputs(),
449
-                'layout_strategy' => new EE_Template_Layout(
450
-                    array(
451
-                        'layout_template_file'     => SPCO_REG_STEPS_PATH
452
-                                                      . $this->_slug
453
-                                                      . DS
454
-                                                      . 'copy_attendee_info.template.php',
455
-                        'begin_template_file'      => null,
456
-                        'input_template_file'      => null,
457
-                        'subsection_template_file' => null,
458
-                        'end_template_file'        => null,
459
-                    )
460
-                ),
461
-            )
462
-        );
463
-    }
464
-
465
-
466
-    /**
467
-     * _auto_copy_attendee_info
468
-     *
469
-     * @access public
470
-     * @return EE_Form_Section_HTML
471
-     */
472
-    private function _auto_copy_attendee_info()
473
-    {
474
-        return new EE_Form_Section_HTML(
475
-            EEH_Template::locate_template(
476
-                SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
477
-                apply_filters(
478
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
479
-                    array()
480
-                ),
481
-                true,
482
-                true
483
-            )
484
-        );
485
-    }
486
-
487
-
488
-    /**
489
-     * _copy_attendee_info_inputs
490
-     *
491
-     * @access public
492
-     * @return array
493
-     * @throws \EE_Error
494
-     */
495
-    private function _copy_attendee_info_inputs()
496
-    {
497
-        $copy_attendee_info_inputs = array();
498
-        $prev_ticket               = null;
499
-        // grab the saved registrations from the transaction
500
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
501
-        foreach ($registrations as $registration) {
502
-            // for all  attendees other than the primary attendee
503
-            if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
504
-                // if this is a new ticket OR if this is the very first additional attendee after the primary attendee
505
-                if ($registration->ticket()->ID() !== $prev_ticket) {
506
-                    $item_name = $registration->ticket()->name();
507
-                    $item_name .= $registration->ticket()->description() !== ''
508
-                        ? ' - ' . $registration->ticket()->description()
509
-                        : '';
510
-                    $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']'] =
511
-                        new EE_Form_Section_HTML(
512
-                            '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
513
-                        );
514
-                    $prev_ticket = $registration->ticket()->ID();
515
-                }
516
-
517
-                $copy_attendee_info_inputs['spco_copy_attendee_chk[' . $registration->ID() . ']'] =
518
-                    new EE_Checkbox_Multi_Input(
519
-                        array(
520
-                            $registration->ID() => sprintf(
521
-                                esc_html__('Attendee #%s', 'event_espresso'),
522
-                                $registration->count()
523
-                            ),
524
-                        ),
525
-                        array(
526
-                            'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
527
-                            'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
528
-                            'display_html_label_text' => false,
529
-                        )
530
-                    );
531
-            }
532
-        }
533
-        return $copy_attendee_info_inputs;
534
-    }
535
-
536
-
537
-    /**
538
-     * _additional_primary_registrant_inputs
539
-     *
540
-     * @access public
541
-     * @param EE_Registration $registration
542
-     * @return    EE_Form_Input_Base
543
-     * @throws \EE_Error
544
-     */
545
-    private function _additional_primary_registrant_inputs(EE_Registration $registration)
546
-    {
547
-        // generate hidden input
548
-        return new EE_Hidden_Input(
549
-            array(
550
-                'html_id' => 'primary_registrant',
551
-                'default' => $registration->reg_url_link(),
552
-            )
553
-        );
554
-    }
555
-
556
-
557
-    /**
558
-     * @access public
559
-     * @param EE_Registration $registration
560
-     * @param EE_Question     $question
561
-     * @return EE_Form_Input_Base
562
-     * @throws EE_Error
563
-     * @throws InvalidArgumentException
564
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
565
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
566
-     */
567
-    public function reg_form_question(EE_Registration $registration, EE_Question $question)
568
-    {
569
-
570
-        // if this question was for an attendee detail, then check for that answer
571
-        $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
572
-            $registration,
573
-            $question->system_ID()
574
-        );
575
-        $answer       = $answer_value === null
576
-            ? EEM_Answer::instance()->get_one(
577
-                array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
578
-            )
579
-            : null;
580
-        // if NOT returning to edit an existing registration
581
-        // OR if this question is for an attendee property
582
-        // OR we still don't have an EE_Answer object
583
-        if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
584
-            // create an EE_Answer object for storing everything in
585
-            $answer = EE_Answer::new_instance(array(
586
-                'QST_ID' => $question->ID(),
587
-                'REG_ID' => $registration->ID(),
588
-            ));
589
-        }
590
-        // verify instance
591
-        if ($answer instanceof EE_Answer) {
592
-            if (! empty($answer_value)) {
593
-                $answer->set('ANS_value', $answer_value);
594
-            }
595
-            $answer->cache('Question', $question);
596
-            //remember system ID had a bug where sometimes it could be null
597
-            $answer_cache_id = $question->is_system_question()
598
-                ? $question->system_ID() . '-' . $registration->reg_url_link()
599
-                : $question->ID() . '-' . $registration->reg_url_link();
600
-            $registration->cache('Answer', $answer, $answer_cache_id);
601
-        }
602
-        return $this->_generate_question_input($registration, $question, $answer);
603
-    }
604
-
605
-
606
-    /**
607
-     * @param EE_Registration $registration
608
-     * @param EE_Question     $question
609
-     * @param                 mixed EE_Answer|NULL      $answer
610
-     * @return EE_Form_Input_Base
611
-     * @throws \EE_Error
612
-     */
613
-    private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
614
-    {
615
-        $identifier                             = $question->is_system_question()
616
-            ? $question->system_ID()
617
-            : $question->ID();
618
-        $this->_required_questions[$identifier] = $question->required() ? true : false;
619
-        add_filter(
620
-            'FHEE__EE_Question__generate_form_input__country_options',
621
-            array($this, 'use_cached_countries_for_form_input'),
622
-            10,
623
-            4
624
-        );
625
-        add_filter(
626
-            'FHEE__EE_Question__generate_form_input__state_options',
627
-            array($this, 'use_cached_states_for_form_input'),
628
-            10,
629
-            4
630
-        );
631
-        $input_constructor_args                  = array(
632
-            'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
633
-            'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
634
-            'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
635
-            'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
636
-            'html_label_class' => 'ee-reg-qstn',
637
-        );
638
-        $input_constructor_args['html_label_id'] .= '-lbl';
639
-        if ($answer instanceof EE_Answer && $answer->ID()) {
640
-            $input_constructor_args['html_name']     .= '[' . $answer->ID() . ']';
641
-            $input_constructor_args['html_id']       .= '-' . $answer->ID();
642
-            $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
643
-        }
644
-        $form_input = $question->generate_form_input(
645
-            $registration,
646
-            $answer,
647
-            $input_constructor_args
648
-        );
649
-        remove_filter(
650
-            'FHEE__EE_Question__generate_form_input__country_options',
651
-            array($this, 'use_cached_countries_for_form_input')
652
-        );
653
-        remove_filter(
654
-            'FHEE__EE_Question__generate_form_input__state_options',
655
-            array($this, 'use_cached_states_for_form_input')
656
-        );
657
-        return $form_input;
658
-    }
659
-
660
-
661
-    /**
662
-     * Gets the list of countries for the form input
663
-     *
664
-     * @param array|null       $countries_list
665
-     * @param \EE_Question     $question
666
-     * @param \EE_Registration $registration
667
-     * @param \EE_Answer       $answer
668
-     * @return array 2d keys are country IDs, values are their names
669
-     * @throws EE_Error
670
-     * @throws InvalidArgumentException
671
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
672
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
673
-     */
674
-    public function use_cached_countries_for_form_input(
675
-        $countries_list,
676
-        \EE_Question $question = null,
677
-        \EE_Registration $registration = null,
678
-        \EE_Answer $answer = null
679
-    ) {
680
-        $country_options = array('' => '');
681
-        // get possibly cached list of countries
682
-        $countries = $this->checkout->action === 'process_reg_step'
683
-            ? EEM_Country::instance()->get_all_countries()
684
-            : EEM_Country::instance()->get_all_active_countries();
685
-        if (! empty($countries)) {
686
-            foreach ($countries as $country) {
687
-                if ($country instanceof EE_Country) {
688
-                    $country_options[$country->ID()] = $country->name();
689
-                }
690
-            }
691
-        }
692
-        if ($question instanceof EE_Question
693
-            && $registration instanceof EE_Registration) {
694
-            $answer = EEM_Answer::instance()->get_one(
695
-                array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
696
-            );
697
-        } else {
698
-            $answer = EE_Answer::new_instance();
699
-        }
700
-        $country_options = apply_filters(
701
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
702
-            $country_options,
703
-            $this,
704
-            $registration,
705
-            $question,
706
-            $answer
707
-        );
708
-        return $country_options;
709
-    }
710
-
711
-
712
-    /**
713
-     * Gets the list of states for the form input
714
-     *
715
-     * @param array|null       $states_list
716
-     * @param \EE_Question     $question
717
-     * @param \EE_Registration $registration
718
-     * @param \EE_Answer       $answer
719
-     * @return array 2d keys are state IDs, values are their names
720
-     * @throws EE_Error
721
-     * @throws InvalidArgumentException
722
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
723
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
724
-     */
725
-    public function use_cached_states_for_form_input(
726
-        $states_list,
727
-        \EE_Question $question = null,
728
-        \EE_Registration $registration = null,
729
-        \EE_Answer $answer = null
730
-    ) {
731
-        $state_options = array('' => array('' => ''));
732
-        $states        = $this->checkout->action === 'process_reg_step'
733
-            ? EEM_State::instance()->get_all_states()
734
-            : EEM_State::instance()->get_all_active_states();
735
-        if (! empty($states)) {
736
-            foreach ($states as $state) {
737
-                if ($state instanceof EE_State) {
738
-                    $state_options[$state->country()->name()][$state->ID()] = $state->name();
739
-                }
740
-            }
741
-        }
742
-        $state_options = apply_filters(
743
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
744
-            $state_options,
745
-            $this,
746
-            $registration,
747
-            $question,
748
-            $answer
749
-        );
750
-        return $state_options;
751
-    }
752
-
753
-
754
-
755
-
756
-
757
-
758
-    /********************************************************************************************************/
759
-    /****************************************  PROCESS REG STEP  ****************************************/
760
-    /********************************************************************************************************/
761
-    /**
762
-     * @return bool
763
-     * @throws EE_Error
764
-     * @throws InvalidArgumentException
765
-     * @throws ReflectionException
766
-     * @throws RuntimeException
767
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
768
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
769
-     */
770
-    public function process_reg_step()
771
-    {
772
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
773
-        // grab validated data from form
774
-        $valid_data = $this->checkout->current_step->valid_data();
775
-        // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
776
-        // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
777
-        // if we don't have any $valid_data then something went TERRIBLY WRONG !!!
778
-        if (empty($valid_data)) {
779
-            EE_Error::add_error(
780
-                esc_html__('No valid question responses were received.', 'event_espresso'),
781
-                __FILE__,
782
-                __FUNCTION__,
783
-                __LINE__
784
-            );
785
-            return false;
786
-        }
787
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
788
-            EE_Error::add_error(
789
-                esc_html__(
790
-                    'A valid transaction could not be initiated for processing your registrations.',
791
-                    'event_espresso'
792
-                ),
793
-                __FILE__,
794
-                __FUNCTION__,
795
-                __LINE__
796
-            );
797
-            return false;
798
-        }
799
-        // get cached registrations
800
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
801
-        // verify we got the goods
802
-        if (empty($registrations)) {
803
-            //combine the old translated string with a new one, in order to not break translations
804
-
805
-            // @codingStandardsIgnoreStart
806
-            $error_message = esc_html__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' )
807
-                             . sprintf(
808
-                                 esc_html__('%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', 'event_espresso'),
809
-                                 '<a href="'
810
-                                 . apply_filters(
811
-                                     'FHEE__EE_SPCO_Reg_Step_Attendee_Information__process_reg_step__no_regs_link_to_event_list',
812
-                                     get_post_type_archive_link('espresso_events')
813
-                                 )
814
-                                 . '" >',
815
-                                 '</a>',
816
-                                 '<br />'
817
-                             );
818
-            // @codingStandardsIgnoreEnd
819
-            EE_Error::add_error(
820
-                $error_message,
821
-                __FILE__,
822
-                __FUNCTION__,
823
-                __LINE__
824
-            );
825
-            return false;
826
-        }
827
-        // extract attendee info from form data and save to model objects
828
-        $registrations_processed = $this->_process_registrations($registrations, $valid_data);
829
-        // if first pass thru SPCO,
830
-        // then let's check processed registrations against the total number of tickets in the cart
831
-        if ($registrations_processed === false) {
832
-            // but return immediately if the previous step exited early due to errors
833
-            return false;
834
-        } elseif (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
835
-            // generate a correctly translated string for all possible singular/plural combinations
836
-            if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
837
-                $error_msg = sprintf(
838
-                    esc_html__(
839
-                        'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
840
-                        'event_espresso'
841
-                    ),
842
-                    $this->checkout->total_ticket_count,
843
-                    $registrations_processed
844
-                );
845
-            } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
846
-                $error_msg = sprintf(
847
-                    esc_html__(
848
-                        'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
849
-                        'event_espresso'
850
-                    ),
851
-                    $this->checkout->total_ticket_count,
852
-                    $registrations_processed
853
-                );
854
-            } else {
855
-                $error_msg = sprintf(
856
-                    esc_html__(
857
-                        'There was a total of %1$d tickets in the Event Queue, but %2$ds registrations were processed',
858
-                        'event_espresso'
859
-                    ),
860
-                    $this->checkout->total_ticket_count,
861
-                    $registrations_processed
862
-                );
863
-            }
864
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
865
-            return false;
866
-        }
867
-        // mark this reg step as completed
868
-        $this->set_completed();
869
-        $this->_set_success_message(
870
-            esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
871
-        );
872
-        //do action in case a plugin wants to do something with the data submitted in step 1.
873
-        //passes EE_Single_Page_Checkout, and it's posted data
874
-        do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
875
-        return true;
876
-    }
877
-
878
-
879
-    /**
880
-     *    _process_registrations
881
-     *
882
-     * @param EE_Registration[] $registrations
883
-     * @param array             $valid_data
884
-     * @return bool|int
885
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
886
-     * @throws EE_Error
887
-     * @throws InvalidArgumentException
888
-     * @throws ReflectionException
889
-     * @throws RuntimeException
890
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
891
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
892
-     */
893
-    private function _process_registrations($registrations = array(), $valid_data = array())
894
-    {
895
-        // load resources and set some defaults
896
-        EE_Registry::instance()->load_model('Attendee');
897
-        // holder for primary registrant attendee object
898
-        $this->checkout->primary_attendee_obj = null;
899
-        // array for tracking reg form data for the primary registrant
900
-        $primary_registrant = array(
901
-            'line_item_id' => null,
902
-        );
903
-        $copy_primary       = false;
904
-        // reg form sections that do not contain inputs
905
-        $non_input_form_sections = array(
906
-            'primary_registrant',
907
-            'additional_attendee_reg_info',
908
-            'spco_copy_attendee_chk',
909
-        );
910
-        // attendee counter
911
-        $att_nmbr = 0;
912
-        // grab the saved registrations from the transaction
913
-        foreach ($registrations as $registration) {
914
-            // verify EE_Registration object
915
-            if (! $registration instanceof EE_Registration) {
916
-                EE_Error::add_error(
917
-                    esc_html__(
918
-                        'An invalid Registration object was discovered when attempting to process your registration information.',
919
-                        'event_espresso'
920
-                    ),
921
-                    __FILE__,
922
-                    __FUNCTION__,
923
-                    __LINE__
924
-                );
925
-                return false;
926
-            }
927
-            /** @var string $reg_url_link */
928
-            $reg_url_link = $registration->reg_url_link();
929
-            // reg_url_link exists ?
930
-            if (! empty($reg_url_link)) {
931
-                // should this registration be processed during this visit ?
932
-                if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
933
-                    // if NOT revisiting, then let's save the registration now,
934
-                    // so that we have a REG_ID to use when generating other objects
935
-                    if (! $this->checkout->revisit) {
936
-                        $registration->save();
937
-                    }
938
-                    /**
939
-                     * This allows plugins to trigger a fail on processing of a
940
-                     * registration for any conditions they may have for it to pass.
941
-                     *
942
-                     * @var bool   if true is returned by the plugin then the
943
-                     *            registration processing is halted.
944
-                     */
945
-                    if (apply_filters(
946
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
947
-                        false,
948
-                        $att_nmbr,
949
-                        $registration,
950
-                        $registrations,
951
-                        $valid_data,
952
-                        $this
953
-                    )) {
954
-                        return false;
955
-                    }
956
-
957
-                    // Houston, we have a registration!
958
-                    $att_nmbr++;
959
-                    $this->_attendee_data[$reg_url_link] = array();
960
-                    // grab any existing related answer objects
961
-                    $this->_registration_answers = $registration->answers();
962
-                    // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
963
-                    if (isset($valid_data[$reg_url_link])) {
964
-                        // do we need to copy basic info from primary attendee ?
965
-                        $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
966
-                                        && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
967
-                            ? true
968
-                            : false;
969
-                        // filter form input data for this registration
970
-                        $valid_data[$reg_url_link] = (array)apply_filters(
971
-                            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
972
-                            $valid_data[$reg_url_link]
973
-                        );
974
-                        if (isset($valid_data['primary_attendee'])) {
975
-                            $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
976
-                                ? $valid_data['primary_attendee']
977
-                                : false;
978
-                            unset($valid_data['primary_attendee']);
979
-                        }
980
-                        // now loop through our array of valid post data && process attendee reg forms
981
-                        foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
982
-                            if (! in_array($form_section, $non_input_form_sections)) {
983
-                                foreach ($form_inputs as $form_input => $input_value) {
984
-                                    // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
985
-                                    // check for critical inputs
986
-                                    if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
987
-                                        $form_input,
988
-                                        $input_value
989
-                                    )
990
-                                    ) {
991
-                                        return false;
992
-                                    }
993
-                                    // store a bit of data about the primary attendee
994
-                                    if ($att_nmbr === 1
995
-                                        && ! empty($input_value)
996
-                                        && $reg_url_link === $primary_registrant['line_item_id']
997
-                                    ) {
998
-                                        $primary_registrant[$form_input] = $input_value;
999
-                                    } elseif ($copy_primary
1000
-                                        && $input_value === null
1001
-                                        && isset($primary_registrant[$form_input])
1002
-                                    ) {
1003
-                                        $input_value = $primary_registrant[$form_input];
1004
-                                    }
1005
-                                    // now attempt to save the input data
1006
-                                    if (! $this->_save_registration_form_input(
1007
-                                        $registration,
1008
-                                        $form_input,
1009
-                                        $input_value
1010
-                                    )
1011
-                                    ) {
1012
-                                        EE_Error::add_error(
1013
-                                            sprintf(
1014
-                                                esc_html__(
1015
-                                                    'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
1016
-                                                    'event_espresso'
1017
-                                                ),
1018
-                                                $form_input,
1019
-                                                $input_value
1020
-                                            ),
1021
-                                            __FILE__,
1022
-                                            __FUNCTION__,
1023
-                                            __LINE__
1024
-                                        );
1025
-                                        return false;
1026
-                                    }
1027
-                                }
1028
-                            }
1029
-                        }  // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs )
1030
-                    }
1031
-                    //EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
1032
-                    // this registration does not require additional attendee information ?
1033
-                    if ($copy_primary
1034
-                        && $att_nmbr > 1
1035
-                        && $this->checkout->primary_attendee_obj instanceof EE_Attendee
1036
-                    ) {
1037
-                        // just copy the primary registrant
1038
-                        $attendee = $this->checkout->primary_attendee_obj;
1039
-                    } else {
1040
-                        // ensure critical details are set for additional attendees
1041
-                        $this->_attendee_data[$reg_url_link] = $att_nmbr > 1
1042
-                            ? $this->_copy_critical_attendee_details_from_primary_registrant(
1043
-                                $this->_attendee_data[$reg_url_link]
1044
-                            )
1045
-                            : $this->_attendee_data[$reg_url_link];
1046
-                        // execute create attendee command (which may return an existing attendee)
1047
-                        $attendee = EE_Registry::instance()->BUS->execute(
1048
-                            new CreateAttendeeCommand(
1049
-                                $this->_attendee_data[$reg_url_link],
1050
-                                $registration
1051
-                            )
1052
-                        );
1053
-                        // who's #1 ?
1054
-                        if ($att_nmbr === 1) {
1055
-                            $this->checkout->primary_attendee_obj = $attendee;
1056
-                        }
1057
-                    }
1058
-                    // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1059
-                    // add relation to registration, set attendee ID, and cache attendee
1060
-                    $this->_associate_attendee_with_registration($registration, $attendee);
1061
-                    // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1062
-                    if (! $registration->attendee() instanceof EE_Attendee) {
1063
-                        EE_Error::add_error(
1064
-                            sprintf(
1065
-                                esc_html__(
1066
-                                    'Registration %s has an invalid or missing Attendee object.',
1067
-                                    'event_espresso'
1068
-                                ),
1069
-                                $reg_url_link
1070
-                            ),
1071
-                            __FILE__,
1072
-                            __FUNCTION__,
1073
-                            __LINE__
1074
-                        );
1075
-                        return false;
1076
-                    }
1077
-                    /** @type EE_Registration_Processor $registration_processor */
1078
-                    $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1079
-                    // at this point, we should have enough details about the registrant to consider the registration
1080
-                    // NOT incomplete
1081
-                    $registration_processor->toggle_incomplete_registration_status_to_default(
1082
-                        $registration,
1083
-                        false,
1084
-                        new Context(
1085
-                            'spco_reg_step_attendee_information_process_registrations',
1086
-                            esc_html__(
1087
-                                'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.',
1088
-                                'event_espresso'
1089
-                            )
1090
-                        )
1091
-                    );
1092
-                    // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to
1093
-                    // abandoned
1094
-                    $this->checkout->transaction->toggle_failed_transaction_status();
1095
-                    // if we've gotten this far, then let's save what we have
1096
-                    $registration->save();
1097
-                    // add relation between TXN and registration
1098
-                    $this->_associate_registration_with_transaction($registration);
1099
-                }
1100
-            } else {
1101
-                EE_Error::add_error(
1102
-                    esc_html__(
1103
-                        'An invalid or missing line item ID was encountered while attempting to process the registration form.',
1104
-                        'event_espresso'
1105
-                    ),
1106
-                    __FILE__,
1107
-                    __FUNCTION__,
1108
-                    __LINE__
1109
-                );
1110
-                // remove malformed data
1111
-                unset($valid_data[$reg_url_link]);
1112
-                return false;
1113
-            }
1114
-
1115
-        } // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
1116
-        return $att_nmbr;
1117
-    }
1118
-
1119
-
1120
-    /**
1121
-     *    _save_registration_form_input
1122
-     *
1123
-     * @param EE_Registration $registration
1124
-     * @param string          $form_input
1125
-     * @param string          $input_value
1126
-     * @return bool
1127
-     * @throws EE_Error
1128
-     * @throws InvalidArgumentException
1129
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1130
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1131
-     */
1132
-    private function _save_registration_form_input(
1133
-        EE_Registration $registration,
1134
-        $form_input = '',
1135
-        $input_value = ''
1136
-    ) {
1137
-        // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 );
1138
-        // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
1139
-        // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1140
-        // allow for plugins to hook in and do their own processing of the form input.
1141
-        // For plugins to bypass normal processing here, they just need to return a boolean value.
1142
-        if (apply_filters(
1143
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1144
-            false,
1145
-            $registration,
1146
-            $form_input,
1147
-            $input_value,
1148
-            $this
1149
-        )) {
1150
-            return true;
1151
-        }
1152
-        /*
387
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
388
+		return apply_filters(
389
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
390
+			$question_group_reg_form,
391
+			$registration,
392
+			$question_group,
393
+			$this
394
+		);
395
+	}
396
+
397
+
398
+	/**
399
+	 * @access public
400
+	 * @param EE_Question_Group $question_group
401
+	 * @return    EE_Form_Section_HTML
402
+	 */
403
+	private function _question_group_header(EE_Question_Group $question_group)
404
+	{
405
+		$html = '';
406
+		// group_name
407
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
408
+			if ($this->checkout->admin_request) {
409
+				$html .= EEH_HTML::br();
410
+				$html .= EEH_HTML::h3(
411
+					$question_group->name(),
412
+					'',
413
+					'ee-reg-form-qstn-grp-title title',
414
+					'font-size: 1.3em; padding-left:0;'
415
+				);
416
+			} else {
417
+				$html .= EEH_HTML::h4(
418
+					$question_group->name(),
419
+					'',
420
+					'ee-reg-form-qstn-grp-title section-title'
421
+				);
422
+			}
423
+		}
424
+		// group_desc
425
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
426
+			$html .= EEH_HTML::p(
427
+				$question_group->desc(),
428
+				'',
429
+				$this->checkout->admin_request
430
+					? 'ee-reg-form-qstn-grp-desc-pg'
431
+					: 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text'
432
+			);
433
+		}
434
+		return new EE_Form_Section_HTML($html);
435
+	}
436
+
437
+
438
+	/**
439
+	 * @access public
440
+	 * @return    EE_Form_Section_Proper
441
+	 * @throws \EE_Error
442
+	 */
443
+	private function _copy_attendee_info_form()
444
+	{
445
+		// array of params to pass to parent constructor
446
+		return new EE_Form_Section_Proper(
447
+			array(
448
+				'subsections'     => $this->_copy_attendee_info_inputs(),
449
+				'layout_strategy' => new EE_Template_Layout(
450
+					array(
451
+						'layout_template_file'     => SPCO_REG_STEPS_PATH
452
+													  . $this->_slug
453
+													  . DS
454
+													  . 'copy_attendee_info.template.php',
455
+						'begin_template_file'      => null,
456
+						'input_template_file'      => null,
457
+						'subsection_template_file' => null,
458
+						'end_template_file'        => null,
459
+					)
460
+				),
461
+			)
462
+		);
463
+	}
464
+
465
+
466
+	/**
467
+	 * _auto_copy_attendee_info
468
+	 *
469
+	 * @access public
470
+	 * @return EE_Form_Section_HTML
471
+	 */
472
+	private function _auto_copy_attendee_info()
473
+	{
474
+		return new EE_Form_Section_HTML(
475
+			EEH_Template::locate_template(
476
+				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
477
+				apply_filters(
478
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
479
+					array()
480
+				),
481
+				true,
482
+				true
483
+			)
484
+		);
485
+	}
486
+
487
+
488
+	/**
489
+	 * _copy_attendee_info_inputs
490
+	 *
491
+	 * @access public
492
+	 * @return array
493
+	 * @throws \EE_Error
494
+	 */
495
+	private function _copy_attendee_info_inputs()
496
+	{
497
+		$copy_attendee_info_inputs = array();
498
+		$prev_ticket               = null;
499
+		// grab the saved registrations from the transaction
500
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
501
+		foreach ($registrations as $registration) {
502
+			// for all  attendees other than the primary attendee
503
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
504
+				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
505
+				if ($registration->ticket()->ID() !== $prev_ticket) {
506
+					$item_name = $registration->ticket()->name();
507
+					$item_name .= $registration->ticket()->description() !== ''
508
+						? ' - ' . $registration->ticket()->description()
509
+						: '';
510
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']'] =
511
+						new EE_Form_Section_HTML(
512
+							'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
513
+						);
514
+					$prev_ticket = $registration->ticket()->ID();
515
+				}
516
+
517
+				$copy_attendee_info_inputs['spco_copy_attendee_chk[' . $registration->ID() . ']'] =
518
+					new EE_Checkbox_Multi_Input(
519
+						array(
520
+							$registration->ID() => sprintf(
521
+								esc_html__('Attendee #%s', 'event_espresso'),
522
+								$registration->count()
523
+							),
524
+						),
525
+						array(
526
+							'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
527
+							'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
528
+							'display_html_label_text' => false,
529
+						)
530
+					);
531
+			}
532
+		}
533
+		return $copy_attendee_info_inputs;
534
+	}
535
+
536
+
537
+	/**
538
+	 * _additional_primary_registrant_inputs
539
+	 *
540
+	 * @access public
541
+	 * @param EE_Registration $registration
542
+	 * @return    EE_Form_Input_Base
543
+	 * @throws \EE_Error
544
+	 */
545
+	private function _additional_primary_registrant_inputs(EE_Registration $registration)
546
+	{
547
+		// generate hidden input
548
+		return new EE_Hidden_Input(
549
+			array(
550
+				'html_id' => 'primary_registrant',
551
+				'default' => $registration->reg_url_link(),
552
+			)
553
+		);
554
+	}
555
+
556
+
557
+	/**
558
+	 * @access public
559
+	 * @param EE_Registration $registration
560
+	 * @param EE_Question     $question
561
+	 * @return EE_Form_Input_Base
562
+	 * @throws EE_Error
563
+	 * @throws InvalidArgumentException
564
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
565
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
566
+	 */
567
+	public function reg_form_question(EE_Registration $registration, EE_Question $question)
568
+	{
569
+
570
+		// if this question was for an attendee detail, then check for that answer
571
+		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
572
+			$registration,
573
+			$question->system_ID()
574
+		);
575
+		$answer       = $answer_value === null
576
+			? EEM_Answer::instance()->get_one(
577
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
578
+			)
579
+			: null;
580
+		// if NOT returning to edit an existing registration
581
+		// OR if this question is for an attendee property
582
+		// OR we still don't have an EE_Answer object
583
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
584
+			// create an EE_Answer object for storing everything in
585
+			$answer = EE_Answer::new_instance(array(
586
+				'QST_ID' => $question->ID(),
587
+				'REG_ID' => $registration->ID(),
588
+			));
589
+		}
590
+		// verify instance
591
+		if ($answer instanceof EE_Answer) {
592
+			if (! empty($answer_value)) {
593
+				$answer->set('ANS_value', $answer_value);
594
+			}
595
+			$answer->cache('Question', $question);
596
+			//remember system ID had a bug where sometimes it could be null
597
+			$answer_cache_id = $question->is_system_question()
598
+				? $question->system_ID() . '-' . $registration->reg_url_link()
599
+				: $question->ID() . '-' . $registration->reg_url_link();
600
+			$registration->cache('Answer', $answer, $answer_cache_id);
601
+		}
602
+		return $this->_generate_question_input($registration, $question, $answer);
603
+	}
604
+
605
+
606
+	/**
607
+	 * @param EE_Registration $registration
608
+	 * @param EE_Question     $question
609
+	 * @param                 mixed EE_Answer|NULL      $answer
610
+	 * @return EE_Form_Input_Base
611
+	 * @throws \EE_Error
612
+	 */
613
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer)
614
+	{
615
+		$identifier                             = $question->is_system_question()
616
+			? $question->system_ID()
617
+			: $question->ID();
618
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
619
+		add_filter(
620
+			'FHEE__EE_Question__generate_form_input__country_options',
621
+			array($this, 'use_cached_countries_for_form_input'),
622
+			10,
623
+			4
624
+		);
625
+		add_filter(
626
+			'FHEE__EE_Question__generate_form_input__state_options',
627
+			array($this, 'use_cached_states_for_form_input'),
628
+			10,
629
+			4
630
+		);
631
+		$input_constructor_args                  = array(
632
+			'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
633
+			'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
634
+			'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
635
+			'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
636
+			'html_label_class' => 'ee-reg-qstn',
637
+		);
638
+		$input_constructor_args['html_label_id'] .= '-lbl';
639
+		if ($answer instanceof EE_Answer && $answer->ID()) {
640
+			$input_constructor_args['html_name']     .= '[' . $answer->ID() . ']';
641
+			$input_constructor_args['html_id']       .= '-' . $answer->ID();
642
+			$input_constructor_args['html_label_id'] .= '-' . $answer->ID();
643
+		}
644
+		$form_input = $question->generate_form_input(
645
+			$registration,
646
+			$answer,
647
+			$input_constructor_args
648
+		);
649
+		remove_filter(
650
+			'FHEE__EE_Question__generate_form_input__country_options',
651
+			array($this, 'use_cached_countries_for_form_input')
652
+		);
653
+		remove_filter(
654
+			'FHEE__EE_Question__generate_form_input__state_options',
655
+			array($this, 'use_cached_states_for_form_input')
656
+		);
657
+		return $form_input;
658
+	}
659
+
660
+
661
+	/**
662
+	 * Gets the list of countries for the form input
663
+	 *
664
+	 * @param array|null       $countries_list
665
+	 * @param \EE_Question     $question
666
+	 * @param \EE_Registration $registration
667
+	 * @param \EE_Answer       $answer
668
+	 * @return array 2d keys are country IDs, values are their names
669
+	 * @throws EE_Error
670
+	 * @throws InvalidArgumentException
671
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
672
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
673
+	 */
674
+	public function use_cached_countries_for_form_input(
675
+		$countries_list,
676
+		\EE_Question $question = null,
677
+		\EE_Registration $registration = null,
678
+		\EE_Answer $answer = null
679
+	) {
680
+		$country_options = array('' => '');
681
+		// get possibly cached list of countries
682
+		$countries = $this->checkout->action === 'process_reg_step'
683
+			? EEM_Country::instance()->get_all_countries()
684
+			: EEM_Country::instance()->get_all_active_countries();
685
+		if (! empty($countries)) {
686
+			foreach ($countries as $country) {
687
+				if ($country instanceof EE_Country) {
688
+					$country_options[$country->ID()] = $country->name();
689
+				}
690
+			}
691
+		}
692
+		if ($question instanceof EE_Question
693
+			&& $registration instanceof EE_Registration) {
694
+			$answer = EEM_Answer::instance()->get_one(
695
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
696
+			);
697
+		} else {
698
+			$answer = EE_Answer::new_instance();
699
+		}
700
+		$country_options = apply_filters(
701
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
702
+			$country_options,
703
+			$this,
704
+			$registration,
705
+			$question,
706
+			$answer
707
+		);
708
+		return $country_options;
709
+	}
710
+
711
+
712
+	/**
713
+	 * Gets the list of states for the form input
714
+	 *
715
+	 * @param array|null       $states_list
716
+	 * @param \EE_Question     $question
717
+	 * @param \EE_Registration $registration
718
+	 * @param \EE_Answer       $answer
719
+	 * @return array 2d keys are state IDs, values are their names
720
+	 * @throws EE_Error
721
+	 * @throws InvalidArgumentException
722
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
723
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
724
+	 */
725
+	public function use_cached_states_for_form_input(
726
+		$states_list,
727
+		\EE_Question $question = null,
728
+		\EE_Registration $registration = null,
729
+		\EE_Answer $answer = null
730
+	) {
731
+		$state_options = array('' => array('' => ''));
732
+		$states        = $this->checkout->action === 'process_reg_step'
733
+			? EEM_State::instance()->get_all_states()
734
+			: EEM_State::instance()->get_all_active_states();
735
+		if (! empty($states)) {
736
+			foreach ($states as $state) {
737
+				if ($state instanceof EE_State) {
738
+					$state_options[$state->country()->name()][$state->ID()] = $state->name();
739
+				}
740
+			}
741
+		}
742
+		$state_options = apply_filters(
743
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
744
+			$state_options,
745
+			$this,
746
+			$registration,
747
+			$question,
748
+			$answer
749
+		);
750
+		return $state_options;
751
+	}
752
+
753
+
754
+
755
+
756
+
757
+
758
+	/********************************************************************************************************/
759
+	/****************************************  PROCESS REG STEP  ****************************************/
760
+	/********************************************************************************************************/
761
+	/**
762
+	 * @return bool
763
+	 * @throws EE_Error
764
+	 * @throws InvalidArgumentException
765
+	 * @throws ReflectionException
766
+	 * @throws RuntimeException
767
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
768
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
769
+	 */
770
+	public function process_reg_step()
771
+	{
772
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
773
+		// grab validated data from form
774
+		$valid_data = $this->checkout->current_step->valid_data();
775
+		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
776
+		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
777
+		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
778
+		if (empty($valid_data)) {
779
+			EE_Error::add_error(
780
+				esc_html__('No valid question responses were received.', 'event_espresso'),
781
+				__FILE__,
782
+				__FUNCTION__,
783
+				__LINE__
784
+			);
785
+			return false;
786
+		}
787
+		if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
788
+			EE_Error::add_error(
789
+				esc_html__(
790
+					'A valid transaction could not be initiated for processing your registrations.',
791
+					'event_espresso'
792
+				),
793
+				__FILE__,
794
+				__FUNCTION__,
795
+				__LINE__
796
+			);
797
+			return false;
798
+		}
799
+		// get cached registrations
800
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
801
+		// verify we got the goods
802
+		if (empty($registrations)) {
803
+			//combine the old translated string with a new one, in order to not break translations
804
+
805
+			// @codingStandardsIgnoreStart
806
+			$error_message = esc_html__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' )
807
+							 . sprintf(
808
+								 esc_html__('%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', 'event_espresso'),
809
+								 '<a href="'
810
+								 . apply_filters(
811
+									 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__process_reg_step__no_regs_link_to_event_list',
812
+									 get_post_type_archive_link('espresso_events')
813
+								 )
814
+								 . '" >',
815
+								 '</a>',
816
+								 '<br />'
817
+							 );
818
+			// @codingStandardsIgnoreEnd
819
+			EE_Error::add_error(
820
+				$error_message,
821
+				__FILE__,
822
+				__FUNCTION__,
823
+				__LINE__
824
+			);
825
+			return false;
826
+		}
827
+		// extract attendee info from form data and save to model objects
828
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
829
+		// if first pass thru SPCO,
830
+		// then let's check processed registrations against the total number of tickets in the cart
831
+		if ($registrations_processed === false) {
832
+			// but return immediately if the previous step exited early due to errors
833
+			return false;
834
+		} elseif (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
835
+			// generate a correctly translated string for all possible singular/plural combinations
836
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
837
+				$error_msg = sprintf(
838
+					esc_html__(
839
+						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
840
+						'event_espresso'
841
+					),
842
+					$this->checkout->total_ticket_count,
843
+					$registrations_processed
844
+				);
845
+			} elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
846
+				$error_msg = sprintf(
847
+					esc_html__(
848
+						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
849
+						'event_espresso'
850
+					),
851
+					$this->checkout->total_ticket_count,
852
+					$registrations_processed
853
+				);
854
+			} else {
855
+				$error_msg = sprintf(
856
+					esc_html__(
857
+						'There was a total of %1$d tickets in the Event Queue, but %2$ds registrations were processed',
858
+						'event_espresso'
859
+					),
860
+					$this->checkout->total_ticket_count,
861
+					$registrations_processed
862
+				);
863
+			}
864
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
865
+			return false;
866
+		}
867
+		// mark this reg step as completed
868
+		$this->set_completed();
869
+		$this->_set_success_message(
870
+			esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
871
+		);
872
+		//do action in case a plugin wants to do something with the data submitted in step 1.
873
+		//passes EE_Single_Page_Checkout, and it's posted data
874
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
875
+		return true;
876
+	}
877
+
878
+
879
+	/**
880
+	 *    _process_registrations
881
+	 *
882
+	 * @param EE_Registration[] $registrations
883
+	 * @param array             $valid_data
884
+	 * @return bool|int
885
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
886
+	 * @throws EE_Error
887
+	 * @throws InvalidArgumentException
888
+	 * @throws ReflectionException
889
+	 * @throws RuntimeException
890
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
891
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
892
+	 */
893
+	private function _process_registrations($registrations = array(), $valid_data = array())
894
+	{
895
+		// load resources and set some defaults
896
+		EE_Registry::instance()->load_model('Attendee');
897
+		// holder for primary registrant attendee object
898
+		$this->checkout->primary_attendee_obj = null;
899
+		// array for tracking reg form data for the primary registrant
900
+		$primary_registrant = array(
901
+			'line_item_id' => null,
902
+		);
903
+		$copy_primary       = false;
904
+		// reg form sections that do not contain inputs
905
+		$non_input_form_sections = array(
906
+			'primary_registrant',
907
+			'additional_attendee_reg_info',
908
+			'spco_copy_attendee_chk',
909
+		);
910
+		// attendee counter
911
+		$att_nmbr = 0;
912
+		// grab the saved registrations from the transaction
913
+		foreach ($registrations as $registration) {
914
+			// verify EE_Registration object
915
+			if (! $registration instanceof EE_Registration) {
916
+				EE_Error::add_error(
917
+					esc_html__(
918
+						'An invalid Registration object was discovered when attempting to process your registration information.',
919
+						'event_espresso'
920
+					),
921
+					__FILE__,
922
+					__FUNCTION__,
923
+					__LINE__
924
+				);
925
+				return false;
926
+			}
927
+			/** @var string $reg_url_link */
928
+			$reg_url_link = $registration->reg_url_link();
929
+			// reg_url_link exists ?
930
+			if (! empty($reg_url_link)) {
931
+				// should this registration be processed during this visit ?
932
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
933
+					// if NOT revisiting, then let's save the registration now,
934
+					// so that we have a REG_ID to use when generating other objects
935
+					if (! $this->checkout->revisit) {
936
+						$registration->save();
937
+					}
938
+					/**
939
+					 * This allows plugins to trigger a fail on processing of a
940
+					 * registration for any conditions they may have for it to pass.
941
+					 *
942
+					 * @var bool   if true is returned by the plugin then the
943
+					 *            registration processing is halted.
944
+					 */
945
+					if (apply_filters(
946
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
947
+						false,
948
+						$att_nmbr,
949
+						$registration,
950
+						$registrations,
951
+						$valid_data,
952
+						$this
953
+					)) {
954
+						return false;
955
+					}
956
+
957
+					// Houston, we have a registration!
958
+					$att_nmbr++;
959
+					$this->_attendee_data[$reg_url_link] = array();
960
+					// grab any existing related answer objects
961
+					$this->_registration_answers = $registration->answers();
962
+					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
963
+					if (isset($valid_data[$reg_url_link])) {
964
+						// do we need to copy basic info from primary attendee ?
965
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
966
+										&& absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
967
+							? true
968
+							: false;
969
+						// filter form input data for this registration
970
+						$valid_data[$reg_url_link] = (array)apply_filters(
971
+							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
972
+							$valid_data[$reg_url_link]
973
+						);
974
+						if (isset($valid_data['primary_attendee'])) {
975
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
976
+								? $valid_data['primary_attendee']
977
+								: false;
978
+							unset($valid_data['primary_attendee']);
979
+						}
980
+						// now loop through our array of valid post data && process attendee reg forms
981
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
982
+							if (! in_array($form_section, $non_input_form_sections)) {
983
+								foreach ($form_inputs as $form_input => $input_value) {
984
+									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
985
+									// check for critical inputs
986
+									if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
987
+										$form_input,
988
+										$input_value
989
+									)
990
+									) {
991
+										return false;
992
+									}
993
+									// store a bit of data about the primary attendee
994
+									if ($att_nmbr === 1
995
+										&& ! empty($input_value)
996
+										&& $reg_url_link === $primary_registrant['line_item_id']
997
+									) {
998
+										$primary_registrant[$form_input] = $input_value;
999
+									} elseif ($copy_primary
1000
+										&& $input_value === null
1001
+										&& isset($primary_registrant[$form_input])
1002
+									) {
1003
+										$input_value = $primary_registrant[$form_input];
1004
+									}
1005
+									// now attempt to save the input data
1006
+									if (! $this->_save_registration_form_input(
1007
+										$registration,
1008
+										$form_input,
1009
+										$input_value
1010
+									)
1011
+									) {
1012
+										EE_Error::add_error(
1013
+											sprintf(
1014
+												esc_html__(
1015
+													'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
1016
+													'event_espresso'
1017
+												),
1018
+												$form_input,
1019
+												$input_value
1020
+											),
1021
+											__FILE__,
1022
+											__FUNCTION__,
1023
+											__LINE__
1024
+										);
1025
+										return false;
1026
+									}
1027
+								}
1028
+							}
1029
+						}  // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs )
1030
+					}
1031
+					//EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ );
1032
+					// this registration does not require additional attendee information ?
1033
+					if ($copy_primary
1034
+						&& $att_nmbr > 1
1035
+						&& $this->checkout->primary_attendee_obj instanceof EE_Attendee
1036
+					) {
1037
+						// just copy the primary registrant
1038
+						$attendee = $this->checkout->primary_attendee_obj;
1039
+					} else {
1040
+						// ensure critical details are set for additional attendees
1041
+						$this->_attendee_data[$reg_url_link] = $att_nmbr > 1
1042
+							? $this->_copy_critical_attendee_details_from_primary_registrant(
1043
+								$this->_attendee_data[$reg_url_link]
1044
+							)
1045
+							: $this->_attendee_data[$reg_url_link];
1046
+						// execute create attendee command (which may return an existing attendee)
1047
+						$attendee = EE_Registry::instance()->BUS->execute(
1048
+							new CreateAttendeeCommand(
1049
+								$this->_attendee_data[$reg_url_link],
1050
+								$registration
1051
+							)
1052
+						);
1053
+						// who's #1 ?
1054
+						if ($att_nmbr === 1) {
1055
+							$this->checkout->primary_attendee_obj = $attendee;
1056
+						}
1057
+					}
1058
+					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1059
+					// add relation to registration, set attendee ID, and cache attendee
1060
+					$this->_associate_attendee_with_registration($registration, $attendee);
1061
+					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1062
+					if (! $registration->attendee() instanceof EE_Attendee) {
1063
+						EE_Error::add_error(
1064
+							sprintf(
1065
+								esc_html__(
1066
+									'Registration %s has an invalid or missing Attendee object.',
1067
+									'event_espresso'
1068
+								),
1069
+								$reg_url_link
1070
+							),
1071
+							__FILE__,
1072
+							__FUNCTION__,
1073
+							__LINE__
1074
+						);
1075
+						return false;
1076
+					}
1077
+					/** @type EE_Registration_Processor $registration_processor */
1078
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1079
+					// at this point, we should have enough details about the registrant to consider the registration
1080
+					// NOT incomplete
1081
+					$registration_processor->toggle_incomplete_registration_status_to_default(
1082
+						$registration,
1083
+						false,
1084
+						new Context(
1085
+							'spco_reg_step_attendee_information_process_registrations',
1086
+							esc_html__(
1087
+								'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.',
1088
+								'event_espresso'
1089
+							)
1090
+						)
1091
+					);
1092
+					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to
1093
+					// abandoned
1094
+					$this->checkout->transaction->toggle_failed_transaction_status();
1095
+					// if we've gotten this far, then let's save what we have
1096
+					$registration->save();
1097
+					// add relation between TXN and registration
1098
+					$this->_associate_registration_with_transaction($registration);
1099
+				}
1100
+			} else {
1101
+				EE_Error::add_error(
1102
+					esc_html__(
1103
+						'An invalid or missing line item ID was encountered while attempting to process the registration form.',
1104
+						'event_espresso'
1105
+					),
1106
+					__FILE__,
1107
+					__FUNCTION__,
1108
+					__LINE__
1109
+				);
1110
+				// remove malformed data
1111
+				unset($valid_data[$reg_url_link]);
1112
+				return false;
1113
+			}
1114
+
1115
+		} // end of foreach ( $this->checkout->transaction->registrations()  as $registration )
1116
+		return $att_nmbr;
1117
+	}
1118
+
1119
+
1120
+	/**
1121
+	 *    _save_registration_form_input
1122
+	 *
1123
+	 * @param EE_Registration $registration
1124
+	 * @param string          $form_input
1125
+	 * @param string          $input_value
1126
+	 * @return bool
1127
+	 * @throws EE_Error
1128
+	 * @throws InvalidArgumentException
1129
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1130
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1131
+	 */
1132
+	private function _save_registration_form_input(
1133
+		EE_Registration $registration,
1134
+		$form_input = '',
1135
+		$input_value = ''
1136
+	) {
1137
+		// \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 );
1138
+		// \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ );
1139
+		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1140
+		// allow for plugins to hook in and do their own processing of the form input.
1141
+		// For plugins to bypass normal processing here, they just need to return a boolean value.
1142
+		if (apply_filters(
1143
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1144
+			false,
1145
+			$registration,
1146
+			$form_input,
1147
+			$input_value,
1148
+			$this
1149
+		)) {
1150
+			return true;
1151
+		}
1152
+		/*
1153 1153
          * $answer_cache_id is the key used to find the EE_Answer we want
1154 1154
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
1155 1155
          */
1156
-        $answer_cache_id = $this->checkout->reg_url_link
1157
-            ? $form_input . '-' . $registration->reg_url_link()
1158
-            : $form_input;
1159
-        $answer_is_obj   = isset($this->_registration_answers[$answer_cache_id])
1160
-                           && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1161
-            ? true
1162
-            : false;
1163
-        //rename form_inputs if they are EE_Attendee properties
1164
-        switch ((string) $form_input) {
1165
-            case 'state':
1166
-            case 'STA_ID':
1167
-                $attendee_property = true;
1168
-                $form_input        = 'STA_ID';
1169
-                break;
1170
-
1171
-            case 'country':
1172
-            case 'CNT_ISO':
1173
-                $attendee_property = true;
1174
-                $form_input        = 'CNT_ISO';
1175
-                break;
1176
-
1177
-            default:
1178
-                $ATT_input = 'ATT_' . $form_input;
1179
-                //EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1180
-                $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1181
-                $form_input        = $attendee_property ? 'ATT_' . $form_input : $form_input;
1182
-        }
1183
-        // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1184
-        // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1185
-        // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1186
-        // if this form input has a corresponding attendee property
1187
-        if ($attendee_property) {
1188
-            $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1189
-            if ($answer_is_obj) {
1190
-                // and delete the corresponding answer since we won't be storing this data in that object
1191
-                $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1192
-                $this->_registration_answers[$answer_cache_id]->delete_permanently();
1193
-            }
1194
-            return true;
1195
-        } elseif ($answer_is_obj) {
1196
-            // save this data to the answer object
1197
-            $this->_registration_answers[$answer_cache_id]->set_value($input_value);
1198
-            $result = $this->_registration_answers[$answer_cache_id]->save();
1199
-            return $result !== false ? true : false;
1200
-        } else {
1201
-            foreach ($this->_registration_answers as $answer) {
1202
-                if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1203
-                    $answer->set_value($input_value);
1204
-                    $result = $answer->save();
1205
-                    return $result !== false ? true : false;
1206
-                }
1207
-            }
1208
-        }
1209
-        return false;
1210
-    }
1211
-
1212
-
1213
-    /**
1214
-     *    _verify_critical_attendee_details_are_set
1215
-     *
1216
-     * @param string $form_input
1217
-     * @param string $input_value
1218
-     * @return boolean
1219
-     */
1220
-    private function _verify_critical_attendee_details_are_set_and_validate_email(
1221
-        $form_input = '',
1222
-        $input_value = ''
1223
-    ) {
1224
-        if (empty($input_value)) {
1225
-            // if the form input isn't marked as being required, then just return
1226
-            if (! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1227
-                return true;
1228
-            }
1229
-            switch ($form_input) {
1230
-                case 'fname':
1231
-                    EE_Error::add_error(
1232
-                        esc_html__('First Name is a required value.', 'event_espresso'),
1233
-                        __FILE__,
1234
-                        __FUNCTION__,
1235
-                        __LINE__
1236
-                    );
1237
-                    return false;
1238
-                    break;
1239
-                case 'lname':
1240
-                    EE_Error::add_error(
1241
-                        esc_html__('Last Name is a required value.', 'event_espresso'),
1242
-                        __FILE__,
1243
-                        __FUNCTION__,
1244
-                        __LINE__
1245
-                    );
1246
-                    return false;
1247
-                    break;
1248
-                case 'email':
1249
-                    EE_Error::add_error(
1250
-                        esc_html__('Please enter a valid email address.', 'event_espresso'),
1251
-                        __FILE__,
1252
-                        __FUNCTION__,
1253
-                        __LINE__
1254
-                    );
1255
-                    return false;
1256
-                    break;
1257
-            }
1258
-        }
1259
-        return true;
1260
-    }
1261
-
1262
-
1263
-    /**
1264
-     *    _associate_attendee_with_registration
1265
-     *
1266
-     * @param EE_Registration $registration
1267
-     * @param EE_Attendee     $attendee
1268
-     * @return void
1269
-     * @throws EE_Error
1270
-     * @throws RuntimeException
1271
-     */
1272
-    private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee)
1273
-    {
1274
-        // add relation to attendee
1275
-        $registration->_add_relation_to($attendee, 'Attendee');
1276
-        $registration->set_attendee_id($attendee->ID());
1277
-        $registration->update_cache_after_object_save('Attendee', $attendee);
1278
-    }
1279
-
1280
-
1281
-    /**
1282
-     *    _associate_registration_with_transaction
1283
-     *
1284
-     * @param EE_Registration $registration
1285
-     * @return void
1286
-     * @throws \EE_Error
1287
-     */
1288
-    private function _associate_registration_with_transaction(EE_Registration $registration)
1289
-    {
1290
-        // add relation to registration
1291
-        $this->checkout->transaction->_add_relation_to($registration, 'Registration');
1292
-        $this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1293
-    }
1294
-
1295
-
1296
-    /**
1297
-     *    _copy_critical_attendee_details_from_primary_registrant
1298
-     *    ensures that all attendees at least have data for first name, last name, and email address
1299
-     *
1300
-     * @param array $attendee_data
1301
-     * @return array
1302
-     * @throws \EE_Error
1303
-     */
1304
-    private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array())
1305
-    {
1306
-        // bare minimum critical details include first name, last name, email address
1307
-        $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1308
-        // add address info to critical details?
1309
-        if (apply_filters(
1310
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1311
-            false
1312
-        )) {
1313
-            $address_details           = array(
1314
-                'ATT_address',
1315
-                'ATT_address2',
1316
-                'ATT_city',
1317
-                'STA_ID',
1318
-                'CNT_ISO',
1319
-                'ATT_zip',
1320
-                'ATT_phone',
1321
-            );
1322
-            $critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1323
-        }
1324
-        foreach ($critical_attendee_details as $critical_attendee_detail) {
1325
-            if (! isset($attendee_data[$critical_attendee_detail])
1326
-                || empty($attendee_data[$critical_attendee_detail])
1327
-            ) {
1328
-                $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1329
-                    $critical_attendee_detail
1330
-                );
1331
-            }
1332
-        }
1333
-        return $attendee_data;
1334
-    }
1335
-
1336
-
1337
-    /**
1338
-     *    update_reg_step
1339
-     *    this is the final step after a user  revisits the site to edit their attendee information
1340
-     *    this gets called AFTER the process_reg_step() method above
1341
-     *
1342
-     * @return bool
1343
-     * @throws EE_Error
1344
-     * @throws InvalidArgumentException
1345
-     * @throws ReflectionException
1346
-     * @throws RuntimeException
1347
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1348
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1349
-     */
1350
-    public function update_reg_step()
1351
-    {
1352
-        // save everything
1353
-        if ($this->process_reg_step()) {
1354
-            $this->checkout->redirect     = true;
1355
-            $this->checkout->redirect_url = add_query_arg(
1356
-                array(
1357
-                    'e_reg_url_link' => $this->checkout->reg_url_link,
1358
-                    'revisit'        => true,
1359
-                ),
1360
-                $this->checkout->thank_you_page_url
1361
-            );
1362
-            $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1363
-            return true;
1364
-        }
1365
-        return false;
1366
-    }
1156
+		$answer_cache_id = $this->checkout->reg_url_link
1157
+			? $form_input . '-' . $registration->reg_url_link()
1158
+			: $form_input;
1159
+		$answer_is_obj   = isset($this->_registration_answers[$answer_cache_id])
1160
+						   && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1161
+			? true
1162
+			: false;
1163
+		//rename form_inputs if they are EE_Attendee properties
1164
+		switch ((string) $form_input) {
1165
+			case 'state':
1166
+			case 'STA_ID':
1167
+				$attendee_property = true;
1168
+				$form_input        = 'STA_ID';
1169
+				break;
1170
+
1171
+			case 'country':
1172
+			case 'CNT_ISO':
1173
+				$attendee_property = true;
1174
+				$form_input        = 'CNT_ISO';
1175
+				break;
1176
+
1177
+			default:
1178
+				$ATT_input = 'ATT_' . $form_input;
1179
+				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1180
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1181
+				$form_input        = $attendee_property ? 'ATT_' . $form_input : $form_input;
1182
+		}
1183
+		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1184
+		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1185
+		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1186
+		// if this form input has a corresponding attendee property
1187
+		if ($attendee_property) {
1188
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1189
+			if ($answer_is_obj) {
1190
+				// and delete the corresponding answer since we won't be storing this data in that object
1191
+				$registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1192
+				$this->_registration_answers[$answer_cache_id]->delete_permanently();
1193
+			}
1194
+			return true;
1195
+		} elseif ($answer_is_obj) {
1196
+			// save this data to the answer object
1197
+			$this->_registration_answers[$answer_cache_id]->set_value($input_value);
1198
+			$result = $this->_registration_answers[$answer_cache_id]->save();
1199
+			return $result !== false ? true : false;
1200
+		} else {
1201
+			foreach ($this->_registration_answers as $answer) {
1202
+				if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1203
+					$answer->set_value($input_value);
1204
+					$result = $answer->save();
1205
+					return $result !== false ? true : false;
1206
+				}
1207
+			}
1208
+		}
1209
+		return false;
1210
+	}
1211
+
1212
+
1213
+	/**
1214
+	 *    _verify_critical_attendee_details_are_set
1215
+	 *
1216
+	 * @param string $form_input
1217
+	 * @param string $input_value
1218
+	 * @return boolean
1219
+	 */
1220
+	private function _verify_critical_attendee_details_are_set_and_validate_email(
1221
+		$form_input = '',
1222
+		$input_value = ''
1223
+	) {
1224
+		if (empty($input_value)) {
1225
+			// if the form input isn't marked as being required, then just return
1226
+			if (! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1227
+				return true;
1228
+			}
1229
+			switch ($form_input) {
1230
+				case 'fname':
1231
+					EE_Error::add_error(
1232
+						esc_html__('First Name is a required value.', 'event_espresso'),
1233
+						__FILE__,
1234
+						__FUNCTION__,
1235
+						__LINE__
1236
+					);
1237
+					return false;
1238
+					break;
1239
+				case 'lname':
1240
+					EE_Error::add_error(
1241
+						esc_html__('Last Name is a required value.', 'event_espresso'),
1242
+						__FILE__,
1243
+						__FUNCTION__,
1244
+						__LINE__
1245
+					);
1246
+					return false;
1247
+					break;
1248
+				case 'email':
1249
+					EE_Error::add_error(
1250
+						esc_html__('Please enter a valid email address.', 'event_espresso'),
1251
+						__FILE__,
1252
+						__FUNCTION__,
1253
+						__LINE__
1254
+					);
1255
+					return false;
1256
+					break;
1257
+			}
1258
+		}
1259
+		return true;
1260
+	}
1261
+
1262
+
1263
+	/**
1264
+	 *    _associate_attendee_with_registration
1265
+	 *
1266
+	 * @param EE_Registration $registration
1267
+	 * @param EE_Attendee     $attendee
1268
+	 * @return void
1269
+	 * @throws EE_Error
1270
+	 * @throws RuntimeException
1271
+	 */
1272
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee)
1273
+	{
1274
+		// add relation to attendee
1275
+		$registration->_add_relation_to($attendee, 'Attendee');
1276
+		$registration->set_attendee_id($attendee->ID());
1277
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1278
+	}
1279
+
1280
+
1281
+	/**
1282
+	 *    _associate_registration_with_transaction
1283
+	 *
1284
+	 * @param EE_Registration $registration
1285
+	 * @return void
1286
+	 * @throws \EE_Error
1287
+	 */
1288
+	private function _associate_registration_with_transaction(EE_Registration $registration)
1289
+	{
1290
+		// add relation to registration
1291
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1292
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1293
+	}
1294
+
1295
+
1296
+	/**
1297
+	 *    _copy_critical_attendee_details_from_primary_registrant
1298
+	 *    ensures that all attendees at least have data for first name, last name, and email address
1299
+	 *
1300
+	 * @param array $attendee_data
1301
+	 * @return array
1302
+	 * @throws \EE_Error
1303
+	 */
1304
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array())
1305
+	{
1306
+		// bare minimum critical details include first name, last name, email address
1307
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1308
+		// add address info to critical details?
1309
+		if (apply_filters(
1310
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1311
+			false
1312
+		)) {
1313
+			$address_details           = array(
1314
+				'ATT_address',
1315
+				'ATT_address2',
1316
+				'ATT_city',
1317
+				'STA_ID',
1318
+				'CNT_ISO',
1319
+				'ATT_zip',
1320
+				'ATT_phone',
1321
+			);
1322
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1323
+		}
1324
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1325
+			if (! isset($attendee_data[$critical_attendee_detail])
1326
+				|| empty($attendee_data[$critical_attendee_detail])
1327
+			) {
1328
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1329
+					$critical_attendee_detail
1330
+				);
1331
+			}
1332
+		}
1333
+		return $attendee_data;
1334
+	}
1335
+
1336
+
1337
+	/**
1338
+	 *    update_reg_step
1339
+	 *    this is the final step after a user  revisits the site to edit their attendee information
1340
+	 *    this gets called AFTER the process_reg_step() method above
1341
+	 *
1342
+	 * @return bool
1343
+	 * @throws EE_Error
1344
+	 * @throws InvalidArgumentException
1345
+	 * @throws ReflectionException
1346
+	 * @throws RuntimeException
1347
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
1348
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
1349
+	 */
1350
+	public function update_reg_step()
1351
+	{
1352
+		// save everything
1353
+		if ($this->process_reg_step()) {
1354
+			$this->checkout->redirect     = true;
1355
+			$this->checkout->redirect_url = add_query_arg(
1356
+				array(
1357
+					'e_reg_url_link' => $this->checkout->reg_url_link,
1358
+					'revisit'        => true,
1359
+				),
1360
+				$this->checkout->thank_you_page_url
1361
+			);
1362
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1363
+			return true;
1364
+		}
1365
+		return false;
1366
+	}
1367 1367
 }
Please login to merge, or discard this patch.
Spacing   +50 added lines, -51 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     {
49 49
         $this->_slug     = 'attendee_information';
50 50
         $this->_name     = esc_html__('Attendee Information', 'event_espresso');
51
-        $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
51
+        $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
52 52
         $this->checkout  = $checkout;
53 53
         $this->_reset_success_message();
54 54
         $this->set_instructions(
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 
60 60
     public function translate_js_strings()
61 61
     {
62
-        EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
62
+        EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
63 63
             ' is a required question.',
64 64
             'event_espresso'
65 65
         );
66
-        EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
66
+        EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
67 67
             ' is a required question. Please enter a value for at least one of the options.',
68 68
             'event_espresso'
69 69
         );
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
             'Please answer all required questions correctly before proceeding.',
72 72
             'event_espresso'
73 73
         );
74
-        EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
74
+        EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
75 75
             esc_html__(
76 76
                 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
77 77
                 'event_espresso'
78 78
             ),
79 79
             '<br/>'
80 80
         );
81
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
81
+        EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
82 82
             'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
83 83
             'event_espresso'
84 84
         );
85
-        EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
85
+        EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
86 86
             'You must enter a valid email address.',
87 87
             'event_espresso'
88 88
         );
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                     && $this->checkout->visit_allows_processing_of_this_registration($registration)
146 146
                 ) {
147 147
                     $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
148
-                    if (! $this->checkout->admin_request) {
148
+                    if ( ! $this->checkout->admin_request) {
149 149
                         $template_args['registrations'][$registration->reg_url_link()]    = $registration;
150 150
                         $template_args['ticket_count'][$registration->ticket()->ID()]     = isset(
151 151
                             $template_args['ticket_count'][$registration->ticket()->ID()]
@@ -194,8 +194,7 @@  discard block
 block discarded – undo
194 194
                 'html_id'         => $this->reg_form_name(),
195 195
                 'subsections'     => $subsections,
196 196
                 'layout_strategy' => $this->checkout->admin_request ?
197
-                    new EE_Div_Per_Section_Layout() :
198
-                    new EE_Template_Layout(
197
+                    new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
199 198
                         array(
200 199
                             'layout_template_file' => $this->_template, // layout_template
201 200
                             'template_args'        => $template_args,
@@ -238,7 +237,7 @@  discard block
 block discarded – undo
238 237
             if ($question_groups) {
239 238
                 // array of params to pass to parent constructor
240 239
                 $form_args = array(
241
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
240
+                    'html_id'         => 'ee-registration-'.$registration->reg_url_link(),
242 241
                     'html_class'      => 'ee-reg-form-attendee-dv',
243 242
                     'html_style'      => $this->checkout->admin_request
244 243
                         ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
@@ -294,7 +293,7 @@  discard block
 block discarded – undo
294 293
         // generate hidden input
295 294
         return new EE_Hidden_Input(
296 295
             array(
297
-                'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
296
+                'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(),
298 297
                 'default' => $additional_attendee_reg_info,
299 298
             )
300 299
         );
@@ -314,11 +313,11 @@  discard block
 block discarded – undo
314 313
     {
315 314
         // array of params to pass to parent constructor
316 315
         $form_args = array(
317
-            'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
316
+            'html_id'         => 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
318 317
             'html_class'      => $this->checkout->admin_request
319 318
                 ? 'form-table ee-reg-form-qstn-grp-dv'
320 319
                 : 'ee-reg-form-qstn-grp-dv',
321
-            'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
320
+            'html_label_id'   => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
322 321
             'subsections'     => array(
323 322
                 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group),
324 323
             ),
@@ -329,7 +328,7 @@  discard block
 block discarded – undo
329 328
         // where params
330 329
         $query_params = array('QST_deleted' => 0);
331 330
         // don't load admin only questions on the frontend
332
-        if (! $this->checkout->admin_request) {
331
+        if ( ! $this->checkout->admin_request) {
333 332
             $query_params['QST_admin_only'] = array('!=', true);
334 333
         }
335 334
         $questions = $question_group->get_many_related(
@@ -473,7 +472,7 @@  discard block
 block discarded – undo
473 472
     {
474 473
         return new EE_Form_Section_HTML(
475 474
             EEH_Template::locate_template(
476
-                SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
475
+                SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
477 476
                 apply_filters(
478 477
                     'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
479 478
                     array()
@@ -505,16 +504,16 @@  discard block
 block discarded – undo
505 504
                 if ($registration->ticket()->ID() !== $prev_ticket) {
506 505
                     $item_name = $registration->ticket()->name();
507 506
                     $item_name .= $registration->ticket()->description() !== ''
508
-                        ? ' - ' . $registration->ticket()->description()
507
+                        ? ' - '.$registration->ticket()->description()
509 508
                         : '';
510
-                    $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']'] =
509
+                    $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] =
511 510
                         new EE_Form_Section_HTML(
512
-                            '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
511
+                            '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
513 512
                         );
514 513
                     $prev_ticket = $registration->ticket()->ID();
515 514
                 }
516 515
 
517
-                $copy_attendee_info_inputs['spco_copy_attendee_chk[' . $registration->ID() . ']'] =
516
+                $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] =
518 517
                     new EE_Checkbox_Multi_Input(
519 518
                         array(
520 519
                             $registration->ID() => sprintf(
@@ -523,7 +522,7 @@  discard block
 block discarded – undo
523 522
                             ),
524 523
                         ),
525 524
                         array(
526
-                            'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
525
+                            'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
527 526
                             'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
528 527
                             'display_html_label_text' => false,
529 528
                         )
@@ -572,7 +571,7 @@  discard block
 block discarded – undo
572 571
             $registration,
573 572
             $question->system_ID()
574 573
         );
575
-        $answer       = $answer_value === null
574
+        $answer = $answer_value === null
576 575
             ? EEM_Answer::instance()->get_one(
577 576
                 array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
578 577
             )
@@ -589,14 +588,14 @@  discard block
 block discarded – undo
589 588
         }
590 589
         // verify instance
591 590
         if ($answer instanceof EE_Answer) {
592
-            if (! empty($answer_value)) {
591
+            if ( ! empty($answer_value)) {
593 592
                 $answer->set('ANS_value', $answer_value);
594 593
             }
595 594
             $answer->cache('Question', $question);
596 595
             //remember system ID had a bug where sometimes it could be null
597 596
             $answer_cache_id = $question->is_system_question()
598
-                ? $question->system_ID() . '-' . $registration->reg_url_link()
599
-                : $question->ID() . '-' . $registration->reg_url_link();
597
+                ? $question->system_ID().'-'.$registration->reg_url_link()
598
+                : $question->ID().'-'.$registration->reg_url_link();
600 599
             $registration->cache('Answer', $answer, $answer_cache_id);
601 600
         }
602 601
         return $this->_generate_question_input($registration, $question, $answer);
@@ -628,18 +627,18 @@  discard block
 block discarded – undo
628 627
             10,
629 628
             4
630 629
         );
631
-        $input_constructor_args                  = array(
632
-            'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
633
-            'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
634
-            'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
635
-            'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
630
+        $input_constructor_args = array(
631
+            'html_name'        => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
632
+            'html_id'          => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
633
+            'html_class'       => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
634
+            'html_label_id'    => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
636 635
             'html_label_class' => 'ee-reg-qstn',
637 636
         );
638 637
         $input_constructor_args['html_label_id'] .= '-lbl';
639 638
         if ($answer instanceof EE_Answer && $answer->ID()) {
640
-            $input_constructor_args['html_name']     .= '[' . $answer->ID() . ']';
641
-            $input_constructor_args['html_id']       .= '-' . $answer->ID();
642
-            $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
639
+            $input_constructor_args['html_name']     .= '['.$answer->ID().']';
640
+            $input_constructor_args['html_id']       .= '-'.$answer->ID();
641
+            $input_constructor_args['html_label_id'] .= '-'.$answer->ID();
643 642
         }
644 643
         $form_input = $question->generate_form_input(
645 644
             $registration,
@@ -682,7 +681,7 @@  discard block
 block discarded – undo
682 681
         $countries = $this->checkout->action === 'process_reg_step'
683 682
             ? EEM_Country::instance()->get_all_countries()
684 683
             : EEM_Country::instance()->get_all_active_countries();
685
-        if (! empty($countries)) {
684
+        if ( ! empty($countries)) {
686 685
             foreach ($countries as $country) {
687 686
                 if ($country instanceof EE_Country) {
688 687
                     $country_options[$country->ID()] = $country->name();
@@ -732,7 +731,7 @@  discard block
 block discarded – undo
732 731
         $states        = $this->checkout->action === 'process_reg_step'
733 732
             ? EEM_State::instance()->get_all_states()
734 733
             : EEM_State::instance()->get_all_active_states();
735
-        if (! empty($states)) {
734
+        if ( ! empty($states)) {
736 735
             foreach ($states as $state) {
737 736
                 if ($state instanceof EE_State) {
738 737
                     $state_options[$state->country()->name()][$state->ID()] = $state->name();
@@ -784,7 +783,7 @@  discard block
 block discarded – undo
784 783
             );
785 784
             return false;
786 785
         }
787
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
786
+        if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
788 787
             EE_Error::add_error(
789 788
                 esc_html__(
790 789
                     'A valid transaction could not be initiated for processing your registrations.',
@@ -803,7 +802,7 @@  discard block
 block discarded – undo
803 802
             //combine the old translated string with a new one, in order to not break translations
804 803
 
805 804
             // @codingStandardsIgnoreStart
806
-            $error_message = esc_html__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' )
805
+            $error_message = esc_html__('Your form data could not be applied to any valid registrations.', 'event_espresso')
807 806
                              . sprintf(
808 807
                                  esc_html__('%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', 'event_espresso'),
809 808
                                  '<a href="'
@@ -831,7 +830,7 @@  discard block
 block discarded – undo
831 830
         if ($registrations_processed === false) {
832 831
             // but return immediately if the previous step exited early due to errors
833 832
             return false;
834
-        } elseif (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
833
+        } elseif ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
835 834
             // generate a correctly translated string for all possible singular/plural combinations
836 835
             if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
837 836
                 $error_msg = sprintf(
@@ -912,7 +911,7 @@  discard block
 block discarded – undo
912 911
         // grab the saved registrations from the transaction
913 912
         foreach ($registrations as $registration) {
914 913
             // verify EE_Registration object
915
-            if (! $registration instanceof EE_Registration) {
914
+            if ( ! $registration instanceof EE_Registration) {
916 915
                 EE_Error::add_error(
917 916
                     esc_html__(
918 917
                         'An invalid Registration object was discovered when attempting to process your registration information.',
@@ -927,12 +926,12 @@  discard block
 block discarded – undo
927 926
             /** @var string $reg_url_link */
928 927
             $reg_url_link = $registration->reg_url_link();
929 928
             // reg_url_link exists ?
930
-            if (! empty($reg_url_link)) {
929
+            if ( ! empty($reg_url_link)) {
931 930
                 // should this registration be processed during this visit ?
932 931
                 if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
933 932
                     // if NOT revisiting, then let's save the registration now,
934 933
                     // so that we have a REG_ID to use when generating other objects
935
-                    if (! $this->checkout->revisit) {
934
+                    if ( ! $this->checkout->revisit) {
936 935
                         $registration->save();
937 936
                     }
938 937
                     /**
@@ -967,7 +966,7 @@  discard block
 block discarded – undo
967 966
                             ? true
968 967
                             : false;
969 968
                         // filter form input data for this registration
970
-                        $valid_data[$reg_url_link] = (array)apply_filters(
969
+                        $valid_data[$reg_url_link] = (array) apply_filters(
971 970
                             'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
972 971
                             $valid_data[$reg_url_link]
973 972
                         );
@@ -979,11 +978,11 @@  discard block
 block discarded – undo
979 978
                         }
980 979
                         // now loop through our array of valid post data && process attendee reg forms
981 980
                         foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
982
-                            if (! in_array($form_section, $non_input_form_sections)) {
981
+                            if ( ! in_array($form_section, $non_input_form_sections)) {
983 982
                                 foreach ($form_inputs as $form_input => $input_value) {
984 983
                                     // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
985 984
                                     // check for critical inputs
986
-                                    if (! $this->_verify_critical_attendee_details_are_set_and_validate_email(
985
+                                    if ( ! $this->_verify_critical_attendee_details_are_set_and_validate_email(
987 986
                                         $form_input,
988 987
                                         $input_value
989 988
                                     )
@@ -1003,7 +1002,7 @@  discard block
 block discarded – undo
1003 1002
                                         $input_value = $primary_registrant[$form_input];
1004 1003
                                     }
1005 1004
                                     // now attempt to save the input data
1006
-                                    if (! $this->_save_registration_form_input(
1005
+                                    if ( ! $this->_save_registration_form_input(
1007 1006
                                         $registration,
1008 1007
                                         $form_input,
1009 1008
                                         $input_value
@@ -1059,7 +1058,7 @@  discard block
 block discarded – undo
1059 1058
                     // add relation to registration, set attendee ID, and cache attendee
1060 1059
                     $this->_associate_attendee_with_registration($registration, $attendee);
1061 1060
                     // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1062
-                    if (! $registration->attendee() instanceof EE_Attendee) {
1061
+                    if ( ! $registration->attendee() instanceof EE_Attendee) {
1063 1062
                         EE_Error::add_error(
1064 1063
                             sprintf(
1065 1064
                                 esc_html__(
@@ -1154,7 +1153,7 @@  discard block
 block discarded – undo
1154 1153
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
1155 1154
          */
1156 1155
         $answer_cache_id = $this->checkout->reg_url_link
1157
-            ? $form_input . '-' . $registration->reg_url_link()
1156
+            ? $form_input.'-'.$registration->reg_url_link()
1158 1157
             : $form_input;
1159 1158
         $answer_is_obj   = isset($this->_registration_answers[$answer_cache_id])
1160 1159
                            && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
@@ -1175,10 +1174,10 @@  discard block
 block discarded – undo
1175 1174
                 break;
1176 1175
 
1177 1176
             default:
1178
-                $ATT_input = 'ATT_' . $form_input;
1177
+                $ATT_input = 'ATT_'.$form_input;
1179 1178
                 //EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1180 1179
                 $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1181
-                $form_input        = $attendee_property ? 'ATT_' . $form_input : $form_input;
1180
+                $form_input        = $attendee_property ? 'ATT_'.$form_input : $form_input;
1182 1181
         }
1183 1182
         // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1184 1183
         // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
@@ -1223,7 +1222,7 @@  discard block
 block discarded – undo
1223 1222
     ) {
1224 1223
         if (empty($input_value)) {
1225 1224
             // if the form input isn't marked as being required, then just return
1226
-            if (! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1225
+            if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1227 1226
                 return true;
1228 1227
             }
1229 1228
             switch ($form_input) {
@@ -1310,7 +1309,7 @@  discard block
 block discarded – undo
1310 1309
             'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1311 1310
             false
1312 1311
         )) {
1313
-            $address_details           = array(
1312
+            $address_details = array(
1314 1313
                 'ATT_address',
1315 1314
                 'ATT_address2',
1316 1315
                 'ATT_city',
@@ -1322,7 +1321,7 @@  discard block
 block discarded – undo
1322 1321
             $critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1323 1322
         }
1324 1323
         foreach ($critical_attendee_details as $critical_attendee_detail) {
1325
-            if (! isset($attendee_data[$critical_attendee_detail])
1324
+            if ( ! isset($attendee_data[$critical_attendee_detail])
1326 1325
                 || empty($attendee_data[$critical_attendee_detail])
1327 1326
             ) {
1328 1327
                 $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
Please login to merge, or discard this patch.