Completed
Branch master (6bdc59)
by
unknown
25:30 queued 20:54
created
admin_pages/registrations/EE_Attendee_Contact_List_Table.class.php 1 patch
Indentation   +386 added lines, -386 removed lines patch added patch discarded remove patch
@@ -13,412 +13,412 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Attendee_Contact_List_Table extends EE_Admin_List_Table
15 15
 {
16
-    /**
17
-     * Initial setup of data (called by parent).
18
-     *
19
-     * @throws EE_Error
20
-     * @throws ReflectionException
21
-     */
22
-    protected function _setup_data()
23
-    {
24
-        $this->_data = $this->_view !== 'trash'
25
-            ? $this->_admin_page->get_attendees($this->_per_page)
26
-            : $this->_admin_page->get_attendees($this->_per_page, false, true);
27
-
28
-        $this->_all_data_count = $this->_view !== 'trash'
29
-            ? $this->_admin_page->get_attendees($this->_per_page, true)
30
-            : $this->_admin_page->get_attendees($this->_per_page, true, true);
31
-    }
32
-
33
-
34
-    /**
35
-     * Initial setup of properties.
36
-     */
37
-    protected function _set_properties()
38
-    {
39
-        $this->_wp_list_args = [
40
-            'singular' => esc_html__('attendee', 'event_espresso'),
41
-            'plural'   => esc_html__('attendees', 'event_espresso'),
42
-            'ajax'     => true,
43
-            'screen'   => $this->_admin_page->get_current_screen()->id,
44
-        ];
45
-
46
-        $this->_columns = [
47
-            'cb'                 => '<input type="checkbox" />', // Render a checkbox instead of text
48
-            'id'                 => esc_html__('ID', 'event_espresso'),
49
-            'ATT_fname'          => esc_html__('First Name', 'event_espresso'),
50
-            'ATT_lname'          => esc_html__('Last Name', 'event_espresso'),
51
-            'ATT_email'          => esc_html__('Email Address', 'event_espresso'),
52
-            'Registration_Count' => esc_html__('# Reg', 'event_espresso'),
53
-            'ATT_phone'          => esc_html__('Phone', 'event_espresso'),
54
-            'ATT_address'        => esc_html__('Address', 'event_espresso'),
55
-            'ATT_city'           => esc_html__('City', 'event_espresso'),
56
-            'STA_ID'             => esc_html__('State/Province', 'event_espresso'),
57
-            'CNT_ISO'            => esc_html__('Country', 'event_espresso'),
58
-        ];
59
-
60
-        $this->_sortable_columns = [
61
-            'id'                 => ['id' => false],
62
-            'ATT_lname'          => ['ATT_lname' => true], // true means its already sorted
63
-            'ATT_fname'          => ['ATT_fname' => false],
64
-            'ATT_email'          => ['ATT_email' => false],
65
-            'Registration_Count' => ['Registration_Count' => false],
66
-            'ATT_city'           => ['ATT_city' => false],
67
-            'STA_ID'             => ['STA_ID' => false],
68
-            'CNT_ISO'            => ['CNT_ISO' => false],
69
-        ];
70
-
71
-        $this->_hidden_columns = [
72
-            'ATT_phone',
73
-            'ATT_address',
74
-            'ATT_city',
75
-            'STA_ID',
76
-            'CNT_ISO',
77
-        ];
78
-    }
79
-
80
-
81
-    /**
82
-     * Initial setup of filters
83
-     *
84
-     * @return array
85
-     */
86
-    protected function _get_table_filters()
87
-    {
88
-        return [];
89
-    }
90
-
91
-
92
-    /**
93
-     * Initial setup of counts for views
94
-     *
95
-     * @throws InvalidArgumentException
96
-     * @throws InvalidDataTypeException
97
-     * @throws InvalidInterfaceException
98
-     * @throws EE_Error
99
-     * @throws EE_Error
100
-     * @throws ReflectionException
101
-     */
102
-    protected function _add_view_counts()
103
-    {
104
-        $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
105
-        if (
106
-            EE_Registry::instance()->CAP->current_user_can(
107
-                'ee_delete_contacts',
108
-                'espresso_registrations_delete_registration'
109
-            )
110
-        ) {
111
-            $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
112
-        }
113
-    }
114
-
115
-
116
-    /**
117
-     * Get count of attendees.
118
-     *
119
-     * @return int
120
-     * @throws EE_Error
121
-     * @throws InvalidArgumentException
122
-     * @throws InvalidDataTypeException
123
-     * @throws InvalidInterfaceException
124
-     * @throws ReflectionException
125
-     */
126
-    protected function _get_attendees_count(): int
127
-    {
128
-        return EEM_Attendee::instance()->count();
129
-    }
130
-
131
-
132
-    /**
133
-     * Checkbox column
134
-     *
135
-     * @param EE_Attendee $item Unable to typehint this method because overrides parent.
136
-     * @return string
137
-     * @throws EE_Error
138
-     * @throws ReflectionException
139
-     */
140
-    public function column_cb($item): string
141
-    {
142
-        if (! $item instanceof EE_Attendee) {
143
-            return '';
144
-        }
145
-        return sprintf(
146
-            '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
147
-            $item->ID()
148
-        );
149
-    }
150
-
151
-
152
-    /**
153
-     * @param EE_Attendee|null $attendee
154
-     * @return string
155
-     * @throws EE_Error
156
-     * @throws ReflectionException
157
-     */
158
-    public function column_id(?EE_Attendee $attendee): string
159
-    {
160
-        $content = '
16
+	/**
17
+	 * Initial setup of data (called by parent).
18
+	 *
19
+	 * @throws EE_Error
20
+	 * @throws ReflectionException
21
+	 */
22
+	protected function _setup_data()
23
+	{
24
+		$this->_data = $this->_view !== 'trash'
25
+			? $this->_admin_page->get_attendees($this->_per_page)
26
+			: $this->_admin_page->get_attendees($this->_per_page, false, true);
27
+
28
+		$this->_all_data_count = $this->_view !== 'trash'
29
+			? $this->_admin_page->get_attendees($this->_per_page, true)
30
+			: $this->_admin_page->get_attendees($this->_per_page, true, true);
31
+	}
32
+
33
+
34
+	/**
35
+	 * Initial setup of properties.
36
+	 */
37
+	protected function _set_properties()
38
+	{
39
+		$this->_wp_list_args = [
40
+			'singular' => esc_html__('attendee', 'event_espresso'),
41
+			'plural'   => esc_html__('attendees', 'event_espresso'),
42
+			'ajax'     => true,
43
+			'screen'   => $this->_admin_page->get_current_screen()->id,
44
+		];
45
+
46
+		$this->_columns = [
47
+			'cb'                 => '<input type="checkbox" />', // Render a checkbox instead of text
48
+			'id'                 => esc_html__('ID', 'event_espresso'),
49
+			'ATT_fname'          => esc_html__('First Name', 'event_espresso'),
50
+			'ATT_lname'          => esc_html__('Last Name', 'event_espresso'),
51
+			'ATT_email'          => esc_html__('Email Address', 'event_espresso'),
52
+			'Registration_Count' => esc_html__('# Reg', 'event_espresso'),
53
+			'ATT_phone'          => esc_html__('Phone', 'event_espresso'),
54
+			'ATT_address'        => esc_html__('Address', 'event_espresso'),
55
+			'ATT_city'           => esc_html__('City', 'event_espresso'),
56
+			'STA_ID'             => esc_html__('State/Province', 'event_espresso'),
57
+			'CNT_ISO'            => esc_html__('Country', 'event_espresso'),
58
+		];
59
+
60
+		$this->_sortable_columns = [
61
+			'id'                 => ['id' => false],
62
+			'ATT_lname'          => ['ATT_lname' => true], // true means its already sorted
63
+			'ATT_fname'          => ['ATT_fname' => false],
64
+			'ATT_email'          => ['ATT_email' => false],
65
+			'Registration_Count' => ['Registration_Count' => false],
66
+			'ATT_city'           => ['ATT_city' => false],
67
+			'STA_ID'             => ['STA_ID' => false],
68
+			'CNT_ISO'            => ['CNT_ISO' => false],
69
+		];
70
+
71
+		$this->_hidden_columns = [
72
+			'ATT_phone',
73
+			'ATT_address',
74
+			'ATT_city',
75
+			'STA_ID',
76
+			'CNT_ISO',
77
+		];
78
+	}
79
+
80
+
81
+	/**
82
+	 * Initial setup of filters
83
+	 *
84
+	 * @return array
85
+	 */
86
+	protected function _get_table_filters()
87
+	{
88
+		return [];
89
+	}
90
+
91
+
92
+	/**
93
+	 * Initial setup of counts for views
94
+	 *
95
+	 * @throws InvalidArgumentException
96
+	 * @throws InvalidDataTypeException
97
+	 * @throws InvalidInterfaceException
98
+	 * @throws EE_Error
99
+	 * @throws EE_Error
100
+	 * @throws ReflectionException
101
+	 */
102
+	protected function _add_view_counts()
103
+	{
104
+		$this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
105
+		if (
106
+			EE_Registry::instance()->CAP->current_user_can(
107
+				'ee_delete_contacts',
108
+				'espresso_registrations_delete_registration'
109
+			)
110
+		) {
111
+			$this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
112
+		}
113
+	}
114
+
115
+
116
+	/**
117
+	 * Get count of attendees.
118
+	 *
119
+	 * @return int
120
+	 * @throws EE_Error
121
+	 * @throws InvalidArgumentException
122
+	 * @throws InvalidDataTypeException
123
+	 * @throws InvalidInterfaceException
124
+	 * @throws ReflectionException
125
+	 */
126
+	protected function _get_attendees_count(): int
127
+	{
128
+		return EEM_Attendee::instance()->count();
129
+	}
130
+
131
+
132
+	/**
133
+	 * Checkbox column
134
+	 *
135
+	 * @param EE_Attendee $item Unable to typehint this method because overrides parent.
136
+	 * @return string
137
+	 * @throws EE_Error
138
+	 * @throws ReflectionException
139
+	 */
140
+	public function column_cb($item): string
141
+	{
142
+		if (! $item instanceof EE_Attendee) {
143
+			return '';
144
+		}
145
+		return sprintf(
146
+			'<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
147
+			$item->ID()
148
+		);
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param EE_Attendee|null $attendee
154
+	 * @return string
155
+	 * @throws EE_Error
156
+	 * @throws ReflectionException
157
+	 */
158
+	public function column_id(?EE_Attendee $attendee): string
159
+	{
160
+		$content = '
161 161
             <span class="ee-entity-id">' . $attendee->ID() . '</span>
162 162
             <span class="show-on-mobile-view-only">
163 163
                 ' . $this->editAttendeeLink($attendee->ID(), $attendee->full_name()) . '
164 164
             </span>';
165
-        return $this->columnContent('id', $content, 'end');
166
-    }
167
-
168
-
169
-    /**
170
-     * ATT_lname column
171
-     *
172
-     * @param EE_Attendee $attendee
173
-     * @return string
174
-     * @throws EE_Error
175
-     * @throws ReflectionException
176
-     */
177
-    public function column_ATT_lname(EE_Attendee $attendee): string
178
-    {
179
-        // edit attendee link
180
-        $content = $this->editAttendeeLink($attendee->ID(), $attendee->lname());
181
-        return $this->columnContent('ATT_lname', $content);
182
-    }
183
-
184
-
185
-    /**
186
-     * @param int    $ID
187
-     * @param string $attendee_name
188
-     * @return string
189
-     * @since   5.0.0.p
190
-     */
191
-    private function editAttendeeLink(int $ID, string $attendee_name): string
192
-    {
193
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
194
-            [
195
-                'action' => 'edit_attendee',
196
-                'post'   => $ID,
197
-            ],
198
-            REG_ADMIN_URL
199
-        );
200
-        return EE_Registry::instance()->CAP->current_user_can(
201
-            'ee_edit_contacts',
202
-            'espresso_registrations_edit_attendee'
203
-        )
204
-            ? '
165
+		return $this->columnContent('id', $content, 'end');
166
+	}
167
+
168
+
169
+	/**
170
+	 * ATT_lname column
171
+	 *
172
+	 * @param EE_Attendee $attendee
173
+	 * @return string
174
+	 * @throws EE_Error
175
+	 * @throws ReflectionException
176
+	 */
177
+	public function column_ATT_lname(EE_Attendee $attendee): string
178
+	{
179
+		// edit attendee link
180
+		$content = $this->editAttendeeLink($attendee->ID(), $attendee->lname());
181
+		return $this->columnContent('ATT_lname', $content);
182
+	}
183
+
184
+
185
+	/**
186
+	 * @param int    $ID
187
+	 * @param string $attendee_name
188
+	 * @return string
189
+	 * @since   5.0.0.p
190
+	 */
191
+	private function editAttendeeLink(int $ID, string $attendee_name): string
192
+	{
193
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
194
+			[
195
+				'action' => 'edit_attendee',
196
+				'post'   => $ID,
197
+			],
198
+			REG_ADMIN_URL
199
+		);
200
+		return EE_Registry::instance()->CAP->current_user_can(
201
+			'ee_edit_contacts',
202
+			'espresso_registrations_edit_attendee'
203
+		)
204
+			? '
205 205
             <a  href="' . $edit_lnk_url . '"
206 206
                 class="ee-aria-tooltip"
207 207
                 aria-label="' . esc_attr__('Edit Contact', 'event_espresso') . '"
208 208
             >
209 209
                 ' . $attendee_name . '
210 210
             </a>'
211
-            : $attendee_name;
212
-    }
213
-
214
-
215
-    /**
216
-     * ATT_fname column
217
-     *
218
-     * @param EE_Attendee $attendee
219
-     * @return string
220
-     * @throws InvalidArgumentException
221
-     * @throws InvalidDataTypeException
222
-     * @throws InvalidInterfaceException
223
-     * @throws EE_Error
224
-     * @throws ReflectionException
225
-     * @throws ReflectionException
226
-     * @throws ReflectionException
227
-     * @throws ReflectionException
228
-     */
229
-    public function column_ATT_fname(EE_Attendee $attendee): string
230
-    {
231
-        // Build row actions
232
-        $actions = [];
233
-        // edit attendee link
234
-        if (
235
-            EE_Registry::instance()->CAP->current_user_can(
236
-                'ee_edit_contacts',
237
-                'espresso_registrations_edit_attendee'
238
-            )
239
-        ) {
240
-            $actions['edit'] = $this->editAttendeeLink(
241
-                $attendee->ID(),
242
-                esc_html__('Edit Contact', 'event_espresso')
243
-            );
244
-        }
245
-
246
-        if ($this->_view === 'in_use') {
247
-            // trash attendee link
248
-            if (
249
-                EE_Registry::instance()->CAP->current_user_can(
250
-                    'ee_delete_contacts',
251
-                    'espresso_registrations_trash_attendees'
252
-                )
253
-            ) {
254
-                $trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
255
-                    [
256
-                        'action' => 'trash_attendee',
257
-                        'ATT_ID' => $attendee->ID(),
258
-                    ],
259
-                    REG_ADMIN_URL
260
-                );
261
-                $actions['trash'] = '
211
+			: $attendee_name;
212
+	}
213
+
214
+
215
+	/**
216
+	 * ATT_fname column
217
+	 *
218
+	 * @param EE_Attendee $attendee
219
+	 * @return string
220
+	 * @throws InvalidArgumentException
221
+	 * @throws InvalidDataTypeException
222
+	 * @throws InvalidInterfaceException
223
+	 * @throws EE_Error
224
+	 * @throws ReflectionException
225
+	 * @throws ReflectionException
226
+	 * @throws ReflectionException
227
+	 * @throws ReflectionException
228
+	 */
229
+	public function column_ATT_fname(EE_Attendee $attendee): string
230
+	{
231
+		// Build row actions
232
+		$actions = [];
233
+		// edit attendee link
234
+		if (
235
+			EE_Registry::instance()->CAP->current_user_can(
236
+				'ee_edit_contacts',
237
+				'espresso_registrations_edit_attendee'
238
+			)
239
+		) {
240
+			$actions['edit'] = $this->editAttendeeLink(
241
+				$attendee->ID(),
242
+				esc_html__('Edit Contact', 'event_espresso')
243
+			);
244
+		}
245
+
246
+		if ($this->_view === 'in_use') {
247
+			// trash attendee link
248
+			if (
249
+				EE_Registry::instance()->CAP->current_user_can(
250
+					'ee_delete_contacts',
251
+					'espresso_registrations_trash_attendees'
252
+				)
253
+			) {
254
+				$trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
255
+					[
256
+						'action' => 'trash_attendee',
257
+						'ATT_ID' => $attendee->ID(),
258
+					],
259
+					REG_ADMIN_URL
260
+				);
261
+				$actions['trash'] = '
262 262
                     <a  href="' . $trash_lnk_url . '"
263 263
                         class="ee-aria-tooltip"
264 264
                         aria-label="' . esc_attr__('Move Contact to Trash', 'event_espresso') . '"
265 265
                     >
266 266
                         ' . esc_html__('Trash', 'event_espresso') . '
267 267
                     </a>';
268
-            }
269
-        } else {
270
-            if (
271
-                EE_Registry::instance()->CAP->current_user_can(
272
-                    'ee_delete_contacts',
273
-                    'espresso_registrations_restore_attendees'
274
-                )
275
-            ) {
276
-                // restore attendee link
277
-                $restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
278
-                    [
279
-                        'action' => 'restore_attendees',
280
-                        'ATT_ID' => $attendee->ID(),
281
-                    ],
282
-                    REG_ADMIN_URL
283
-                );
284
-                $actions['restore'] = '
268
+			}
269
+		} else {
270
+			if (
271
+				EE_Registry::instance()->CAP->current_user_can(
272
+					'ee_delete_contacts',
273
+					'espresso_registrations_restore_attendees'
274
+				)
275
+			) {
276
+				// restore attendee link
277
+				$restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
278
+					[
279
+						'action' => 'restore_attendees',
280
+						'ATT_ID' => $attendee->ID(),
281
+					],
282
+					REG_ADMIN_URL
283
+				);
284
+				$actions['restore'] = '
285 285
                     <a  href="' . $restore_lnk_url . '"
286 286
                         class="ee-aria-tooltip"
287 287
                         aria-label="' . esc_attr__('Restore Contact', 'event_espresso') . '"
288 288
                     >
289 289
                         ' . esc_html__('Restore', 'event_espresso') . '
290 290
                     </a>';
291
-            }
292
-        }
293
-
294
-        $name_link    = $this->editAttendeeLink($attendee->ID(), $attendee->fname());
295
-
296
-        // Return the name contents
297
-        $content = sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
298
-        return $this->columnContent('ATT_fname', $content);
299
-    }
300
-
301
-
302
-    /**
303
-     * Email Column
304
-     *
305
-     * @param EE_Attendee $attendee
306
-     * @return string
307
-     * @throws EE_Error
308
-     * @throws ReflectionException
309
-     */
310
-    public function column_ATT_email(EE_Attendee $attendee): string
311
-    {
312
-        $content = '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
313
-        return $this->columnContent('ATT_email', $content);
314
-    }
315
-
316
-
317
-    /**
318
-     * Column displaying count of registrations attached to Attendee.
319
-     *
320
-     * @param EE_Attendee $attendee
321
-     * @return string
322
-     * @throws EE_Error
323
-     * @throws ReflectionException
324
-     */
325
-    public function column_Registration_Count(EE_Attendee $attendee): string
326
-    {
327
-        $link = EEH_URL::add_query_args_and_nonce(
328
-            [
329
-                'action' => 'default',
330
-                'ATT_ID' => $attendee->ID(),
331
-            ],
332
-            REG_ADMIN_URL
333
-        );
334
-        $content = '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
335
-        return $this->columnContent('Registration_Count', $content, 'end');
336
-    }
337
-
338
-
339
-    /**
340
-     * ATT_address column
341
-     *
342
-     * @param EE_Attendee $attendee
343
-     * @return string
344
-     * @throws EE_Error
345
-     * @throws ReflectionException
346
-     */
347
-    public function column_ATT_address(EE_Attendee $attendee): string
348
-    {
349
-        return $this->columnContent('ATT_address', $attendee->address());
350
-    }
351
-
352
-
353
-    /**
354
-     * ATT_city column
355
-     *
356
-     * @param EE_Attendee $attendee
357
-     * @return string
358
-     * @throws EE_Error
359
-     * @throws ReflectionException
360
-     */
361
-    public function column_ATT_city(EE_Attendee $attendee): string
362
-    {
363
-        return $this->columnContent('ATT_city', $attendee->city());
364
-    }
365
-
366
-
367
-    /**
368
-     * State Column
369
-     *
370
-     * @param EE_Attendee $attendee
371
-     * @return string
372
-     * @throws EE_Error
373
-     * @throws InvalidArgumentException
374
-     * @throws InvalidDataTypeException
375
-     * @throws InvalidInterfaceException
376
-     * @throws ReflectionException
377
-     */
378
-    public function column_STA_ID(EE_Attendee $attendee): string
379
-    {
380
-        $states = EEM_State::instance()->get_all_states();
381
-        $state  = isset($states[ $attendee->state_ID() ])
382
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
383
-            : $attendee->state_ID();
384
-        $content = ! is_numeric($state) ? $state : '';
385
-        return $this->columnContent('STA_ID', $content);
386
-    }
387
-
388
-
389
-    /**
390
-     * Country Column
391
-     *
392
-     * @param EE_Attendee $attendee
393
-     * @return string
394
-     * @throws EE_Error
395
-     * @throws InvalidArgumentException
396
-     * @throws InvalidDataTypeException
397
-     * @throws InvalidInterfaceException
398
-     * @throws ReflectionException
399
-     * @throws ReflectionException
400
-     */
401
-    public function column_CNT_ISO(EE_Attendee $attendee): string
402
-    {
403
-        $countries = EEM_Country::instance()->get_all_countries();
404
-        $country   = isset($countries[ $attendee->country_ID() ])
405
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
406
-            : $attendee->country_ID();
407
-        $content = ! is_numeric($country) ? $country : '';
408
-        return $this->columnContent('CNT_ISO', $content);
409
-    }
410
-
411
-
412
-    /**
413
-     * Phone Number column
414
-     *
415
-     * @param EE_Attendee $attendee
416
-     * @return string
417
-     * @throws EE_Error
418
-     * @throws ReflectionException
419
-     */
420
-    public function column_ATT_phone(EE_Attendee $attendee): string
421
-    {
422
-        return $this->columnContent('ATT_phone', $attendee->phone());
423
-    }
291
+			}
292
+		}
293
+
294
+		$name_link    = $this->editAttendeeLink($attendee->ID(), $attendee->fname());
295
+
296
+		// Return the name contents
297
+		$content = sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
298
+		return $this->columnContent('ATT_fname', $content);
299
+	}
300
+
301
+
302
+	/**
303
+	 * Email Column
304
+	 *
305
+	 * @param EE_Attendee $attendee
306
+	 * @return string
307
+	 * @throws EE_Error
308
+	 * @throws ReflectionException
309
+	 */
310
+	public function column_ATT_email(EE_Attendee $attendee): string
311
+	{
312
+		$content = '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
313
+		return $this->columnContent('ATT_email', $content);
314
+	}
315
+
316
+
317
+	/**
318
+	 * Column displaying count of registrations attached to Attendee.
319
+	 *
320
+	 * @param EE_Attendee $attendee
321
+	 * @return string
322
+	 * @throws EE_Error
323
+	 * @throws ReflectionException
324
+	 */
325
+	public function column_Registration_Count(EE_Attendee $attendee): string
326
+	{
327
+		$link = EEH_URL::add_query_args_and_nonce(
328
+			[
329
+				'action' => 'default',
330
+				'ATT_ID' => $attendee->ID(),
331
+			],
332
+			REG_ADMIN_URL
333
+		);
334
+		$content = '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
335
+		return $this->columnContent('Registration_Count', $content, 'end');
336
+	}
337
+
338
+
339
+	/**
340
+	 * ATT_address column
341
+	 *
342
+	 * @param EE_Attendee $attendee
343
+	 * @return string
344
+	 * @throws EE_Error
345
+	 * @throws ReflectionException
346
+	 */
347
+	public function column_ATT_address(EE_Attendee $attendee): string
348
+	{
349
+		return $this->columnContent('ATT_address', $attendee->address());
350
+	}
351
+
352
+
353
+	/**
354
+	 * ATT_city column
355
+	 *
356
+	 * @param EE_Attendee $attendee
357
+	 * @return string
358
+	 * @throws EE_Error
359
+	 * @throws ReflectionException
360
+	 */
361
+	public function column_ATT_city(EE_Attendee $attendee): string
362
+	{
363
+		return $this->columnContent('ATT_city', $attendee->city());
364
+	}
365
+
366
+
367
+	/**
368
+	 * State Column
369
+	 *
370
+	 * @param EE_Attendee $attendee
371
+	 * @return string
372
+	 * @throws EE_Error
373
+	 * @throws InvalidArgumentException
374
+	 * @throws InvalidDataTypeException
375
+	 * @throws InvalidInterfaceException
376
+	 * @throws ReflectionException
377
+	 */
378
+	public function column_STA_ID(EE_Attendee $attendee): string
379
+	{
380
+		$states = EEM_State::instance()->get_all_states();
381
+		$state  = isset($states[ $attendee->state_ID() ])
382
+			? $states[ $attendee->state_ID() ]->get('STA_name')
383
+			: $attendee->state_ID();
384
+		$content = ! is_numeric($state) ? $state : '';
385
+		return $this->columnContent('STA_ID', $content);
386
+	}
387
+
388
+
389
+	/**
390
+	 * Country Column
391
+	 *
392
+	 * @param EE_Attendee $attendee
393
+	 * @return string
394
+	 * @throws EE_Error
395
+	 * @throws InvalidArgumentException
396
+	 * @throws InvalidDataTypeException
397
+	 * @throws InvalidInterfaceException
398
+	 * @throws ReflectionException
399
+	 * @throws ReflectionException
400
+	 */
401
+	public function column_CNT_ISO(EE_Attendee $attendee): string
402
+	{
403
+		$countries = EEM_Country::instance()->get_all_countries();
404
+		$country   = isset($countries[ $attendee->country_ID() ])
405
+			? $countries[ $attendee->country_ID() ]->get('CNT_name')
406
+			: $attendee->country_ID();
407
+		$content = ! is_numeric($country) ? $country : '';
408
+		return $this->columnContent('CNT_ISO', $content);
409
+	}
410
+
411
+
412
+	/**
413
+	 * Phone Number column
414
+	 *
415
+	 * @param EE_Attendee $attendee
416
+	 * @return string
417
+	 * @throws EE_Error
418
+	 * @throws ReflectionException
419
+	 */
420
+	public function column_ATT_phone(EE_Attendee $attendee): string
421
+	{
422
+		return $this->columnContent('ATT_phone', $attendee->phone());
423
+	}
424 424
 }
Please login to merge, or discard this patch.
thank_you_page/templates/thank-you-page-registration-details.template.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -14,24 +14,24 @@  discard block
 block discarded – undo
14 14
 
15 15
 <div class="ee-registration-details-dv">
16 16
     <?php
17
-    $registrations = $transaction->registrations();
18
-    $registrations = is_array($registrations) ? $registrations : [];
19
-    $reg_count     = count($registrations);
20
-    $reg_cntr      = 0;
21
-    $event_name    = '';
22
-    $wait_list     = false;
23
-    foreach ($registrations as $registration) {
24
-        if (! $registration instanceof EE_Registration) {
25
-            continue;
26
-        }
27
-        if ($event_name != $registration->event_name() && ! empty($event_name)) { ?>
17
+	$registrations = $transaction->registrations();
18
+	$registrations = is_array($registrations) ? $registrations : [];
19
+	$reg_count     = count($registrations);
20
+	$reg_cntr      = 0;
21
+	$event_name    = '';
22
+	$wait_list     = false;
23
+	foreach ($registrations as $registration) {
24
+		if (! $registration instanceof EE_Registration) {
25
+			continue;
26
+		}
27
+		if ($event_name != $registration->event_name() && ! empty($event_name)) { ?>
28 28
             </tbody>
29 29
             </table>
30 30
             <?php
31
-        }
32
-        $reg_cntr++;
33
-        if ($event_name != $registration->event_name()) {
34
-            ?>
31
+		}
32
+		$reg_cntr++;
33
+		if ($event_name != $registration->event_name()) {
34
+			?>
35 35
             <h5>
36 36
                 <span class="smaller-text grey-text">
37 37
                     <?php esc_html_e('for', 'event_espresso'); ?> :
@@ -54,24 +54,24 @@  discard block
 block discarded – undo
54 54
             </thead>
55 55
             <tbody>
56 56
             <?php
57
-        }
58
-        if ($is_primary || (! $is_primary && $reg_url_link == $registration->reg_url_link())) { ?>
57
+		}
58
+		if ($is_primary || (! $is_primary && $reg_url_link == $registration->reg_url_link())) { ?>
59 59
             <tr>
60 60
                 <td width="40%">
61 61
                     <span>
62 62
                         <?php
63
-                        if ($registration->attendee() instanceof EE_Attendee) {
64
-                            echo '<span class="ee-attendee-name">' . esc_html($registration->attendee()->full_name(true)) . '</span>';
65
-                        }
66
-                        ?>
63
+						if ($registration->attendee() instanceof EE_Attendee) {
64
+							echo '<span class="ee-attendee-name">' . esc_html($registration->attendee()->full_name(true)) . '</span>';
65
+						}
66
+						?>
67 67
                         <span class="tiny-text" style="margin: .75em 0 0;">
68 68
                             <?php if ($registration->count_question_groups()) { ?>
69 69
                                 <a class="ee-icon-only-lnk"
70 70
                                    href="<?php echo esc_url_raw($registration->edit_attendee_information_url()); ?>"
71 71
                                    title="<?php esc_attr_e(
72
-                                       'Click here to edit Attendee Information',
73
-                                       'event_espresso'
74
-                                   ); ?>"
72
+									   'Click here to edit Attendee Information',
73
+									   'event_espresso'
74
+								   ); ?>"
75 75
                                 >
76 76
                                     <span class="dashicons dashicons-groups"></span>
77 77
                                     <span class="ee-link-text"><?php esc_html_e('edit info', 'event_espresso'); ?></span>
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
                             <?php } ?>
80 80
                             <a class="ee-resend-reg-confirmation-email ee-icon-only-lnk"
81 81
                                href="<?php echo esc_url_raw(
82
-                                   add_query_arg(
83
-                                       ['token' => $registration->reg_url_link(), 'resend_reg_confirmation' => 'true'],
84
-                                       EE_Registry::instance()->CFG->core->thank_you_page_url()
85
-                                   )
86
-                               ); ?>"
82
+								   add_query_arg(
83
+									   ['token' => $registration->reg_url_link(), 'resend_reg_confirmation' => 'true'],
84
+									   EE_Registry::instance()->CFG->core->thank_you_page_url()
85
+								   )
86
+							   ); ?>"
87 87
                                title="<?php esc_attr_e(
88
-                                   'Click here to resend the Registration Confirmation email',
89
-                                   'event_espresso'
90
-                               ); ?>"
88
+								   'Click here to resend the Registration Confirmation email',
89
+								   'event_espresso'
90
+							   ); ?>"
91 91
                                rel="<?php echo esc_attr($registration->reg_url_link()); ?>"
92 92
                             >
93 93
                                 <span class="dashicons dashicons-email-alt"></span>
@@ -103,28 +103,28 @@  discard block
 block discarded – undo
103 103
                     <span>
104 104
                     <?php $registration->e_pretty_status(true) ?>
105 105
                     <?php
106
-                    if ($registration->status_ID() === EEM_Registration::status_id_wait_list) {
107
-                        $wait_list = true;
108
-                    }
109
-                    ?>
106
+					if ($registration->status_ID() === EEM_Registration::status_id_wait_list) {
107
+						$wait_list = true;
108
+					}
109
+					?>
110 110
                     </span>
111 111
                 </td>
112 112
             </tr>
113 113
             <?php do_action(
114
-                'AHEE__thank_you_page_registration_details_template__after_registration_table_row',
115
-                $registration
116
-            ); ?>
114
+				'AHEE__thank_you_page_registration_details_template__after_registration_table_row',
115
+				$registration
116
+			); ?>
117 117
             <?php
118
-            $event_name = $registration->event_name();
119
-        }
120
-        if ($reg_cntr >= $reg_count) {
121
-            ?>
118
+			$event_name = $registration->event_name();
119
+		}
120
+		if ($reg_cntr >= $reg_count) {
121
+			?>
122 122
             </tbody>
123 123
             </table>
124 124
             <?php
125
-        }
126
-    }
127
-    ?>
125
+		}
126
+	}
127
+	?>
128 128
     <?php if ($is_primary && $SPCO_attendee_information_url) { ?>
129 129
         <p class="small-text jst-rght">
130 130
             <a href='<?php echo esc_url_raw($SPCO_attendee_information_url) ?>'>
@@ -133,29 +133,29 @@  discard block
 block discarded – undo
133 133
         </p>
134 134
     <?php } ?>
135 135
     <?php
136
-    if ($wait_list) {
137
-        echo apply_filters(
138
-            'AFEE__thank_you_page_registration_details_template__wait_list_notice',
139
-            sprintf(
140
-                esc_html__(
141
-                    '%1$sre: Wait List Registrations%2$sPlease note that the total cost listed below in the Transaction Details is for ALL registrations, including those that are on the wait list, even though they can not be currently paid for. If any spaces become available however, you may be notified by the Event admin and have the opportunity to secure the remaining tickets by making a payment for them.%3$s',
142
-                    'event_espresso'
143
-                ),
144
-                '
136
+	if ($wait_list) {
137
+		echo apply_filters(
138
+			'AFEE__thank_you_page_registration_details_template__wait_list_notice',
139
+			sprintf(
140
+				esc_html__(
141
+					'%1$sre: Wait List Registrations%2$sPlease note that the total cost listed below in the Transaction Details is for ALL registrations, including those that are on the wait list, even though they can not be currently paid for. If any spaces become available however, you may be notified by the Event admin and have the opportunity to secure the remaining tickets by making a payment for them.%3$s',
142
+					'event_espresso'
143
+				),
144
+				'
145 145
                 <h6 class="" style="margin-bottom:.25em;">
146 146
                     <span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>
147 147
                     <span class="ee-link-text">',
148
-                '
148
+				'
149 149
                     </span>
150 150
                 </h6 >
151 151
                 <p class="ee-wait-list-notice">',
152
-                '
152
+				'
153 153
                 </p ><br />'
154
-            )
155
-        );
156
-    }
157
-    do_action('AHEE__thank_you_page_registration_details_template__after_registration_details');
158
-    ?>
154
+			)
155
+		);
156
+	}
157
+	do_action('AHEE__thank_you_page_registration_details_template__after_registration_details');
158
+	?>
159 159
 
160 160
 </div>
161 161
 <!-- end of .registration-details -->
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     $event_name    = '';
22 22
     $wait_list     = false;
23 23
     foreach ($registrations as $registration) {
24
-        if (! $registration instanceof EE_Registration) {
24
+        if ( ! $registration instanceof EE_Registration) {
25 25
             continue;
26 26
         }
27 27
         if ($event_name != $registration->event_name() && ! empty($event_name)) { ?>
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
             <tbody>
56 56
             <?php
57 57
         }
58
-        if ($is_primary || (! $is_primary && $reg_url_link == $registration->reg_url_link())) { ?>
58
+        if ($is_primary || ( ! $is_primary && $reg_url_link == $registration->reg_url_link())) { ?>
59 59
             <tr>
60 60
                 <td width="40%">
61 61
                     <span>
62 62
                         <?php
63 63
                         if ($registration->attendee() instanceof EE_Attendee) {
64
-                            echo '<span class="ee-attendee-name">' . esc_html($registration->attendee()->full_name(true)) . '</span>';
64
+                            echo '<span class="ee-attendee-name">'.esc_html($registration->attendee()->full_name(true)).'</span>';
65 65
                         }
66 66
                         ?>
67 67
                         <span class="tiny-text" style="margin: .75em 0 0;">
Please login to merge, or discard this patch.
modules/thank_you_page/EED_Thank_You_Page.module.php 2 patches
Indentation   +802 added lines, -802 removed lines patch added patch discarded remove patch
@@ -12,622 +12,622 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class EED_Thank_You_Page extends EED_Module
14 14
 {
15
-    /**
16
-     * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes )
17
-     */
18
-    const IPN_wait_time = 1200;
19
-
20
-    /**
21
-     * The transaction specified by the reg_url_link passed from the Request, or from the Session
22
-     *
23
-     * @var EE_Transaction $_current_txn
24
-     */
25
-    private $_current_txn;
26
-
27
-    /**
28
-     * @var EE_Registration $_primary_registrant
29
-     */
30
-    private $_primary_registrant;
31
-
32
-    /**
33
-     * The reg_url_link passed from the Request, or from the Session
34
-     *
35
-     * @var string $_reg_url_link
36
-     */
37
-    private $_reg_url_link;
38
-
39
-    /**
40
-     * whether the incoming reg_url_link is for the primary registrant or not
41
-     *
42
-     * @var boolean $_is_primary
43
-     */
44
-    private $_is_primary;
45
-
46
-    /**
47
-     * The URL for revisiting the SPCO attendee information step
48
-     *
49
-     * @var string $_SPCO_attendee_information_url
50
-     */
51
-    private $_SPCO_attendee_information_url;
52
-
53
-    /**
54
-     * The URL for revisiting the SPCO payment options step
55
-     *
56
-     * @var string $_SPCO_payment_options_url
57
-     */
58
-    private $_SPCO_payment_options_url;
59
-
60
-    /**
61
-     * whether to display the Payment Options link
62
-     *
63
-     * @var boolean $_show_try_pay_again_link
64
-     */
65
-    private $_show_try_pay_again_link = false;
66
-
67
-    /**
68
-     * whether payments are allowed at this time
69
-     *
70
-     * @var boolean $_payments_closed
71
-     */
72
-    private $_payments_closed = false;
73
-
74
-    /**
75
-     * whether the selected payment method is Bank, Check , Invoice, etc
76
-     *
77
-     * @var boolean $_is_offline_payment_method
78
-     */
79
-    private $_is_offline_payment_method = true;
80
-
81
-
82
-    /**
83
-     * @return EED_Module|EED_Thank_You_Page
84
-     * @throws EE_Error
85
-     * @throws ReflectionException
86
-     */
87
-    public static function instance()
88
-    {
89
-        return parent::get_instance(__CLASS__);
90
-    }
91
-
92
-
93
-    /**
94
-     * set_hooks - for hooking into EE Core, modules, etc
95
-     *
96
-     * @return void
97
-     */
98
-    public static function set_hooks()
99
-    {
100
-        add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2);
101
-    }
102
-
103
-
104
-    /**
105
-     * set_hooks_admin - for hooking into EE Admin Core, modules, etc
106
-     *
107
-     * @return void
108
-     */
109
-    public static function set_hooks_admin()
110
-    {
111
-        add_action(
112
-            'wp_ajax_espresso_resend_reg_confirmation_email',
113
-            array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
114
-            10,
115
-            2
116
-        );
117
-        add_action(
118
-            'wp_ajax_nopriv_espresso_resend_reg_confirmation_email',
119
-            array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
120
-            10,
121
-            2
122
-        );
123
-    }
124
-
125
-
126
-    /**
127
-     * set_definitions
128
-     *
129
-     * @return void
130
-     */
131
-    public static function set_definitions()
132
-    {
133
-        define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
134
-        define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
135
-    }
136
-
137
-
138
-    /**
139
-     * get_txn
140
-     *
141
-     * @return EE_Transaction
142
-     * @throws EE_Error
143
-     * @throws ReflectionException
144
-     */
145
-    public function get_txn()
146
-    {
147
-        if ($this->_current_txn instanceof EE_Transaction) {
148
-            return $this->_current_txn;
149
-        }
150
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
151
-        if (! $TXN_model instanceof EEM_Transaction) {
152
-            EE_Error::add_error(
153
-                esc_html__('The transaction model could not be established.', 'event_espresso'),
154
-                __FILE__,
155
-                __FUNCTION__,
156
-                __LINE__
157
-            );
158
-            return null;
159
-        }
160
-        // get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request
161
-        $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link);
162
-        // verify TXN
163
-        if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) {
164
-            EE_Error::add_error(
165
-                esc_html__(
166
-                    'No transaction information could be retrieved or the transaction data is not of the correct type.',
167
-                    'event_espresso'
168
-                ),
169
-                __FILE__,
170
-                __FUNCTION__,
171
-                __LINE__
172
-            );
173
-            return null;
174
-        }
175
-        return $this->_current_txn;
176
-    }
177
-
178
-
179
-    /**
180
-     * get_txn_payments
181
-     *
182
-     * @param int $since
183
-     * @return EE_Payment[]
184
-     * @throws EE_Error
185
-     * @throws ReflectionException
186
-     */
187
-    public function get_txn_payments($since = 0)
188
-    {
189
-        if (! $this->get_txn()) {
190
-            return [];
191
-        }
192
-        $args = array('order_by' => array('PAY_timestamp' => 'ASC'));
193
-        if ($since > 0) {
194
-            $args[0] = array('PAY_timestamp' => array('>', $since));
195
-        }
196
-        // get array of payments with most recent first
197
-        return $this->_current_txn->payments($args);
198
-    }
199
-
200
-
201
-    /**
202
-     * @return bool
203
-     */
204
-    public function isOfflinePaymentMethod()
205
-    {
206
-        return $this->_is_offline_payment_method;
207
-    }
208
-
209
-
210
-
211
-
212
-    /**
213
-     * get_reg_url_link
214
-     *
215
-     * @return void
216
-     */
217
-    private function _get_reg_url_link()
218
-    {
219
-        if ($this->_reg_url_link) {
220
-            return;
221
-        }
222
-        // check for reg_url_link
223
-        $reg_url_link = self::getRequest()->getRequestParam('e_reg_url_link');
224
-        // only do thank you page stuff if we have a REG_url_link in the url
225
-        if (WP_DEBUG && ! $reg_url_link) {
226
-            EE_Error::add_error(
227
-                esc_html__(
228
-                    'No transaction information could be retrieved because the registration URL link is missing or invalid.',
229
-                    'event_espresso'
230
-                ),
231
-                __FILE__,
232
-                __FUNCTION__,
233
-                __LINE__
234
-            );
235
-        }
236
-        $this->set_reg_url_link($reg_url_link);
237
-    }
238
-
239
-
240
-    /**
241
-     * set_reg_url_link
242
-     *
243
-     * @param string $reg_url_link
244
-     */
245
-    public function set_reg_url_link($reg_url_link = null)
246
-    {
247
-        $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link;
248
-    }
249
-
250
-
251
-    /**
252
-     * run - initial module setup
253
-     * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
254
-     *
255
-     * @param WP $WP
256
-     * @return void
257
-     */
258
-    public function run($WP)
259
-    {
260
-    }
261
-
262
-
263
-    /**
264
-     * load_resources
265
-     *
266
-     * @return void
267
-     * @throws EE_Error
268
-     * @throws ReflectionException
269
-     */
270
-    public function load_resources()
271
-    {
272
-        $this->_get_reg_url_link();
273
-        // resend_reg_confirmation_email ?
274
-        if (self::getRequest()->requestParamIsSet('resend')) {
275
-            EED_Thank_You_Page::resend_reg_confirmation_email();
276
-        }
277
-        if (! EE_Registry::instance()->SSN instanceof EE_Session) {
278
-            // Make sure we allow loading the session. It is required here.
279
-            add_filter('FHEE_load_EE_Session', '__return_true', 999);
280
-            EE_Registry::instance()->SSN = LoaderFactory::getShared('EE_Session');
281
-        }
282
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
283
-        $this->_translate_strings();
284
-        // load assets
285
-        add_action('wp_enqueue_scripts', [$this, 'load_js'], 10);
286
-    }
287
-
288
-
289
-    /**
290
-     * load_js
291
-     *
292
-     * @return void
293
-     */
294
-    protected function _translate_strings()
295
-    {
296
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link;
297
-        EE_Registry::$i18n_js_strings['initial_access'] = time();
298
-        EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time;
299
-        EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code;
300
-        EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code;
301
-        EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __(
302
-            'checking for new payments...',
303
-            'event_espresso'
304
-        );
305
-        EE_Registry::$i18n_js_strings['loading_payment_info'] = __(
306
-            'loading payment information...',
307
-            'event_espresso'
308
-        );
309
-        EE_Registry::$i18n_js_strings['server_error'] = __(
310
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.',
311
-            'event_espresso'
312
-        );
313
-        EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters(
314
-            'EED_Thank_You_Page__load_js__slow_IPN',
315
-            sprintf(
316
-                __(
317
-                    '%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s',
318
-                    'event_espresso'
319
-                ),
320
-                '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">',
321
-                '</div>'
322
-            )
323
-        );
324
-    }
325
-
326
-
327
-    /**
328
-     * load_js
329
-     *
330
-     * @return void
331
-     */
332
-    public function load_js()
333
-    {
334
-        wp_enqueue_script(
335
-            'thank_you_page',
336
-            THANK_YOU_ASSETS_URL . 'thank_you_page.js',
337
-            array('espresso_core', 'heartbeat'),
338
-            EVENT_ESPRESSO_VERSION,
339
-            true
340
-        );
341
-        wp_enqueue_style(
342
-            'thank_you_page_css',
343
-            THANK_YOU_ASSETS_URL . 'thank_you_page.css',
344
-            ['espresso_default'],
345
-            EVENT_ESPRESSO_VERSION
346
-        );
347
-    }
348
-
349
-
350
-    /**
351
-     * init
352
-     *
353
-     * @return void
354
-     * @throws EE_Error
355
-     * @throws ReflectionException
356
-     */
357
-    public function init()
358
-    {
359
-        $this->_get_reg_url_link();
360
-        if (! $this->get_txn()) {
361
-            echo EEH_HTML::div(
362
-                EEH_HTML::h4(esc_html__('We\'re sorry...', 'event_espresso')) .
363
-                sprintf(
364
-                    esc_html__(
365
-                        'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
366
-                        'event_espresso'
367
-                    ),
368
-                    '<br/>'
369
-                ),
370
-                '',
371
-                'ee-attention'
372
-            );
373
-            return;
374
-        }
375
-        // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
376
-        if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) {
377
-            $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
378
-            $this->_current_txn->save();
379
-        }
380
-        $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration
381
-            ? $this->_current_txn->primary_registration()
382
-            : null;
383
-        $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link;
384
-        $show_try_pay_again_link_default = apply_filters(
385
-            'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default',
386
-            true
387
-        );
388
-        $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
389
-        // txn status ?
390
-        if ($this->_current_txn->is_completed()) {
391
-            $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
392
-        } elseif (
393
-            $this->_current_txn->is_incomplete()
394
-            && ($this->_primary_registrant->is_approved()
395
-                || $this->_primary_registrant->is_pending_payment())
396
-        ) {
397
-            $this->_show_try_pay_again_link = true;
398
-        } elseif ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
399
-            // its pending
400
-            $this->_show_try_pay_again_link = isset(
401
-                EE_Registry::instance()->CFG->registration->show_pending_payment_options
402
-            )
403
-                                              && EE_Registry::instance()->CFG
404
-                                                  ->registration->show_pending_payment_options
405
-                ? true
406
-                : $show_try_pay_again_link_default;
407
-        }
408
-        $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method;
409
-        $this->_is_offline_payment_method = false;
410
-        if (
15
+	/**
16
+	 * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes )
17
+	 */
18
+	const IPN_wait_time = 1200;
19
+
20
+	/**
21
+	 * The transaction specified by the reg_url_link passed from the Request, or from the Session
22
+	 *
23
+	 * @var EE_Transaction $_current_txn
24
+	 */
25
+	private $_current_txn;
26
+
27
+	/**
28
+	 * @var EE_Registration $_primary_registrant
29
+	 */
30
+	private $_primary_registrant;
31
+
32
+	/**
33
+	 * The reg_url_link passed from the Request, or from the Session
34
+	 *
35
+	 * @var string $_reg_url_link
36
+	 */
37
+	private $_reg_url_link;
38
+
39
+	/**
40
+	 * whether the incoming reg_url_link is for the primary registrant or not
41
+	 *
42
+	 * @var boolean $_is_primary
43
+	 */
44
+	private $_is_primary;
45
+
46
+	/**
47
+	 * The URL for revisiting the SPCO attendee information step
48
+	 *
49
+	 * @var string $_SPCO_attendee_information_url
50
+	 */
51
+	private $_SPCO_attendee_information_url;
52
+
53
+	/**
54
+	 * The URL for revisiting the SPCO payment options step
55
+	 *
56
+	 * @var string $_SPCO_payment_options_url
57
+	 */
58
+	private $_SPCO_payment_options_url;
59
+
60
+	/**
61
+	 * whether to display the Payment Options link
62
+	 *
63
+	 * @var boolean $_show_try_pay_again_link
64
+	 */
65
+	private $_show_try_pay_again_link = false;
66
+
67
+	/**
68
+	 * whether payments are allowed at this time
69
+	 *
70
+	 * @var boolean $_payments_closed
71
+	 */
72
+	private $_payments_closed = false;
73
+
74
+	/**
75
+	 * whether the selected payment method is Bank, Check , Invoice, etc
76
+	 *
77
+	 * @var boolean $_is_offline_payment_method
78
+	 */
79
+	private $_is_offline_payment_method = true;
80
+
81
+
82
+	/**
83
+	 * @return EED_Module|EED_Thank_You_Page
84
+	 * @throws EE_Error
85
+	 * @throws ReflectionException
86
+	 */
87
+	public static function instance()
88
+	{
89
+		return parent::get_instance(__CLASS__);
90
+	}
91
+
92
+
93
+	/**
94
+	 * set_hooks - for hooking into EE Core, modules, etc
95
+	 *
96
+	 * @return void
97
+	 */
98
+	public static function set_hooks()
99
+	{
100
+		add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2);
101
+	}
102
+
103
+
104
+	/**
105
+	 * set_hooks_admin - for hooking into EE Admin Core, modules, etc
106
+	 *
107
+	 * @return void
108
+	 */
109
+	public static function set_hooks_admin()
110
+	{
111
+		add_action(
112
+			'wp_ajax_espresso_resend_reg_confirmation_email',
113
+			array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
114
+			10,
115
+			2
116
+		);
117
+		add_action(
118
+			'wp_ajax_nopriv_espresso_resend_reg_confirmation_email',
119
+			array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
120
+			10,
121
+			2
122
+		);
123
+	}
124
+
125
+
126
+	/**
127
+	 * set_definitions
128
+	 *
129
+	 * @return void
130
+	 */
131
+	public static function set_definitions()
132
+	{
133
+		define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
134
+		define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
135
+	}
136
+
137
+
138
+	/**
139
+	 * get_txn
140
+	 *
141
+	 * @return EE_Transaction
142
+	 * @throws EE_Error
143
+	 * @throws ReflectionException
144
+	 */
145
+	public function get_txn()
146
+	{
147
+		if ($this->_current_txn instanceof EE_Transaction) {
148
+			return $this->_current_txn;
149
+		}
150
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
151
+		if (! $TXN_model instanceof EEM_Transaction) {
152
+			EE_Error::add_error(
153
+				esc_html__('The transaction model could not be established.', 'event_espresso'),
154
+				__FILE__,
155
+				__FUNCTION__,
156
+				__LINE__
157
+			);
158
+			return null;
159
+		}
160
+		// get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request
161
+		$this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link);
162
+		// verify TXN
163
+		if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) {
164
+			EE_Error::add_error(
165
+				esc_html__(
166
+					'No transaction information could be retrieved or the transaction data is not of the correct type.',
167
+					'event_espresso'
168
+				),
169
+				__FILE__,
170
+				__FUNCTION__,
171
+				__LINE__
172
+			);
173
+			return null;
174
+		}
175
+		return $this->_current_txn;
176
+	}
177
+
178
+
179
+	/**
180
+	 * get_txn_payments
181
+	 *
182
+	 * @param int $since
183
+	 * @return EE_Payment[]
184
+	 * @throws EE_Error
185
+	 * @throws ReflectionException
186
+	 */
187
+	public function get_txn_payments($since = 0)
188
+	{
189
+		if (! $this->get_txn()) {
190
+			return [];
191
+		}
192
+		$args = array('order_by' => array('PAY_timestamp' => 'ASC'));
193
+		if ($since > 0) {
194
+			$args[0] = array('PAY_timestamp' => array('>', $since));
195
+		}
196
+		// get array of payments with most recent first
197
+		return $this->_current_txn->payments($args);
198
+	}
199
+
200
+
201
+	/**
202
+	 * @return bool
203
+	 */
204
+	public function isOfflinePaymentMethod()
205
+	{
206
+		return $this->_is_offline_payment_method;
207
+	}
208
+
209
+
210
+
211
+
212
+	/**
213
+	 * get_reg_url_link
214
+	 *
215
+	 * @return void
216
+	 */
217
+	private function _get_reg_url_link()
218
+	{
219
+		if ($this->_reg_url_link) {
220
+			return;
221
+		}
222
+		// check for reg_url_link
223
+		$reg_url_link = self::getRequest()->getRequestParam('e_reg_url_link');
224
+		// only do thank you page stuff if we have a REG_url_link in the url
225
+		if (WP_DEBUG && ! $reg_url_link) {
226
+			EE_Error::add_error(
227
+				esc_html__(
228
+					'No transaction information could be retrieved because the registration URL link is missing or invalid.',
229
+					'event_espresso'
230
+				),
231
+				__FILE__,
232
+				__FUNCTION__,
233
+				__LINE__
234
+			);
235
+		}
236
+		$this->set_reg_url_link($reg_url_link);
237
+	}
238
+
239
+
240
+	/**
241
+	 * set_reg_url_link
242
+	 *
243
+	 * @param string $reg_url_link
244
+	 */
245
+	public function set_reg_url_link($reg_url_link = null)
246
+	{
247
+		$this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link;
248
+	}
249
+
250
+
251
+	/**
252
+	 * run - initial module setup
253
+	 * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
254
+	 *
255
+	 * @param WP $WP
256
+	 * @return void
257
+	 */
258
+	public function run($WP)
259
+	{
260
+	}
261
+
262
+
263
+	/**
264
+	 * load_resources
265
+	 *
266
+	 * @return void
267
+	 * @throws EE_Error
268
+	 * @throws ReflectionException
269
+	 */
270
+	public function load_resources()
271
+	{
272
+		$this->_get_reg_url_link();
273
+		// resend_reg_confirmation_email ?
274
+		if (self::getRequest()->requestParamIsSet('resend')) {
275
+			EED_Thank_You_Page::resend_reg_confirmation_email();
276
+		}
277
+		if (! EE_Registry::instance()->SSN instanceof EE_Session) {
278
+			// Make sure we allow loading the session. It is required here.
279
+			add_filter('FHEE_load_EE_Session', '__return_true', 999);
280
+			EE_Registry::instance()->SSN = LoaderFactory::getShared('EE_Session');
281
+		}
282
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
283
+		$this->_translate_strings();
284
+		// load assets
285
+		add_action('wp_enqueue_scripts', [$this, 'load_js'], 10);
286
+	}
287
+
288
+
289
+	/**
290
+	 * load_js
291
+	 *
292
+	 * @return void
293
+	 */
294
+	protected function _translate_strings()
295
+	{
296
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link;
297
+		EE_Registry::$i18n_js_strings['initial_access'] = time();
298
+		EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time;
299
+		EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code;
300
+		EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code;
301
+		EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __(
302
+			'checking for new payments...',
303
+			'event_espresso'
304
+		);
305
+		EE_Registry::$i18n_js_strings['loading_payment_info'] = __(
306
+			'loading payment information...',
307
+			'event_espresso'
308
+		);
309
+		EE_Registry::$i18n_js_strings['server_error'] = __(
310
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.',
311
+			'event_espresso'
312
+		);
313
+		EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters(
314
+			'EED_Thank_You_Page__load_js__slow_IPN',
315
+			sprintf(
316
+				__(
317
+					'%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s',
318
+					'event_espresso'
319
+				),
320
+				'<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">',
321
+				'</div>'
322
+			)
323
+		);
324
+	}
325
+
326
+
327
+	/**
328
+	 * load_js
329
+	 *
330
+	 * @return void
331
+	 */
332
+	public function load_js()
333
+	{
334
+		wp_enqueue_script(
335
+			'thank_you_page',
336
+			THANK_YOU_ASSETS_URL . 'thank_you_page.js',
337
+			array('espresso_core', 'heartbeat'),
338
+			EVENT_ESPRESSO_VERSION,
339
+			true
340
+		);
341
+		wp_enqueue_style(
342
+			'thank_you_page_css',
343
+			THANK_YOU_ASSETS_URL . 'thank_you_page.css',
344
+			['espresso_default'],
345
+			EVENT_ESPRESSO_VERSION
346
+		);
347
+	}
348
+
349
+
350
+	/**
351
+	 * init
352
+	 *
353
+	 * @return void
354
+	 * @throws EE_Error
355
+	 * @throws ReflectionException
356
+	 */
357
+	public function init()
358
+	{
359
+		$this->_get_reg_url_link();
360
+		if (! $this->get_txn()) {
361
+			echo EEH_HTML::div(
362
+				EEH_HTML::h4(esc_html__('We\'re sorry...', 'event_espresso')) .
363
+				sprintf(
364
+					esc_html__(
365
+						'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
366
+						'event_espresso'
367
+					),
368
+					'<br/>'
369
+				),
370
+				'',
371
+				'ee-attention'
372
+			);
373
+			return;
374
+		}
375
+		// if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
376
+		if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) {
377
+			$this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
378
+			$this->_current_txn->save();
379
+		}
380
+		$this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration
381
+			? $this->_current_txn->primary_registration()
382
+			: null;
383
+		$this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link;
384
+		$show_try_pay_again_link_default = apply_filters(
385
+			'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default',
386
+			true
387
+		);
388
+		$this->_show_try_pay_again_link = $show_try_pay_again_link_default;
389
+		// txn status ?
390
+		if ($this->_current_txn->is_completed()) {
391
+			$this->_show_try_pay_again_link = $show_try_pay_again_link_default;
392
+		} elseif (
393
+			$this->_current_txn->is_incomplete()
394
+			&& ($this->_primary_registrant->is_approved()
395
+				|| $this->_primary_registrant->is_pending_payment())
396
+		) {
397
+			$this->_show_try_pay_again_link = true;
398
+		} elseif ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
399
+			// its pending
400
+			$this->_show_try_pay_again_link = isset(
401
+				EE_Registry::instance()->CFG->registration->show_pending_payment_options
402
+			)
403
+											  && EE_Registry::instance()->CFG
404
+												  ->registration->show_pending_payment_options
405
+				? true
406
+				: $show_try_pay_again_link_default;
407
+		}
408
+		$this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method;
409
+		$this->_is_offline_payment_method = false;
410
+		if (
411 411
 // if payment method is unknown
412
-            ! $this->_current_txn->payment_method() instanceof EE_Payment_Method
413
-            || (
414
-                // or is an offline payment method
415
-                $this->_current_txn->payment_method() instanceof EE_Payment_Method
416
-                && $this->_current_txn->payment_method()->is_off_line()
417
-            )
418
-        ) {
419
-            $this->_is_offline_payment_method = true;
420
-        }
421
-        // link to SPCO
422
-        $revisit_spco_url = add_query_arg(
423
-            array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link),
424
-            EE_Registry::instance()->CFG->core->reg_page_url()
425
-        );
426
-        // link to SPCO payment_options
427
-        $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration
428
-            ? $this->_primary_registrant->payment_overview_url()
429
-            : add_query_arg(
430
-                array('step' => 'payment_options'),
431
-                $revisit_spco_url
432
-            );
433
-        // link to SPCO attendee_information
434
-        $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration
435
-            ? $this->_primary_registrant->edit_attendee_information_url()
436
-            : false;
437
-        do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn);
438
-        // set no cache headers and constants
439
-        EE_System::do_not_cache();
440
-    }
441
-
442
-
443
-    /**
444
-     * display_thank_you_page_results
445
-     *
446
-     * @return string
447
-     * @throws EE_Error
448
-     * @throws ReflectionException
449
-     */
450
-    public function thank_you_page_results()
451
-    {
452
-        $this->init();
453
-        if (! $this->_current_txn instanceof EE_Transaction) {
454
-            return EE_Error::get_notices();
455
-        }
456
-        // link to receipt
457
-        $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url();
458
-        if (! empty($template_args['TXN_receipt_url'])) {
459
-            $template_args['order_conf_desc'] = esc_html__(
460
-                '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.',
461
-                'event_espresso'
462
-            );
463
-        } else {
464
-            $template_args['order_conf_desc'] = esc_html__(
465
-                '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.',
466
-                'event_espresso'
467
-            );
468
-        }
469
-        $template_args['transaction'] = $this->_current_txn;
470
-        $template_args['revisit'] = self::getRequest()->getRequestParam('revisit', false, 'bool');
471
-        add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details'));
472
-        if ($this->_is_primary && ! $this->_current_txn->is_free()) {
473
-            add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
474
-        }
475
-        return EEH_Template::locate_template(
476
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
477
-            $template_args
478
-        );
479
-    }
480
-
481
-
482
-    /**
483
-     * _update_server_wait_time
484
-     *
485
-     * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data
486
-     * @return array
487
-     * @throws EE_Error
488
-     * @throws ReflectionException
489
-     */
490
-    private function _update_server_wait_time($thank_you_page_data = array())
491
-    {
492
-        $response['espresso_thank_you_page'] = array(
493
-            'still_waiting' => isset($thank_you_page_data['initial_access'])
494
-                ? time() - $thank_you_page_data['initial_access']
495
-                : 0,
496
-            'txn_status'    => $this->_current_txn->status_ID(),
497
-        );
498
-        return $response;
499
-    }
500
-
501
-
502
-    /**
503
-     * get_registration_details
504
-     *
505
-     * @throws EE_Error
506
-     */
507
-    public function get_registration_details()
508
-    {
509
-        // prepare variables for displaying
510
-        $template_args = array();
511
-        $template_args['transaction'] = $this->_current_txn;
512
-        $template_args['reg_url_link'] = $this->_reg_url_link;
513
-        $template_args['is_primary'] = $this->_is_primary;
514
-        $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url;
515
-        $template_args['resend_reg_confirmation_url'] = add_query_arg(
516
-            array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'),
517
-            EE_Registry::instance()->CFG->core->thank_you_page_url()
518
-        );
519
-        // verify template arguments
520
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
521
-        EEH_Template_Validator::verify_isnt_null(
522
-            $template_args['SPCO_attendee_information_url'],
523
-            '$SPCO_attendee_information_url'
524
-        );
525
-        echo EEH_Template::locate_template(
526
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
527
-            $template_args
528
-        );
529
-    }
530
-
531
-
532
-    /**
533
-     * resend_reg_confirmation_email
534
-     *
535
-     * @throws EE_Error
536
-     * @throws ReflectionException
537
-     */
538
-    public static function resend_reg_confirmation_email()
539
-    {
540
-        $reg_url_link = self::getRequest()->getRequestParam('token');
541
-        // was a REG_ID passed ?
542
-        if ($reg_url_link) {
543
-            $registration = EEM_Registration::instance()->get_one(
544
-                array(array('REG_url_link' => $reg_url_link))
545
-            );
546
-            if ($registration instanceof EE_Registration) {
547
-                // resend email
548
-                EED_Messages::process_resend(array('_REG_ID' => $registration->ID()));
549
-            } else {
550
-                EE_Error::add_error(
551
-                    esc_html__(
552
-                        'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.',
553
-                        'event_espresso'
554
-                    ),
555
-                    __FILE__,
556
-                    __FUNCTION__,
557
-                    __LINE__
558
-                );
559
-            }
560
-        } else {
561
-            EE_Error::add_error(
562
-                esc_html__(
563
-                    'The Registration Confirmation email could not be sent because a registration token is missing or invalid.',
564
-                    'event_espresso'
565
-                ),
566
-                __FILE__,
567
-                __FUNCTION__,
568
-                __LINE__
569
-            );
570
-        }
571
-        // request sent via AJAX ?
572
-        if (EE_FRONT_AJAX) {
573
-            echo wp_json_encode(EE_Error::get_notices(false));
574
-            die();
575
-            // or was JS disabled ?
576
-        } else {
577
-            // save errors so that they get picked up on the next request
578
-            EE_Error::get_notices(true, true);
579
-            wp_safe_redirect(
580
-                add_query_arg(
581
-                    array('e_reg_url_link' => $reg_url_link),
582
-                    EE_Registry::instance()->CFG->core->thank_you_page_url()
583
-                )
584
-            );
585
-        }
586
-    }
587
-
588
-
589
-    /**
590
-     * get_ajax_content
591
-     *
592
-     * @return void
593
-     * @throws EE_Error
594
-     * @throws ReflectionException
595
-     */
596
-    public function get_ajax_content()
597
-    {
598
-        if (! $this->get_txn()) {
599
-            return;
600
-        }
601
-        // first determine which event(s) require pre-approval or not
602
-        $events = array();
603
-        $events_requiring_pre_approval = array();
604
-        foreach ($this->_current_txn->registrations() as $registration) {
605
-            if ($registration instanceof EE_Registration) {
606
-                $event = $registration->event();
607
-                if ($event instanceof EE_Event) {
608
-                    if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) {
609
-                        $events_requiring_pre_approval[ $event->ID() ] = $event;
610
-                    } else {
611
-                        $events[ $event->ID() ] = $event;
612
-                    }
613
-                }
614
-            }
615
-        }
616
-        $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval);
617
-        $this->display_details_for_events($events);
618
-    }
619
-
620
-
621
-    /**
622
-     * display_details_for_events
623
-     *
624
-     * @param EE_Event[] $events
625
-     * @return void
626
-     */
627
-    public function display_details_for_events($events = array())
628
-    {
629
-        if (! empty($events)) {
630
-            ?>
412
+			! $this->_current_txn->payment_method() instanceof EE_Payment_Method
413
+			|| (
414
+				// or is an offline payment method
415
+				$this->_current_txn->payment_method() instanceof EE_Payment_Method
416
+				&& $this->_current_txn->payment_method()->is_off_line()
417
+			)
418
+		) {
419
+			$this->_is_offline_payment_method = true;
420
+		}
421
+		// link to SPCO
422
+		$revisit_spco_url = add_query_arg(
423
+			array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link),
424
+			EE_Registry::instance()->CFG->core->reg_page_url()
425
+		);
426
+		// link to SPCO payment_options
427
+		$this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration
428
+			? $this->_primary_registrant->payment_overview_url()
429
+			: add_query_arg(
430
+				array('step' => 'payment_options'),
431
+				$revisit_spco_url
432
+			);
433
+		// link to SPCO attendee_information
434
+		$this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration
435
+			? $this->_primary_registrant->edit_attendee_information_url()
436
+			: false;
437
+		do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn);
438
+		// set no cache headers and constants
439
+		EE_System::do_not_cache();
440
+	}
441
+
442
+
443
+	/**
444
+	 * display_thank_you_page_results
445
+	 *
446
+	 * @return string
447
+	 * @throws EE_Error
448
+	 * @throws ReflectionException
449
+	 */
450
+	public function thank_you_page_results()
451
+	{
452
+		$this->init();
453
+		if (! $this->_current_txn instanceof EE_Transaction) {
454
+			return EE_Error::get_notices();
455
+		}
456
+		// link to receipt
457
+		$template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url();
458
+		if (! empty($template_args['TXN_receipt_url'])) {
459
+			$template_args['order_conf_desc'] = esc_html__(
460
+				'%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.',
461
+				'event_espresso'
462
+			);
463
+		} else {
464
+			$template_args['order_conf_desc'] = esc_html__(
465
+				'%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.',
466
+				'event_espresso'
467
+			);
468
+		}
469
+		$template_args['transaction'] = $this->_current_txn;
470
+		$template_args['revisit'] = self::getRequest()->getRequestParam('revisit', false, 'bool');
471
+		add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details'));
472
+		if ($this->_is_primary && ! $this->_current_txn->is_free()) {
473
+			add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
474
+		}
475
+		return EEH_Template::locate_template(
476
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
477
+			$template_args
478
+		);
479
+	}
480
+
481
+
482
+	/**
483
+	 * _update_server_wait_time
484
+	 *
485
+	 * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data
486
+	 * @return array
487
+	 * @throws EE_Error
488
+	 * @throws ReflectionException
489
+	 */
490
+	private function _update_server_wait_time($thank_you_page_data = array())
491
+	{
492
+		$response['espresso_thank_you_page'] = array(
493
+			'still_waiting' => isset($thank_you_page_data['initial_access'])
494
+				? time() - $thank_you_page_data['initial_access']
495
+				: 0,
496
+			'txn_status'    => $this->_current_txn->status_ID(),
497
+		);
498
+		return $response;
499
+	}
500
+
501
+
502
+	/**
503
+	 * get_registration_details
504
+	 *
505
+	 * @throws EE_Error
506
+	 */
507
+	public function get_registration_details()
508
+	{
509
+		// prepare variables for displaying
510
+		$template_args = array();
511
+		$template_args['transaction'] = $this->_current_txn;
512
+		$template_args['reg_url_link'] = $this->_reg_url_link;
513
+		$template_args['is_primary'] = $this->_is_primary;
514
+		$template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url;
515
+		$template_args['resend_reg_confirmation_url'] = add_query_arg(
516
+			array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'),
517
+			EE_Registry::instance()->CFG->core->thank_you_page_url()
518
+		);
519
+		// verify template arguments
520
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
521
+		EEH_Template_Validator::verify_isnt_null(
522
+			$template_args['SPCO_attendee_information_url'],
523
+			'$SPCO_attendee_information_url'
524
+		);
525
+		echo EEH_Template::locate_template(
526
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
527
+			$template_args
528
+		);
529
+	}
530
+
531
+
532
+	/**
533
+	 * resend_reg_confirmation_email
534
+	 *
535
+	 * @throws EE_Error
536
+	 * @throws ReflectionException
537
+	 */
538
+	public static function resend_reg_confirmation_email()
539
+	{
540
+		$reg_url_link = self::getRequest()->getRequestParam('token');
541
+		// was a REG_ID passed ?
542
+		if ($reg_url_link) {
543
+			$registration = EEM_Registration::instance()->get_one(
544
+				array(array('REG_url_link' => $reg_url_link))
545
+			);
546
+			if ($registration instanceof EE_Registration) {
547
+				// resend email
548
+				EED_Messages::process_resend(array('_REG_ID' => $registration->ID()));
549
+			} else {
550
+				EE_Error::add_error(
551
+					esc_html__(
552
+						'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.',
553
+						'event_espresso'
554
+					),
555
+					__FILE__,
556
+					__FUNCTION__,
557
+					__LINE__
558
+				);
559
+			}
560
+		} else {
561
+			EE_Error::add_error(
562
+				esc_html__(
563
+					'The Registration Confirmation email could not be sent because a registration token is missing or invalid.',
564
+					'event_espresso'
565
+				),
566
+				__FILE__,
567
+				__FUNCTION__,
568
+				__LINE__
569
+			);
570
+		}
571
+		// request sent via AJAX ?
572
+		if (EE_FRONT_AJAX) {
573
+			echo wp_json_encode(EE_Error::get_notices(false));
574
+			die();
575
+			// or was JS disabled ?
576
+		} else {
577
+			// save errors so that they get picked up on the next request
578
+			EE_Error::get_notices(true, true);
579
+			wp_safe_redirect(
580
+				add_query_arg(
581
+					array('e_reg_url_link' => $reg_url_link),
582
+					EE_Registry::instance()->CFG->core->thank_you_page_url()
583
+				)
584
+			);
585
+		}
586
+	}
587
+
588
+
589
+	/**
590
+	 * get_ajax_content
591
+	 *
592
+	 * @return void
593
+	 * @throws EE_Error
594
+	 * @throws ReflectionException
595
+	 */
596
+	public function get_ajax_content()
597
+	{
598
+		if (! $this->get_txn()) {
599
+			return;
600
+		}
601
+		// first determine which event(s) require pre-approval or not
602
+		$events = array();
603
+		$events_requiring_pre_approval = array();
604
+		foreach ($this->_current_txn->registrations() as $registration) {
605
+			if ($registration instanceof EE_Registration) {
606
+				$event = $registration->event();
607
+				if ($event instanceof EE_Event) {
608
+					if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) {
609
+						$events_requiring_pre_approval[ $event->ID() ] = $event;
610
+					} else {
611
+						$events[ $event->ID() ] = $event;
612
+					}
613
+				}
614
+			}
615
+		}
616
+		$this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval);
617
+		$this->display_details_for_events($events);
618
+	}
619
+
620
+
621
+	/**
622
+	 * display_details_for_events
623
+	 *
624
+	 * @param EE_Event[] $events
625
+	 * @return void
626
+	 */
627
+	public function display_details_for_events($events = array())
628
+	{
629
+		if (! empty($events)) {
630
+			?>
631 631
             <div id="espresso-thank-you-page-ajax-content-dv">
632 632
                 <div id="espresso-thank-you-page-ajax-transaction-dv"></div>
633 633
                 <div id="espresso-thank-you-page-ajax-payment-dv"></div>
@@ -635,19 +635,19 @@  discard block
 block discarded – undo
635 635
                     <div id="ee-ajax-loading-dv" class="float-left lt-blue-text">
636 636
                         <span class="dashicons dashicons-upload"></span><span id="ee-ajax-loading-msg-spn">
637 637
                             <?php esc_html_e(
638
-                                'loading transaction and payment information...',
639
-                                'event_espresso'
640
-                            ); ?></span>
638
+								'loading transaction and payment information...',
639
+								'event_espresso'
640
+							); ?></span>
641 641
                     </div>
642 642
                     <?php if (! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?>
643 643
                         <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear">
644 644
                             <?php echo apply_filters(
645
-                                'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg',
646
-                                esc_html__(
647
-                                    'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.',
648
-                                    'event_espresso'
649
-                                )
650
-                            ); ?>
645
+								'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg',
646
+								esc_html__(
647
+									'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.',
648
+									'event_espresso'
649
+								)
650
+							); ?>
651 651
                             <br/>
652 652
                             <span class="jst-rght ee-block small-text lt-grey-text">
653 653
                                 <?php esc_html_e('current wait time ', 'event_espresso'); ?>
@@ -658,124 +658,124 @@  discard block
 block discarded – undo
658 658
                 <div class="clear"></div>
659 659
             </div>
660 660
             <?php
661
-        }
662
-    }
663
-
664
-
665
-    /**
666
-     * display_details_for_events_requiring_pre_approval
667
-     *
668
-     * @param EE_Event[] $events
669
-     * @return void
670
-     * @throws EE_Error
671
-     * @throws EE_Error
672
-     */
673
-    public function display_details_for_events_requiring_pre_approval($events = array())
674
-    {
675
-        if (! empty($events)) {
676
-            ?>
661
+		}
662
+	}
663
+
664
+
665
+	/**
666
+	 * display_details_for_events_requiring_pre_approval
667
+	 *
668
+	 * @param EE_Event[] $events
669
+	 * @return void
670
+	 * @throws EE_Error
671
+	 * @throws EE_Error
672
+	 */
673
+	public function display_details_for_events_requiring_pre_approval($events = array())
674
+	{
675
+		if (! empty($events)) {
676
+			?>
677 677
             <div id="espresso-thank-you-page-not-approved-message-dv">
678 678
                 <h4 class="orange-text"><?php esc_html_e('Important Notice:', 'event_espresso'); ?></h4>
679 679
                 <p id="events-requiring-pre-approval-pg" class="small-text">
680 680
                     <?php echo apply_filters(
681
-                        'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message',
682
-                        esc_html__(
683
-                            'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.',
684
-                            'event_espresso'
685
-                        )
686
-                    ); ?>
681
+						'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message',
682
+						esc_html__(
683
+							'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.',
684
+							'event_espresso'
685
+						)
686
+					); ?>
687 687
                 </p>
688 688
                 <ul class="events-requiring-pre-approval-ul">
689 689
                     <?php
690
-                    foreach ($events as $event) {
691
-                        if ($event instanceof EE_Event) {
692
-                            echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>',
693
-                            esc_html($event->name()),
694
-                            '</li>';
695
-                        }
696
-                    } ?>
690
+					foreach ($events as $event) {
691
+						if ($event instanceof EE_Event) {
692
+							echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>',
693
+							esc_html($event->name()),
694
+							'</li>';
695
+						}
696
+					} ?>
697 697
                 </ul>
698 698
                 <div class="clear"></div>
699 699
             </div>
700 700
             <?php
701
-        }
702
-    }
703
-
704
-
705
-    /**
706
-     * get_transaction_details
707
-     *
708
-     * @return string
709
-     * @throws EE_Error
710
-     */
711
-    public function get_transaction_details()
712
-    {
713
-        // primary attendee
714
-        $primary_attendee = $this->_primary_registrant->attendee();
715
-        // prepare variables for displaying
716
-        $template_args                            = [];
717
-        $template_args['transaction']             = $this->_current_txn;
718
-        $template_args['reg_url_link']            = $this->_reg_url_link;
719
-        $template_args['primary_registrant_name'] = $primary_attendee instanceof EE_Attendee
720
-            ? $primary_attendee->full_name(true)
721
-            : '';
722
-        // link to SPCO payment_options
723
-        $template_args['show_try_pay_again_link']  = $this->_show_try_pay_again_link;
724
-        $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
725
-        // verify template arguments
726
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
727
-        EEH_Template_Validator::verify_isnt_null(
728
-            $template_args['show_try_pay_again_link'],
729
-            '$show_try_pay_again_link'
730
-        );
731
-        EEH_Template_Validator::verify_isnt_null(
732
-            $template_args['SPCO_payment_options_url'],
733
-            '$SPCO_payment_options_url'
734
-        );
735
-        return EEH_Template::locate_template(
736
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
737
-            $template_args
738
-        );
739
-    }
740
-
741
-
742
-    /**
743
-     * get_payment_row_html
744
-     *
745
-     * @param EE_Payment $payment
746
-     * @return string
747
-     * @throws EE_Error
748
-     */
749
-    public function get_payment_row_html(EE_Payment $payment = null)
750
-    {
751
-        $html = '';
752
-        if (! $payment instanceof EE_Payment) {
753
-            return '';
754
-        }
755
-        if (
756
-            $payment->payment_method() instanceof EE_Payment_Method
757
-            && $payment->status() === EEM_Payment::status_id_failed
758
-            && $payment->payment_method()->is_off_site()
759
-        ) {
760
-            // considering the registrant has made it to the Thank You page,
761
-            // any failed payments may actually be pending and the IPN is just slow
762
-            // so let's
763
-            $payment->set_status(EEM_Payment::status_id_pending);
764
-        }
765
-        $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
766
-            ? '<br /><span class="small-text">' . esc_html($payment->gateway_response()) . '</span>'
767
-            : '';
768
-        $html .= '
701
+		}
702
+	}
703
+
704
+
705
+	/**
706
+	 * get_transaction_details
707
+	 *
708
+	 * @return string
709
+	 * @throws EE_Error
710
+	 */
711
+	public function get_transaction_details()
712
+	{
713
+		// primary attendee
714
+		$primary_attendee = $this->_primary_registrant->attendee();
715
+		// prepare variables for displaying
716
+		$template_args                            = [];
717
+		$template_args['transaction']             = $this->_current_txn;
718
+		$template_args['reg_url_link']            = $this->_reg_url_link;
719
+		$template_args['primary_registrant_name'] = $primary_attendee instanceof EE_Attendee
720
+			? $primary_attendee->full_name(true)
721
+			: '';
722
+		// link to SPCO payment_options
723
+		$template_args['show_try_pay_again_link']  = $this->_show_try_pay_again_link;
724
+		$template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
725
+		// verify template arguments
726
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
727
+		EEH_Template_Validator::verify_isnt_null(
728
+			$template_args['show_try_pay_again_link'],
729
+			'$show_try_pay_again_link'
730
+		);
731
+		EEH_Template_Validator::verify_isnt_null(
732
+			$template_args['SPCO_payment_options_url'],
733
+			'$SPCO_payment_options_url'
734
+		);
735
+		return EEH_Template::locate_template(
736
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
737
+			$template_args
738
+		);
739
+	}
740
+
741
+
742
+	/**
743
+	 * get_payment_row_html
744
+	 *
745
+	 * @param EE_Payment $payment
746
+	 * @return string
747
+	 * @throws EE_Error
748
+	 */
749
+	public function get_payment_row_html(EE_Payment $payment = null)
750
+	{
751
+		$html = '';
752
+		if (! $payment instanceof EE_Payment) {
753
+			return '';
754
+		}
755
+		if (
756
+			$payment->payment_method() instanceof EE_Payment_Method
757
+			&& $payment->status() === EEM_Payment::status_id_failed
758
+			&& $payment->payment_method()->is_off_site()
759
+		) {
760
+			// considering the registrant has made it to the Thank You page,
761
+			// any failed payments may actually be pending and the IPN is just slow
762
+			// so let's
763
+			$payment->set_status(EEM_Payment::status_id_pending);
764
+		}
765
+		$payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
766
+			? '<br /><span class="small-text">' . esc_html($payment->gateway_response()) . '</span>'
767
+			: '';
768
+		$html .= '
769 769
             <tr>
770 770
                 <td>
771 771
                     ' . esc_html($payment->timestamp()) . '
772 772
                 </td>
773 773
                 <td>
774 774
                     ' . (
775
-            $payment->payment_method() instanceof EE_Payment_Method
776
-                ? esc_html($payment->payment_method()->name())
777
-                : esc_html__('Unknown', 'event_espresso')
778
-            ) . '
775
+			$payment->payment_method() instanceof EE_Payment_Method
776
+				? esc_html($payment->payment_method()->name())
777
+				: esc_html__('Unknown', 'event_espresso')
778
+			) . '
779 779
                 </td>
780 780
                 <td class="jst-rght">
781 781
                     ' . EEH_Template::format_currency($payment->amount()) . '
@@ -784,81 +784,81 @@  discard block
 block discarded – undo
784 784
                     ' . $payment->pretty_status(true) . $payment_declined_msg . '
785 785
                 </td>
786 786
             </tr>';
787
-        do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
788
-        return $html;
789
-    }
790
-
791
-
792
-    /**
793
-     * get_payment_details
794
-     *
795
-     * @param EE_Payment[] $payments
796
-     * @return string
797
-     * @throws EE_Error
798
-     * @throws ReflectionException
799
-     */
800
-    public function get_payment_details($payments = array())
801
-    {
802
-        // prepare variables for displaying
803
-        $template_args = array();
804
-        $template_args['transaction'] = $this->_current_txn;
805
-        $template_args['reg_url_link'] = $this->_reg_url_link;
806
-        $template_args['payments'] = array();
807
-        foreach ($payments as $payment) {
808
-            $template_args['payments'][] = $this->get_payment_row_html($payment);
809
-        }
810
-        // create a hacky payment object, but dont save it
811
-        $payment = EE_Payment::new_instance(
812
-            array(
813
-                'TXN_ID'        => $this->_current_txn->ID(),
814
-                'STS_ID'        => EEM_Payment::status_id_pending,
815
-                'PAY_timestamp' => time(),
816
-                'PAY_amount'    => $this->_current_txn->total(),
817
-                'PMD_ID'        => $this->_current_txn->payment_method_ID(),
818
-            )
819
-        );
820
-        $payment_method = $this->_current_txn->payment_method();
821
-        if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) {
822
-            $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment);
823
-        } else {
824
-            $template_args['gateway_content'] = '';
825
-        }
826
-        // link to SPCO payment_options
827
-        $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
828
-        $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
829
-        // verify template arguments
830
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
831
-        EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments');
832
-        EEH_Template_Validator::verify_isnt_null(
833
-            $template_args['show_try_pay_again_link'],
834
-            '$show_try_pay_again_link'
835
-        );
836
-        EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content');
837
-        EEH_Template_Validator::verify_isnt_null(
838
-            $template_args['SPCO_payment_options_url'],
839
-            '$SPCO_payment_options_url'
840
-        );
841
-        return EEH_Template::locate_template(
842
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
843
-            $template_args
844
-        );
845
-    }
846
-
847
-
848
-    /**
849
-     * get_payment_details
850
-     *
851
-     * @param array $payments
852
-     * @return string
853
-     * @throws EE_Error
854
-     */
855
-    public function get_new_payments($payments = array())
856
-    {
857
-        $payments_html = '';
858
-        // prepare variables for displaying
859
-        foreach ($payments as $payment) {
860
-            $payments_html .= $this->get_payment_row_html($payment);
861
-        }
862
-        return $payments_html;
863
-    }
787
+		do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
788
+		return $html;
789
+	}
790
+
791
+
792
+	/**
793
+	 * get_payment_details
794
+	 *
795
+	 * @param EE_Payment[] $payments
796
+	 * @return string
797
+	 * @throws EE_Error
798
+	 * @throws ReflectionException
799
+	 */
800
+	public function get_payment_details($payments = array())
801
+	{
802
+		// prepare variables for displaying
803
+		$template_args = array();
804
+		$template_args['transaction'] = $this->_current_txn;
805
+		$template_args['reg_url_link'] = $this->_reg_url_link;
806
+		$template_args['payments'] = array();
807
+		foreach ($payments as $payment) {
808
+			$template_args['payments'][] = $this->get_payment_row_html($payment);
809
+		}
810
+		// create a hacky payment object, but dont save it
811
+		$payment = EE_Payment::new_instance(
812
+			array(
813
+				'TXN_ID'        => $this->_current_txn->ID(),
814
+				'STS_ID'        => EEM_Payment::status_id_pending,
815
+				'PAY_timestamp' => time(),
816
+				'PAY_amount'    => $this->_current_txn->total(),
817
+				'PMD_ID'        => $this->_current_txn->payment_method_ID(),
818
+			)
819
+		);
820
+		$payment_method = $this->_current_txn->payment_method();
821
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) {
822
+			$template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment);
823
+		} else {
824
+			$template_args['gateway_content'] = '';
825
+		}
826
+		// link to SPCO payment_options
827
+		$template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
828
+		$template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
829
+		// verify template arguments
830
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
831
+		EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments');
832
+		EEH_Template_Validator::verify_isnt_null(
833
+			$template_args['show_try_pay_again_link'],
834
+			'$show_try_pay_again_link'
835
+		);
836
+		EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content');
837
+		EEH_Template_Validator::verify_isnt_null(
838
+			$template_args['SPCO_payment_options_url'],
839
+			'$SPCO_payment_options_url'
840
+		);
841
+		return EEH_Template::locate_template(
842
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
843
+			$template_args
844
+		);
845
+	}
846
+
847
+
848
+	/**
849
+	 * get_payment_details
850
+	 *
851
+	 * @param array $payments
852
+	 * @return string
853
+	 * @throws EE_Error
854
+	 */
855
+	public function get_new_payments($payments = array())
856
+	{
857
+		$payments_html = '';
858
+		// prepare variables for displaying
859
+		foreach ($payments as $payment) {
860
+			$payments_html .= $this->get_payment_row_html($payment);
861
+		}
862
+		return $payments_html;
863
+	}
864 864
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public static function set_definitions()
132 132
     {
133
-        define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
134
-        define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
133
+        define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
134
+        define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/');
135 135
     }
136 136
 
137 137
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             return $this->_current_txn;
149 149
         }
150 150
         $TXN_model = EE_Registry::instance()->load_model('Transaction');
151
-        if (! $TXN_model instanceof EEM_Transaction) {
151
+        if ( ! $TXN_model instanceof EEM_Transaction) {
152 152
             EE_Error::add_error(
153 153
                 esc_html__('The transaction model could not be established.', 'event_espresso'),
154 154
                 __FILE__,
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      */
187 187
     public function get_txn_payments($since = 0)
188 188
     {
189
-        if (! $this->get_txn()) {
189
+        if ( ! $this->get_txn()) {
190 190
             return [];
191 191
         }
192 192
         $args = array('order_by' => array('PAY_timestamp' => 'ASC'));
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
         if (self::getRequest()->requestParamIsSet('resend')) {
275 275
             EED_Thank_You_Page::resend_reg_confirmation_email();
276 276
         }
277
-        if (! EE_Registry::instance()->SSN instanceof EE_Session) {
277
+        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
278 278
             // Make sure we allow loading the session. It is required here.
279 279
             add_filter('FHEE_load_EE_Session', '__return_true', 999);
280 280
             EE_Registry::instance()->SSN = LoaderFactory::getShared('EE_Session');
@@ -333,14 +333,14 @@  discard block
 block discarded – undo
333 333
     {
334 334
         wp_enqueue_script(
335 335
             'thank_you_page',
336
-            THANK_YOU_ASSETS_URL . 'thank_you_page.js',
336
+            THANK_YOU_ASSETS_URL.'thank_you_page.js',
337 337
             array('espresso_core', 'heartbeat'),
338 338
             EVENT_ESPRESSO_VERSION,
339 339
             true
340 340
         );
341 341
         wp_enqueue_style(
342 342
             'thank_you_page_css',
343
-            THANK_YOU_ASSETS_URL . 'thank_you_page.css',
343
+            THANK_YOU_ASSETS_URL.'thank_you_page.css',
344 344
             ['espresso_default'],
345 345
             EVENT_ESPRESSO_VERSION
346 346
         );
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
     public function init()
358 358
     {
359 359
         $this->_get_reg_url_link();
360
-        if (! $this->get_txn()) {
360
+        if ( ! $this->get_txn()) {
361 361
             echo EEH_HTML::div(
362
-                EEH_HTML::h4(esc_html__('We\'re sorry...', 'event_espresso')) .
362
+                EEH_HTML::h4(esc_html__('We\'re sorry...', 'event_espresso')).
363 363
                 sprintf(
364 364
                     esc_html__(
365 365
                         'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
     public function thank_you_page_results()
451 451
     {
452 452
         $this->init();
453
-        if (! $this->_current_txn instanceof EE_Transaction) {
453
+        if ( ! $this->_current_txn instanceof EE_Transaction) {
454 454
             return EE_Error::get_notices();
455 455
         }
456 456
         // link to receipt
457 457
         $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url();
458
-        if (! empty($template_args['TXN_receipt_url'])) {
458
+        if ( ! empty($template_args['TXN_receipt_url'])) {
459 459
             $template_args['order_conf_desc'] = esc_html__(
460 460
                 '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.',
461 461
                 'event_espresso'
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
             add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
474 474
         }
475 475
         return EEH_Template::locate_template(
476
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
476
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-overview.template.php',
477 477
             $template_args
478 478
         );
479 479
     }
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
             '$SPCO_attendee_information_url'
524 524
         );
525 525
         echo EEH_Template::locate_template(
526
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
526
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-registration-details.template.php',
527 527
             $template_args
528 528
         );
529 529
     }
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
      */
596 596
     public function get_ajax_content()
597 597
     {
598
-        if (! $this->get_txn()) {
598
+        if ( ! $this->get_txn()) {
599 599
             return;
600 600
         }
601 601
         // first determine which event(s) require pre-approval or not
@@ -606,9 +606,9 @@  discard block
 block discarded – undo
606 606
                 $event = $registration->event();
607 607
                 if ($event instanceof EE_Event) {
608 608
                     if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) {
609
-                        $events_requiring_pre_approval[ $event->ID() ] = $event;
609
+                        $events_requiring_pre_approval[$event->ID()] = $event;
610 610
                     } else {
611
-                        $events[ $event->ID() ] = $event;
611
+                        $events[$event->ID()] = $event;
612 612
                     }
613 613
                 }
614 614
             }
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
      */
627 627
     public function display_details_for_events($events = array())
628 628
     {
629
-        if (! empty($events)) {
629
+        if ( ! empty($events)) {
630 630
             ?>
631 631
             <div id="espresso-thank-you-page-ajax-content-dv">
632 632
                 <div id="espresso-thank-you-page-ajax-transaction-dv"></div>
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
                                 'event_espresso'
640 640
                             ); ?></span>
641 641
                     </div>
642
-                    <?php if (! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?>
642
+                    <?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?>
643 643
                         <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear">
644 644
                             <?php echo apply_filters(
645 645
                                 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg',
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
      */
673 673
     public function display_details_for_events_requiring_pre_approval($events = array())
674 674
     {
675
-        if (! empty($events)) {
675
+        if ( ! empty($events)) {
676 676
             ?>
677 677
             <div id="espresso-thank-you-page-not-approved-message-dv">
678 678
                 <h4 class="orange-text"><?php esc_html_e('Important Notice:', 'event_espresso'); ?></h4>
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
             '$SPCO_payment_options_url'
734 734
         );
735 735
         return EEH_Template::locate_template(
736
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
736
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-transaction-details.template.php',
737 737
             $template_args
738 738
         );
739 739
     }
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
     public function get_payment_row_html(EE_Payment $payment = null)
750 750
     {
751 751
         $html = '';
752
-        if (! $payment instanceof EE_Payment) {
752
+        if ( ! $payment instanceof EE_Payment) {
753 753
             return '';
754 754
         }
755 755
         if (
@@ -763,25 +763,25 @@  discard block
 block discarded – undo
763 763
             $payment->set_status(EEM_Payment::status_id_pending);
764 764
         }
765 765
         $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
766
-            ? '<br /><span class="small-text">' . esc_html($payment->gateway_response()) . '</span>'
766
+            ? '<br /><span class="small-text">'.esc_html($payment->gateway_response()).'</span>'
767 767
             : '';
768 768
         $html .= '
769 769
             <tr>
770 770
                 <td>
771
-                    ' . esc_html($payment->timestamp()) . '
771
+                    ' . esc_html($payment->timestamp()).'
772 772
                 </td>
773 773
                 <td>
774 774
                     ' . (
775 775
             $payment->payment_method() instanceof EE_Payment_Method
776 776
                 ? esc_html($payment->payment_method()->name())
777 777
                 : esc_html__('Unknown', 'event_espresso')
778
-            ) . '
778
+            ).'
779 779
                 </td>
780 780
                 <td class="jst-rght">
781
-                    ' . EEH_Template::format_currency($payment->amount()) . '
781
+                    ' . EEH_Template::format_currency($payment->amount()).'
782 782
                 </td>
783 783
                 <td class="jst-rght" style="line-height:1;">
784
-                    ' . $payment->pretty_status(true) . $payment_declined_msg . '
784
+                    ' . $payment->pretty_status(true).$payment_declined_msg.'
785 785
                 </td>
786 786
             </tr>';
787 787
         do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
             '$SPCO_payment_options_url'
840 840
         );
841 841
         return EEH_Template::locate_template(
842
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
842
+            THANK_YOU_TEMPLATES_PATH.'thank-you-page-payment-details.template.php',
843 843
             $template_args
844 844
         );
845 845
     }
Please login to merge, or discard this patch.