Completed
Branch fix/kses-6 (dd7b82)
by
unknown
09:41 queued 07:30
created
caffeinated/modules/recaptcha_invisible/RecaptchaAdminSettings.php 1 patch
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -32,362 +32,362 @@
 block discarded – undo
32 32
 class RecaptchaAdminSettings
33 33
 {
34 34
 
35
-    /**
36
-     * @var EE_Registration_Config $config
37
-     */
38
-    private $config;
35
+	/**
36
+	 * @var EE_Registration_Config $config
37
+	 */
38
+	private $config;
39 39
 
40 40
 
41
-    /**
42
-     * RecaptchaAdminSettings constructor.
43
-     *
44
-     * @param EE_Registration_Config $registration_config
45
-     */
46
-    public function __construct(EE_Registration_Config $registration_config)
47
-    {
48
-        $this->config = $registration_config;
49
-    }
41
+	/**
42
+	 * RecaptchaAdminSettings constructor.
43
+	 *
44
+	 * @param EE_Registration_Config $registration_config
45
+	 */
46
+	public function __construct(EE_Registration_Config $registration_config)
47
+	{
48
+		$this->config = $registration_config;
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * @throws InvalidArgumentException
54
-     * @throws InvalidInterfaceException
55
-     * @throws InvalidDataTypeException
56
-     * @throws EE_Error
57
-     */
58
-    public function adminSettings()
59
-    {
60
-        echo wp_kses($this->settingsForm()->get_html_and_js(), AllowedTags::getWithFormTags());
61
-    }
52
+	/**
53
+	 * @throws InvalidArgumentException
54
+	 * @throws InvalidInterfaceException
55
+	 * @throws InvalidDataTypeException
56
+	 * @throws EE_Error
57
+	 */
58
+	public function adminSettings()
59
+	{
60
+		echo wp_kses($this->settingsForm()->get_html_and_js(), AllowedTags::getWithFormTags());
61
+	}
62 62
 
63 63
 
64
-    /**
65
-     * @return EE_Form_Section_Proper
66
-     * @throws EE_Error
67
-     */
68
-    protected function settingsForm()
69
-    {
70
-        return new EE_Form_Section_Proper(
71
-            array(
72
-                'name'            => 'recaptcha_settings_form',
73
-                'html_id'         => 'recaptcha_settings_form',
74
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
75
-                'subsections'     => apply_filters(
76
-                    'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections',
77
-                    array(
78
-                        'main_settings_hdr'       => new EE_Form_Section_HTML(
79
-                            EEH_HTML::h2(
80
-                                esc_html__('reCAPTCHA Anti-spam Settings', 'event_espresso')
81
-                                . EEH_Template::get_help_tab_link('recaptcha_info')
82
-                            )
83
-                        ),
84
-                        'main_settings'           => $this->mainSettings(),
85
-                        'appearance_settings_hdr' => new EE_Form_Section_HTML(
86
-                            EEH_HTML::h2(esc_html__('reCAPTCHA Appearance', 'event_espresso'))
87
-                        ),
88
-                        'appearance_settings'     => $this->appearanceSettings(),
89
-                        'required_fields_note'    => new EE_Form_Section_HTML(
90
-                            EEH_HTML::p(
91
-                                esc_html__('All fields marked with a * are required fields', 'event_espresso'),
92
-                                '',
93
-                                'grey-text'
94
-                            )
95
-                        ),
96
-                    )
97
-                ),
98
-            )
99
-        );
100
-    }
64
+	/**
65
+	 * @return EE_Form_Section_Proper
66
+	 * @throws EE_Error
67
+	 */
68
+	protected function settingsForm()
69
+	{
70
+		return new EE_Form_Section_Proper(
71
+			array(
72
+				'name'            => 'recaptcha_settings_form',
73
+				'html_id'         => 'recaptcha_settings_form',
74
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
75
+				'subsections'     => apply_filters(
76
+					'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections',
77
+					array(
78
+						'main_settings_hdr'       => new EE_Form_Section_HTML(
79
+							EEH_HTML::h2(
80
+								esc_html__('reCAPTCHA Anti-spam Settings', 'event_espresso')
81
+								. EEH_Template::get_help_tab_link('recaptcha_info')
82
+							)
83
+						),
84
+						'main_settings'           => $this->mainSettings(),
85
+						'appearance_settings_hdr' => new EE_Form_Section_HTML(
86
+							EEH_HTML::h2(esc_html__('reCAPTCHA Appearance', 'event_espresso'))
87
+						),
88
+						'appearance_settings'     => $this->appearanceSettings(),
89
+						'required_fields_note'    => new EE_Form_Section_HTML(
90
+							EEH_HTML::p(
91
+								esc_html__('All fields marked with a * are required fields', 'event_espresso'),
92
+								'',
93
+								'grey-text'
94
+							)
95
+						),
96
+					)
97
+				),
98
+			)
99
+		);
100
+	}
101 101
 
102 102
 
103
-    /**
104
-     * @return EE_Form_Section_Proper
105
-     * @throws EE_Error
106
-     */
107
-    protected function mainSettings()
108
-    {
109
-        return new EE_Form_Section_Proper(
110
-            array(
111
-                'name'            => 'recaptcha_settings_tbl',
112
-                'html_id'         => 'recaptcha_settings_tbl',
113
-                'html_class'      => 'form-table',
114
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
115
-                'subsections'     => apply_filters(
116
-                    'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections',
117
-                    array(
118
-                        'use_captcha'          => new EE_Yes_No_Input(
119
-                            array(
120
-                                'html_label_text'         => esc_html__('Use reCAPTCHA', 'event_espresso'),
121
-                                'html_help_text'          => sprintf(
122
-                                    esc_html__(
123
-                                        'reCAPTCHA is a free service that  protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.',
124
-                                        'event_espresso'
125
-                                    ),
126
-                                    '<a href="https://www.google.com/recaptcha/intro/index.html">',
127
-                                    '</a>'
128
-                                ),
129
-                                'default'                 => $this->config->use_captcha !== null
130
-                                    ? $this->config->use_captcha : false,
131
-                                'display_html_label_text' => false,
132
-                            )
133
-                        ),
134
-                        'recaptcha_publickey'  => new EE_Text_Input(
135
-                            array(
136
-                                'html_label_text' => esc_html__('Site Key', 'event_espresso'),
137
-                                'html_help_text'  => esc_html__(
138
-                                    'The site key is used to display the widget on your site.',
139
-                                    'event_espresso'
140
-                                ),
141
-                                'default'         => $this->config->recaptcha_publickey !== null
142
-                                    ? stripslashes($this->config->recaptcha_publickey) : '',
143
-                            )
144
-                        ),
145
-                        'recaptcha_privatekey' => new EE_Text_Input(
146
-                            array(
147
-                                'html_label_text' => esc_html__('Secret Key', 'event_espresso'),
148
-                                'html_help_text'  => esc_html__(
149
-                                    'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.',
150
-                                    'event_espresso'
151
-                                ),
152
-                                'default'         => $this->config->recaptcha_privatekey !== null
153
-                                    ? stripslashes($this->config->recaptcha_privatekey)
154
-                                    : '',
155
-                            )
156
-                        ),
157
-                        'recaptcha_protected_forms' => new EE_Checkbox_Multi_Input(
158
-                            array(
159
-                                'ticket_selector'   => esc_html__('Ticket Selector', 'event_espresso'),
160
-                                'registration_form' => esc_html__('Registration Form', 'event_espresso'),
161
-                            ),
162
-                            array(
163
-                                'html_label_text'         => esc_html__(
164
-                                    'Invisible reCAPTCHA Protection',
165
-                                    'event_espresso'
166
-                                ),
167
-                                'html_help_text'          => esc_html__(
168
-                                    'Select which Event Espresso forms you would like to enable Invisible reCAPTCHA on.',
169
-                                    'event_espresso'
170
-                                ),
171
-                                'default'                 => is_array($this->config->recaptcha_protected_forms)
172
-                                    ? $this->config->recaptcha_protected_forms
173
-                                    : array(),
174
-                                'display_html_label_text' => false,
175
-                            )
176
-                        ),
177
-                    )
178
-                ),
179
-            )
180
-        );
181
-    }
103
+	/**
104
+	 * @return EE_Form_Section_Proper
105
+	 * @throws EE_Error
106
+	 */
107
+	protected function mainSettings()
108
+	{
109
+		return new EE_Form_Section_Proper(
110
+			array(
111
+				'name'            => 'recaptcha_settings_tbl',
112
+				'html_id'         => 'recaptcha_settings_tbl',
113
+				'html_class'      => 'form-table',
114
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
115
+				'subsections'     => apply_filters(
116
+					'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections',
117
+					array(
118
+						'use_captcha'          => new EE_Yes_No_Input(
119
+							array(
120
+								'html_label_text'         => esc_html__('Use reCAPTCHA', 'event_espresso'),
121
+								'html_help_text'          => sprintf(
122
+									esc_html__(
123
+										'reCAPTCHA is a free service that  protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.',
124
+										'event_espresso'
125
+									),
126
+									'<a href="https://www.google.com/recaptcha/intro/index.html">',
127
+									'</a>'
128
+								),
129
+								'default'                 => $this->config->use_captcha !== null
130
+									? $this->config->use_captcha : false,
131
+								'display_html_label_text' => false,
132
+							)
133
+						),
134
+						'recaptcha_publickey'  => new EE_Text_Input(
135
+							array(
136
+								'html_label_text' => esc_html__('Site Key', 'event_espresso'),
137
+								'html_help_text'  => esc_html__(
138
+									'The site key is used to display the widget on your site.',
139
+									'event_espresso'
140
+								),
141
+								'default'         => $this->config->recaptcha_publickey !== null
142
+									? stripslashes($this->config->recaptcha_publickey) : '',
143
+							)
144
+						),
145
+						'recaptcha_privatekey' => new EE_Text_Input(
146
+							array(
147
+								'html_label_text' => esc_html__('Secret Key', 'event_espresso'),
148
+								'html_help_text'  => esc_html__(
149
+									'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.',
150
+									'event_espresso'
151
+								),
152
+								'default'         => $this->config->recaptcha_privatekey !== null
153
+									? stripslashes($this->config->recaptcha_privatekey)
154
+									: '',
155
+							)
156
+						),
157
+						'recaptcha_protected_forms' => new EE_Checkbox_Multi_Input(
158
+							array(
159
+								'ticket_selector'   => esc_html__('Ticket Selector', 'event_espresso'),
160
+								'registration_form' => esc_html__('Registration Form', 'event_espresso'),
161
+							),
162
+							array(
163
+								'html_label_text'         => esc_html__(
164
+									'Invisible reCAPTCHA Protection',
165
+									'event_espresso'
166
+								),
167
+								'html_help_text'          => esc_html__(
168
+									'Select which Event Espresso forms you would like to enable Invisible reCAPTCHA on.',
169
+									'event_espresso'
170
+								),
171
+								'default'                 => is_array($this->config->recaptcha_protected_forms)
172
+									? $this->config->recaptcha_protected_forms
173
+									: array(),
174
+								'display_html_label_text' => false,
175
+							)
176
+						),
177
+					)
178
+				),
179
+			)
180
+		);
181
+	}
182 182
 
183 183
 
184
-    /**
185
-     * @return EE_Form_Section_Proper
186
-     * @throws EE_Error
187
-     */
188
-    protected function appearanceSettings()
189
-    {
190
-        return new EE_Form_Section_Proper(
191
-            array(
192
-                'name'            => 'recaptcha_appearance_settings_tbl',
193
-                'html_id'         => 'recaptcha_appearance_settings_tbl',
194
-                'html_class'      => 'form-table',
195
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
196
-                'subsections'     => apply_filters(
197
-                    'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections',
198
-                    array(
199
-                        'recaptcha_theme'    => new EE_Radio_Button_Input(
200
-                            array(
201
-                                'invisible' => esc_html__('Invisible', 'event_espresso'),
202
-                                'light'     => esc_html__('Light', 'event_espresso'),
203
-                                'dark'      => esc_html__('Dark', 'event_espresso'),
204
-                            ),
205
-                            array(
206
-                                'html_label_text'         => esc_html__('Theme', 'event_espresso'),
207
-                                'html_help_text'          => esc_html__(
208
-                                    'The color theme of the widget.',
209
-                                    'event_espresso'
210
-                                ),
211
-                                'default'                 => $this->config->recaptcha_theme !== null
212
-                                    ? $this->config->recaptcha_theme
213
-                                    : 'invisible',
214
-                                'display_html_label_text' => false,
215
-                            )
216
-                        ),
217
-                        'recaptcha_badge'     => new EE_Radio_Button_Input(
218
-                            array(
219
-                                'bottomleft' => esc_html__('Bottom Left', 'event_espresso'),
220
-                                'bottomright' => esc_html__('Bottom Right', 'event_espresso'),
221
-                                'inline' => esc_html__('Inline', 'event_espresso'),
222
-                            ),
223
-                            array(
224
-                                'html_label_text'         => esc_html__(
225
-                                    'Invisible reCAPTCHA Badge Position',
226
-                                    'event_espresso'
227
-                                ),
228
-                                'html_help_text'          => esc_html__(
229
-                                    'If using Invisible reCAPTCHA, then this determines the position of the reCAPTCHA badge. "Bottom Left" and "Bottom Right" both will float at the bottom of the screen. "Inline" appears beside the submit button but allows you to control the CSS.',
230
-                                    'event_espresso'
231
-                                ),
232
-                                'default'                 => $this->config->recaptcha_badge !== null
233
-                                    ? $this->config->recaptcha_badge
234
-                                    : 'bottomleft',
235
-                                'display_html_label_text' => false,
236
-                            )
237
-                        ),
238
-                        'recaptcha_type'     => new EE_Radio_Button_Input(
239
-                            array(
240
-                                'image' => esc_html__('Image', 'event_espresso'),
241
-                                'audio' => esc_html__('Audio', 'event_espresso'),
242
-                            ),
243
-                            array(
244
-                                'html_label_text'         => esc_html__('Type', 'event_espresso'),
245
-                                'html_help_text'          => esc_html__(
246
-                                    'The type of CAPTCHA to serve.',
247
-                                    'event_espresso'
248
-                                ),
249
-                                'default'                 => $this->config->recaptcha_type !== null
250
-                                    ? $this->config->recaptcha_type
251
-                                    : 'image',
252
-                                'display_html_label_text' => false,
253
-                            )
254
-                        ),
255
-                        'recaptcha_language' => new EE_Select_Input(
256
-                            array(
257
-                                'ar'     => esc_html__('Arabic', 'event_espresso'),
258
-                                'bg'     => esc_html__('Bulgarian', 'event_espresso'),
259
-                                'ca'     => esc_html__('Catalan', 'event_espresso'),
260
-                                'zh-CN'  => esc_html__('Chinese (Simplified)', 'event_espresso'),
261
-                                'zh-TW'  => esc_html__('Chinese (Traditional)	', 'event_espresso'),
262
-                                'hr'     => esc_html__('Croatian', 'event_espresso'),
263
-                                'cs'     => esc_html__('Czech', 'event_espresso'),
264
-                                'da'     => esc_html__('Danish', 'event_espresso'),
265
-                                'nl'     => esc_html__('Dutch', 'event_espresso'),
266
-                                'en-GB'  => esc_html__('English (UK)', 'event_espresso'),
267
-                                'en'     => esc_html__('English (US)', 'event_espresso'),
268
-                                'fil'    => esc_html__('Filipino', 'event_espresso'),
269
-                                'fi'     => esc_html__('Finnish', 'event_espresso'),
270
-                                'fr'     => esc_html__('French', 'event_espresso'),
271
-                                'fr-CA'  => esc_html__('French (Canadian)', 'event_espresso'),
272
-                                'de'     => esc_html__('German', 'event_espresso'),
273
-                                'de-AT'  => esc_html__('German (Austria)', 'event_espresso'),
274
-                                'de-CH'  => esc_html__('German (Switzerland)', 'event_espresso'),
275
-                                'el'     => esc_html__('Greek', 'event_espresso'),
276
-                                'iw'     => esc_html__('Hebrew', 'event_espresso'),
277
-                                'hi'     => esc_html__('Hindi', 'event_espresso'),
278
-                                'hu'     => esc_html__('Hungarian', 'event_espresso'),
279
-                                'id'     => esc_html__('Indonesian', 'event_espresso'),
280
-                                'it'     => esc_html__('Italian', 'event_espresso'),
281
-                                'ja'     => esc_html__('Japanese', 'event_espresso'),
282
-                                'ko'     => esc_html__('Korean', 'event_espresso'),
283
-                                'lv'     => esc_html__('Latvian', 'event_espresso'),
284
-                                'lt'     => esc_html__('Lithuanian', 'event_espresso'),
285
-                                'no'     => esc_html__('Norwegian', 'event_espresso'),
286
-                                'fa'     => esc_html__('Persian', 'event_espresso'),
287
-                                'pl'     => esc_html__('Polish', 'event_espresso'),
288
-                                'pt'     => esc_html__('Portuguese', 'event_espresso'),
289
-                                'pt-BR'  => esc_html__('Portuguese (Brazil)', 'event_espresso'),
290
-                                'pt-PT'  => esc_html__('Portuguese (Portugal)', 'event_espresso'),
291
-                                'ro'     => esc_html__('Romanian', 'event_espresso'),
292
-                                'ru'     => esc_html__('Russian', 'event_espresso'),
293
-                                'sr'     => esc_html__('Serbian', 'event_espresso'),
294
-                                'sk'     => esc_html__('Slovak', 'event_espresso'),
295
-                                'sl'     => esc_html__('Slovenian', 'event_espresso'),
296
-                                'es'     => esc_html__('Spanish', 'event_espresso'),
297
-                                'es-419' => esc_html__('Spanish (Latin America)', 'event_espresso'),
298
-                                'sv'     => esc_html__('Swedish', 'event_espresso'),
299
-                                'th'     => esc_html__('Thai', 'event_espresso'),
300
-                                'tr'     => esc_html__('Turkish', 'event_espresso'),
301
-                                'uk'     => esc_html__('Ukrainian', 'event_espresso'),
302
-                                'vi'     => esc_html__('Vietnamese', 'event_espresso'),
303
-                            ),
304
-                            array(
305
-                                'html_label_text' => esc_html__('Language', 'event_espresso'),
306
-                                'html_help_text'  => esc_html__(
307
-                                    'Forces the widget to render in a specific language.',
308
-                                    'event_espresso'
309
-                                ),
310
-                                'default'         => $this->config->recaptcha_language !== null
311
-                                    ? $this->config->recaptcha_language : 'en',
312
-                            )
313
-                        ),
314
-                    )
315
-                ),
316
-            )
317
-        );
318
-    }
184
+	/**
185
+	 * @return EE_Form_Section_Proper
186
+	 * @throws EE_Error
187
+	 */
188
+	protected function appearanceSettings()
189
+	{
190
+		return new EE_Form_Section_Proper(
191
+			array(
192
+				'name'            => 'recaptcha_appearance_settings_tbl',
193
+				'html_id'         => 'recaptcha_appearance_settings_tbl',
194
+				'html_class'      => 'form-table',
195
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
196
+				'subsections'     => apply_filters(
197
+					'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections',
198
+					array(
199
+						'recaptcha_theme'    => new EE_Radio_Button_Input(
200
+							array(
201
+								'invisible' => esc_html__('Invisible', 'event_espresso'),
202
+								'light'     => esc_html__('Light', 'event_espresso'),
203
+								'dark'      => esc_html__('Dark', 'event_espresso'),
204
+							),
205
+							array(
206
+								'html_label_text'         => esc_html__('Theme', 'event_espresso'),
207
+								'html_help_text'          => esc_html__(
208
+									'The color theme of the widget.',
209
+									'event_espresso'
210
+								),
211
+								'default'                 => $this->config->recaptcha_theme !== null
212
+									? $this->config->recaptcha_theme
213
+									: 'invisible',
214
+								'display_html_label_text' => false,
215
+							)
216
+						),
217
+						'recaptcha_badge'     => new EE_Radio_Button_Input(
218
+							array(
219
+								'bottomleft' => esc_html__('Bottom Left', 'event_espresso'),
220
+								'bottomright' => esc_html__('Bottom Right', 'event_espresso'),
221
+								'inline' => esc_html__('Inline', 'event_espresso'),
222
+							),
223
+							array(
224
+								'html_label_text'         => esc_html__(
225
+									'Invisible reCAPTCHA Badge Position',
226
+									'event_espresso'
227
+								),
228
+								'html_help_text'          => esc_html__(
229
+									'If using Invisible reCAPTCHA, then this determines the position of the reCAPTCHA badge. "Bottom Left" and "Bottom Right" both will float at the bottom of the screen. "Inline" appears beside the submit button but allows you to control the CSS.',
230
+									'event_espresso'
231
+								),
232
+								'default'                 => $this->config->recaptcha_badge !== null
233
+									? $this->config->recaptcha_badge
234
+									: 'bottomleft',
235
+								'display_html_label_text' => false,
236
+							)
237
+						),
238
+						'recaptcha_type'     => new EE_Radio_Button_Input(
239
+							array(
240
+								'image' => esc_html__('Image', 'event_espresso'),
241
+								'audio' => esc_html__('Audio', 'event_espresso'),
242
+							),
243
+							array(
244
+								'html_label_text'         => esc_html__('Type', 'event_espresso'),
245
+								'html_help_text'          => esc_html__(
246
+									'The type of CAPTCHA to serve.',
247
+									'event_espresso'
248
+								),
249
+								'default'                 => $this->config->recaptcha_type !== null
250
+									? $this->config->recaptcha_type
251
+									: 'image',
252
+								'display_html_label_text' => false,
253
+							)
254
+						),
255
+						'recaptcha_language' => new EE_Select_Input(
256
+							array(
257
+								'ar'     => esc_html__('Arabic', 'event_espresso'),
258
+								'bg'     => esc_html__('Bulgarian', 'event_espresso'),
259
+								'ca'     => esc_html__('Catalan', 'event_espresso'),
260
+								'zh-CN'  => esc_html__('Chinese (Simplified)', 'event_espresso'),
261
+								'zh-TW'  => esc_html__('Chinese (Traditional)	', 'event_espresso'),
262
+								'hr'     => esc_html__('Croatian', 'event_espresso'),
263
+								'cs'     => esc_html__('Czech', 'event_espresso'),
264
+								'da'     => esc_html__('Danish', 'event_espresso'),
265
+								'nl'     => esc_html__('Dutch', 'event_espresso'),
266
+								'en-GB'  => esc_html__('English (UK)', 'event_espresso'),
267
+								'en'     => esc_html__('English (US)', 'event_espresso'),
268
+								'fil'    => esc_html__('Filipino', 'event_espresso'),
269
+								'fi'     => esc_html__('Finnish', 'event_espresso'),
270
+								'fr'     => esc_html__('French', 'event_espresso'),
271
+								'fr-CA'  => esc_html__('French (Canadian)', 'event_espresso'),
272
+								'de'     => esc_html__('German', 'event_espresso'),
273
+								'de-AT'  => esc_html__('German (Austria)', 'event_espresso'),
274
+								'de-CH'  => esc_html__('German (Switzerland)', 'event_espresso'),
275
+								'el'     => esc_html__('Greek', 'event_espresso'),
276
+								'iw'     => esc_html__('Hebrew', 'event_espresso'),
277
+								'hi'     => esc_html__('Hindi', 'event_espresso'),
278
+								'hu'     => esc_html__('Hungarian', 'event_espresso'),
279
+								'id'     => esc_html__('Indonesian', 'event_espresso'),
280
+								'it'     => esc_html__('Italian', 'event_espresso'),
281
+								'ja'     => esc_html__('Japanese', 'event_espresso'),
282
+								'ko'     => esc_html__('Korean', 'event_espresso'),
283
+								'lv'     => esc_html__('Latvian', 'event_espresso'),
284
+								'lt'     => esc_html__('Lithuanian', 'event_espresso'),
285
+								'no'     => esc_html__('Norwegian', 'event_espresso'),
286
+								'fa'     => esc_html__('Persian', 'event_espresso'),
287
+								'pl'     => esc_html__('Polish', 'event_espresso'),
288
+								'pt'     => esc_html__('Portuguese', 'event_espresso'),
289
+								'pt-BR'  => esc_html__('Portuguese (Brazil)', 'event_espresso'),
290
+								'pt-PT'  => esc_html__('Portuguese (Portugal)', 'event_espresso'),
291
+								'ro'     => esc_html__('Romanian', 'event_espresso'),
292
+								'ru'     => esc_html__('Russian', 'event_espresso'),
293
+								'sr'     => esc_html__('Serbian', 'event_espresso'),
294
+								'sk'     => esc_html__('Slovak', 'event_espresso'),
295
+								'sl'     => esc_html__('Slovenian', 'event_espresso'),
296
+								'es'     => esc_html__('Spanish', 'event_espresso'),
297
+								'es-419' => esc_html__('Spanish (Latin America)', 'event_espresso'),
298
+								'sv'     => esc_html__('Swedish', 'event_espresso'),
299
+								'th'     => esc_html__('Thai', 'event_espresso'),
300
+								'tr'     => esc_html__('Turkish', 'event_espresso'),
301
+								'uk'     => esc_html__('Ukrainian', 'event_espresso'),
302
+								'vi'     => esc_html__('Vietnamese', 'event_espresso'),
303
+							),
304
+							array(
305
+								'html_label_text' => esc_html__('Language', 'event_espresso'),
306
+								'html_help_text'  => esc_html__(
307
+									'Forces the widget to render in a specific language.',
308
+									'event_espresso'
309
+								),
310
+								'default'         => $this->config->recaptcha_language !== null
311
+									? $this->config->recaptcha_language : 'en',
312
+							)
313
+						),
314
+					)
315
+				),
316
+			)
317
+		);
318
+	}
319 319
 
320 320
 
321
-    /**
322
-     * @param EE_Registration_Config $EE_Registration_Config
323
-     * @return EE_Registration_Config
324
-     * @throws InvalidArgumentException
325
-     * @throws InvalidInterfaceException
326
-     * @throws InvalidDataTypeException
327
-     * @throws EE_Error
328
-     * @throws ReflectionException
329
-     */
330
-    public function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
331
-    {
332
-        try {
333
-            $recaptcha_settings_form = $this->settingsForm();
334
-            // if not displaying a form, then check for form submission
335
-            if ($recaptcha_settings_form->was_submitted()) {
336
-                // capture form data
337
-                $recaptcha_settings_form->receive_form_submission();
338
-                // validate form data
339
-                if ($recaptcha_settings_form->is_valid()) {
340
-                    // grab validated data from form
341
-                    $valid_data = $recaptcha_settings_form->valid_data();
342
-                    // user proofing recaptcha:  If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message.
343
-                    if (
344
-                        $valid_data['main_settings']['use_captcha']
345
-                        && (
346
-                            ! $EE_Registration_Config->use_captcha
347
-                            && (
348
-                                empty($valid_data['main_settings']['recaptcha_publickey'])
349
-                                || empty($valid_data['main_settings']['recaptcha_privatekey'])
350
-                            )
351
-                        )
352
-                        && apply_filters(
353
-                            'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys',
354
-                            true,
355
-                            $EE_Registration_Config
356
-                        )
357
-                    ) {
358
-                        $valid_data['main_settings']['use_captcha'] = false;
359
-                        EE_Error::add_error(
360
-                            esc_html__(
361
-                                'The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.',
362
-                                'event_espresso'
363
-                            ),
364
-                            __FILE__,
365
-                            __FUNCTION__,
366
-                            __LINE__
367
-                        );
368
-                    }
369
-                    $EE_Registration_Config->use_captcha          = $valid_data['main_settings']['use_captcha'];
370
-                    $EE_Registration_Config->recaptcha_publickey  = $valid_data['main_settings']['recaptcha_publickey'];
371
-                    $EE_Registration_Config->recaptcha_protected_forms = $valid_data['main_settings']['recaptcha_protected_forms'];
372
-                    $EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey'];
373
-                    $EE_Registration_Config->recaptcha_type       = $valid_data['appearance_settings']['recaptcha_type'];
374
-                    $EE_Registration_Config->recaptcha_theme      = $valid_data['appearance_settings']['recaptcha_theme'];
375
-                    $EE_Registration_Config->recaptcha_badge      = $valid_data['appearance_settings']['recaptcha_badge'];
376
-                    $EE_Registration_Config->recaptcha_language   = $valid_data['appearance_settings']['recaptcha_language'];
377
-                } else {
378
-                    if ($recaptcha_settings_form->submission_error_message() !== '') {
379
-                        EE_Error::add_error(
380
-                            $recaptcha_settings_form->submission_error_message(),
381
-                            __FILE__,
382
-                            __FUNCTION__,
383
-                            __LINE__
384
-                        );
385
-                    }
386
-                }
387
-            }
388
-        } catch (EE_Error $e) {
389
-            $e->get_error();
390
-        }
391
-        return $EE_Registration_Config;
392
-    }
321
+	/**
322
+	 * @param EE_Registration_Config $EE_Registration_Config
323
+	 * @return EE_Registration_Config
324
+	 * @throws InvalidArgumentException
325
+	 * @throws InvalidInterfaceException
326
+	 * @throws InvalidDataTypeException
327
+	 * @throws EE_Error
328
+	 * @throws ReflectionException
329
+	 */
330
+	public function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
331
+	{
332
+		try {
333
+			$recaptcha_settings_form = $this->settingsForm();
334
+			// if not displaying a form, then check for form submission
335
+			if ($recaptcha_settings_form->was_submitted()) {
336
+				// capture form data
337
+				$recaptcha_settings_form->receive_form_submission();
338
+				// validate form data
339
+				if ($recaptcha_settings_form->is_valid()) {
340
+					// grab validated data from form
341
+					$valid_data = $recaptcha_settings_form->valid_data();
342
+					// user proofing recaptcha:  If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message.
343
+					if (
344
+						$valid_data['main_settings']['use_captcha']
345
+						&& (
346
+							! $EE_Registration_Config->use_captcha
347
+							&& (
348
+								empty($valid_data['main_settings']['recaptcha_publickey'])
349
+								|| empty($valid_data['main_settings']['recaptcha_privatekey'])
350
+							)
351
+						)
352
+						&& apply_filters(
353
+							'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys',
354
+							true,
355
+							$EE_Registration_Config
356
+						)
357
+					) {
358
+						$valid_data['main_settings']['use_captcha'] = false;
359
+						EE_Error::add_error(
360
+							esc_html__(
361
+								'The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.',
362
+								'event_espresso'
363
+							),
364
+							__FILE__,
365
+							__FUNCTION__,
366
+							__LINE__
367
+						);
368
+					}
369
+					$EE_Registration_Config->use_captcha          = $valid_data['main_settings']['use_captcha'];
370
+					$EE_Registration_Config->recaptcha_publickey  = $valid_data['main_settings']['recaptcha_publickey'];
371
+					$EE_Registration_Config->recaptcha_protected_forms = $valid_data['main_settings']['recaptcha_protected_forms'];
372
+					$EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey'];
373
+					$EE_Registration_Config->recaptcha_type       = $valid_data['appearance_settings']['recaptcha_type'];
374
+					$EE_Registration_Config->recaptcha_theme      = $valid_data['appearance_settings']['recaptcha_theme'];
375
+					$EE_Registration_Config->recaptcha_badge      = $valid_data['appearance_settings']['recaptcha_badge'];
376
+					$EE_Registration_Config->recaptcha_language   = $valid_data['appearance_settings']['recaptcha_language'];
377
+				} else {
378
+					if ($recaptcha_settings_form->submission_error_message() !== '') {
379
+						EE_Error::add_error(
380
+							$recaptcha_settings_form->submission_error_message(),
381
+							__FILE__,
382
+							__FUNCTION__,
383
+							__LINE__
384
+						);
385
+					}
386
+				}
387
+			}
388
+		} catch (EE_Error $e) {
389
+			$e->get_error();
390
+		}
391
+		return $EE_Registration_Config;
392
+	}
393 393
 }
Please login to merge, or discard this patch.
event_single_caff/templates/admin-event-single-settings.template.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -4,10 +4,10 @@  discard block
 block discarded – undo
4 4
 
5 5
 add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
6 6
 $values = EEH_Form_Fields::prep_answer_options(
7
-    array(
8
-        array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')),
9
-        array('id' => 0, 'text' => esc_html__('No', 'event_espresso')),
10
-    )
7
+	array(
8
+		array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')),
9
+		array('id' => 0, 'text' => esc_html__('No', 'event_espresso')),
10
+	)
11 11
 );
12 12
 ?>
13 13
 
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 
16 16
 <h2 class="ee-admin-settings-hdr">
17 17
     <?php esc_html_e(
18
-        'Single Event Pages',
19
-        'event_espresso'
20
-    ); ?><?php // echo EEH_Template::get_help_tab_link('event_single_settings_info');?>
18
+		'Single Event Pages',
19
+		'event_espresso'
20
+	); ?><?php // echo EEH_Template::get_help_tab_link('event_single_settings_info');?>
21 21
 </h2>
22 22
 <table class="form-table">
23 23
     <tbody>
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
         </th>
30 30
         <td>
31 31
             <?php echo EEH_Form_Fields::select(
32
-                'display_status_banner_single',
33
-                $display_status_banner_single,
34
-                $values,
35
-                'display_status_banner_single',
36
-                'display_status_banner_single'
37
-            ); ?>
32
+				'display_status_banner_single',
33
+				$display_status_banner_single,
34
+				$values,
35
+				'display_status_banner_single',
36
+				'display_status_banner_single'
37
+			); ?>
38 38
             <p class="description"><?php
39
-                esc_html_e(
40
-                    'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.',
41
-                    'event_espresso'
42
-                ); ?></p>
39
+				esc_html_e(
40
+					'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.',
41
+					'event_espresso'
42
+				); ?></p>
43 43
         </td>
44 44
     </tr>
45 45
 
@@ -47,23 +47,23 @@  discard block
 block discarded – undo
47 47
         <th>
48 48
             <label for="display_venue">
49 49
                 <?php esc_html_e('Display Venue Details', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
50
-                    'display_addresses_in_reg_form_info'
51
-                ); ?>
50
+					'display_addresses_in_reg_form_info'
51
+				); ?>
52 52
             </label>
53 53
         </th>
54 54
         <td>
55 55
             <?php echo EEH_Form_Fields::select(
56
-                'display_venue',
57
-                $display_venue,
58
-                $values,
59
-                'display_venue',
60
-                'display_venue'
61
-            ); ?>
56
+				'display_venue',
57
+				$display_venue,
58
+				$values,
59
+				'display_venue',
60
+				'display_venue'
61
+			); ?>
62 62
             <p class="description"><?php
63
-                esc_html_e(
64
-                    'Do not use this if you are using the venue shortcodes in your event description.',
65
-                    'event_espresso'
66
-                ); ?></p>
63
+				esc_html_e(
64
+					'Do not use this if you are using the venue shortcodes in your event description.',
65
+					'event_espresso'
66
+				); ?></p>
67 67
         </td>
68 68
     </tr>
69 69
 
@@ -75,37 +75,37 @@  discard block
 block discarded – undo
75 75
         </th>
76 76
         <td>
77 77
             <?php
78
-            echo EEH_Form_Fields::select(
79
-                'use_sortable_display_order',
80
-                $use_sortable_display_order,
81
-                $values,
82
-                'EED_Events_Single_use_sortable_display_order',
83
-                'EED_Events_Single_use_sortable_display_order'
84
-            );
85
-            ?>
78
+			echo EEH_Form_Fields::select(
79
+				'use_sortable_display_order',
80
+				$use_sortable_display_order,
81
+				$values,
82
+				'EED_Events_Single_use_sortable_display_order',
83
+				'EED_Events_Single_use_sortable_display_order'
84
+			);
85
+			?>
86 86
         </td>
87 87
     </tr>
88 88
 
89 89
     <tr>
90 90
         <th>
91 91
             <?php esc_html_e('Display Order', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
92
-                'display_addresses_in_reg_form_info'
93
-            ); ?>
92
+				'display_addresses_in_reg_form_info'
93
+			); ?>
94 94
         </th>
95 95
         <td>
96 96
 
97 97
             <?php wp_nonce_field(
98
-                'espresso_update_event_single_order',
99
-                'espresso_update_event_single_order_nonce',
100
-                false
101
-            ); ?>
98
+				'espresso_update_event_single_order',
99
+				'espresso_update_event_single_order_nonce',
100
+				false
101
+			); ?>
102 102
             <?php echo wp_kses($event_single_display_order, AllowedTags::getWithFormTags()); ?>
103 103
 
104 104
             <p class="description"><?php
105
-                esc_html_e(
106
-                    'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.',
107
-                    'event_espresso'
108
-                ); ?></p>
105
+				esc_html_e(
106
+					'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.',
107
+					'event_espresso'
108
+				); ?></p>
109 109
 
110 110
         </td>
111 111
     </tr>
Please login to merge, or discard this patch.
events_archive_caff/templates/admin-event-list-settings.template.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -5,18 +5,18 @@  discard block
 block discarded – undo
5 5
 add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
6 6
 
7 7
 $values = EEH_Form_Fields::prep_answer_options(
8
-    array(
9
-        array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')),
10
-        array('id' => 0, 'text' => esc_html__('No', 'event_espresso')),
11
-    )
8
+	array(
9
+		array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')),
10
+		array('id' => 0, 'text' => esc_html__('No', 'event_espresso')),
11
+	)
12 12
 );
13 13
 
14 14
 $description = EEH_Form_Fields::prep_answer_options(
15
-    array(
16
-        array('id' => 0, 'text' => esc_html__('none', 'event_espresso')),
17
-        array('id' => 1, 'text' => esc_html__('excerpt (short desc)', 'event_espresso')),
18
-        array('id' => 2, 'text' => esc_html__('full description', 'event_espresso')),
19
-    )
15
+	array(
16
+		array('id' => 0, 'text' => esc_html__('none', 'event_espresso')),
17
+		array('id' => 1, 'text' => esc_html__('excerpt (short desc)', 'event_espresso')),
18
+		array('id' => 2, 'text' => esc_html__('full description', 'event_espresso')),
19
+	)
20 20
 );
21 21
 
22 22
 ?>
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
         <th>
36 36
             <label for="event_listings_url">
37 37
                 <?php esc_html_e('Event Listings URL', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
38
-                    'event_listings_url_info'
39
-                ); ?>
38
+					'event_listings_url_info'
39
+				); ?>
40 40
             </label>
41 41
         </th>
42 42
         <td>
43 43
             <a id="event_listings_url" class="ee-admin-settings-hdr-lnk small-text"
44 44
                href="<?php echo EEH_Event_View::event_archive_url(); ?>"><?php
45
-                echo EEH_Event_View::event_archive_url(); ?></a>
45
+				echo EEH_Event_View::event_archive_url(); ?></a>
46 46
         </td>
47 47
     </tr>
48 48
 
@@ -54,30 +54,30 @@  discard block
 block discarded – undo
54 54
         </th>
55 55
         <td>
56 56
             <p><?php echo site_url() . '/ '
57
-                          . EEH_Form_Fields::text(
58
-                              'not_used',
59
-                              EE_Registry::instance()->CFG->core->event_cpt_slug,
60
-                              'event_cpt_slug',
61
-                              'event_cpt_slug',
62
-                              'regular'
63
-                          ); ?></p>
57
+						  . EEH_Form_Fields::text(
58
+							  'not_used',
59
+							  EE_Registry::instance()->CFG->core->event_cpt_slug,
60
+							  'event_cpt_slug',
61
+							  'event_cpt_slug',
62
+							  'regular'
63
+						  ); ?></p>
64 64
             <p class="description"><?php
65
-                esc_html_e(
66
-                    'This allows you to configure what slug is used for the url of all event pages.',
67
-                    'event_espresso'
68
-                ); ?></p>
65
+				esc_html_e(
66
+					'This allows you to configure what slug is used for the url of all event pages.',
67
+					'event_espresso'
68
+				); ?></p>
69 69
             <?php if (has_filter('FHEE__EE_Register_CPTs__register_CPT__rewrite')) : ?>
70 70
                 <p class="important-notice">
71 71
                     <?php
72
-                    sprintf(
73
-                        esc_html__(
74
-                            'Usage of the %1$s FHEE__EE_Register_CPTs__register_CPT__rewrite %2$s filter has been detected.  Please be aware that while this filter is being used, this setting has no affect.',
75
-                            'event_espresso'
76
-                        ),
77
-                        '<code>',
78
-                        '</code>'
79
-                    );
80
-                    ?>
72
+					sprintf(
73
+						esc_html__(
74
+							'Usage of the %1$s FHEE__EE_Register_CPTs__register_CPT__rewrite %2$s filter has been detected.  Please be aware that while this filter is being used, this setting has no affect.',
75
+							'event_espresso'
76
+						),
77
+						'<code>',
78
+						'</code>'
79
+					);
80
+					?>
81 81
                 </p>
82 82
             <?php endif; ?>
83 83
         </td>
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
         </th>
92 92
         <td>
93 93
             <?php echo EEH_Form_Fields::select(
94
-                'display_status_banner',
95
-                $display_status_banner,
96
-                $values,
97
-                'EED_Events_Archive_display_status_banner',
98
-                'EED_Events_Archive_display_status_banner'
99
-            ); ?>
94
+				'display_status_banner',
95
+				$display_status_banner,
96
+				$values,
97
+				'EED_Events_Archive_display_status_banner',
98
+				'EED_Events_Archive_display_status_banner'
99
+			); ?>
100 100
             <p class="description"><?php
101
-                esc_html_e(
102
-                    'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the events archive page.',
103
-                    'event_espresso'
104
-                ); ?></p>
101
+				esc_html_e(
102
+					'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the events archive page.',
103
+					'event_espresso'
104
+				); ?></p>
105 105
         </td>
106 106
     </tr>
107 107
 
@@ -109,18 +109,18 @@  discard block
 block discarded – undo
109 109
         <th>
110 110
             <label for="EED_Events_Archive_display_description">
111 111
                 <?php esc_html_e('Display Description', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
112
-                    'display_description_info'
113
-                ); ?>
112
+					'display_description_info'
113
+				); ?>
114 114
             </label>
115 115
         </th>
116 116
         <td>
117 117
             <?php echo EEH_Form_Fields::select(
118
-                'description',
119
-                $display_description,
120
-                $description,
121
-                'EED_Events_Archive_display_description',
122
-                'EED_Events_Archive_display_description'
123
-            ); ?>
118
+				'description',
119
+				$display_description,
120
+				$description,
121
+				'EED_Events_Archive_display_description',
122
+				'EED_Events_Archive_display_description'
123
+			); ?>
124 124
         </td>
125 125
     </tr>
126 126
 
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
         <th>
129 129
             <label for="EED_Events_Archive_display_ticket_selector">
130 130
                 <?php esc_html_e('Display Ticket Selector', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
131
-                    'display_ticket_selector_info'
132
-                ); ?>
131
+					'display_ticket_selector_info'
132
+				); ?>
133 133
             </label>
134 134
         </th>
135 135
         <td>
136 136
             <?php echo EEH_Form_Fields::select(
137
-                'ticket_selector',
138
-                $display_ticket_selector,
139
-                $values,
140
-                'EED_Events_Archive_display_ticket_selector',
141
-                'EED_Events_Archive_display_ticket_selector'
142
-            ); ?>
137
+				'ticket_selector',
138
+				$display_ticket_selector,
139
+				$values,
140
+				'EED_Events_Archive_display_ticket_selector',
141
+				'EED_Events_Archive_display_ticket_selector'
142
+			); ?>
143 143
         </td>
144 144
     </tr>
145 145
 
@@ -147,18 +147,18 @@  discard block
 block discarded – undo
147 147
         <th>
148 148
             <label for="EED_Events_Archive_display_datetimes">
149 149
                 <?php esc_html_e('Display Datetimes', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
150
-                    'display_datetimes_info'
151
-                ); ?>
150
+					'display_datetimes_info'
151
+				); ?>
152 152
             </label>
153 153
         </th>
154 154
         <td>
155 155
             <?php echo EEH_Form_Fields::select(
156
-                'venue_details',
157
-                $display_datetimes,
158
-                $values,
159
-                'EED_Events_Archive_display_datetimes',
160
-                'EED_Events_Archive_display_datetimes'
161
-            ); ?>
156
+				'venue_details',
157
+				$display_datetimes,
158
+				$values,
159
+				'EED_Events_Archive_display_datetimes',
160
+				'EED_Events_Archive_display_datetimes'
161
+			); ?>
162 162
         </td>
163 163
     </tr>
164 164
 
@@ -166,18 +166,18 @@  discard block
 block discarded – undo
166 166
         <th>
167 167
             <label for="EED_Events_Archive_display_venue">
168 168
                 <?php esc_html_e('Display Venue Details', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
169
-                    'display_venue_details_info'
170
-                ); ?>
169
+					'display_venue_details_info'
170
+				); ?>
171 171
             </label>
172 172
         </th>
173 173
         <td>
174 174
             <?php echo EEH_Form_Fields::select(
175
-                'display_venue',
176
-                $display_venue,
177
-                $values,
178
-                'EED_Events_Archive_display_venue',
179
-                'EED_Events_Archive_display_venue'
180
-            ); ?>
175
+				'display_venue',
176
+				$display_venue,
177
+				$values,
178
+				'EED_Events_Archive_display_venue',
179
+				'EED_Events_Archive_display_venue'
180
+			); ?>
181 181
         </td>
182 182
     </tr>
183 183
 
@@ -185,18 +185,18 @@  discard block
 block discarded – undo
185 185
         <th>
186 186
             <label for="EED_Events_Archive_display_expired_events">
187 187
                 <?php esc_html_e('Display Expired Events', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
188
-                    'display_expired_events_info'
189
-                ); ?>
188
+					'display_expired_events_info'
189
+				); ?>
190 190
             </label>
191 191
         </th>
192 192
         <td>
193 193
             <?php echo EEH_Form_Fields::select(
194
-                'expired_events',
195
-                $display_expired_events,
196
-                $values,
197
-                'EED_Events_Archive_display_expired_events',
198
-                'EED_Events_Archive_display_expired_events'
199
-            ); ?>
194
+				'expired_events',
195
+				$display_expired_events,
196
+				$values,
197
+				'EED_Events_Archive_display_expired_events',
198
+				'EED_Events_Archive_display_expired_events'
199
+			); ?>
200 200
         </td>
201 201
     </tr>
202 202
 
@@ -204,43 +204,43 @@  discard block
 block discarded – undo
204 204
         <th>
205 205
             <label for="EED_Events_Archive_use_sortable_display_order">
206 206
                 <?php esc_html_e(
207
-                    'Use Custom Display Order?',
208
-                    'event_espresso'
209
-                ); ?><?php // echo EEH_Template::get_help_tab_link('use_sortable_display_order_info');?>
207
+					'Use Custom Display Order?',
208
+					'event_espresso'
209
+				); ?><?php // echo EEH_Template::get_help_tab_link('use_sortable_display_order_info');?>
210 210
             </label>
211 211
         </th>
212 212
         <td>
213 213
             <?php echo EEH_Form_Fields::select(
214
-                'use_sortable_display_order',
215
-                $use_sortable_display_order,
216
-                $values,
217
-                'EED_Events_Archive_use_sortable_display_order',
218
-                'EED_Events_Archive_use_sortable_display_order'
219
-            ); ?>
214
+				'use_sortable_display_order',
215
+				$use_sortable_display_order,
216
+				$values,
217
+				'EED_Events_Archive_use_sortable_display_order',
218
+				'EED_Events_Archive_use_sortable_display_order'
219
+			); ?>
220 220
         </td>
221 221
     </tr>
222 222
 
223 223
     <tr>
224 224
         <th>
225 225
             <?php esc_html_e(
226
-                'Display Order',
227
-                'event_espresso'
228
-            ); ?><?php // echo EEH_Template::get_help_tab_link( 'event_archive_order_info' ); ?>
226
+				'Display Order',
227
+				'event_espresso'
228
+			); ?><?php // echo EEH_Template::get_help_tab_link( 'event_archive_order_info' ); ?>
229 229
         </th>
230 230
         <td>
231 231
 
232 232
             <?php wp_nonce_field(
233
-                'espresso_update_event_archive_order',
234
-                'espresso_update_event_archive_order_nonce',
235
-                false
236
-            ); ?>
233
+				'espresso_update_event_archive_order',
234
+				'espresso_update_event_archive_order_nonce',
235
+				false
236
+			); ?>
237 237
             <?php echo wp_kses($event_archive_display_order, AllowedTags::getWithFormTags()); ?>
238 238
 
239 239
             <p class="description"><?php
240
-                esc_html_e(
241
-                    'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the event archive page.',
242
-                    'event_espresso'
243
-                ); ?></p>
240
+				esc_html_e(
241
+					'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the event archive page.',
242
+					'event_espresso'
243
+				); ?></p>
244 244
 
245 245
         </td>
246 246
     </tr>
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
         </th>
254 254
         <td>
255 255
             <?php echo EEH_Form_Fields::select(
256
-                'reset_event_list_settings',
257
-                0,
258
-                $values,
259
-                'EED_Events_Archive_reset_event_list_settings',
260
-                'EED_Events_Archive_reset_event_list_settings'
261
-            ); ?>
256
+				'reset_event_list_settings',
257
+				0,
258
+				$values,
259
+				'EED_Events_Archive_reset_event_list_settings',
260
+				'EED_Events_Archive_reset_event_list_settings'
261
+			); ?>
262 262
         </td>
263 263
     </tr>
264 264
 
Please login to merge, or discard this patch.
ticket_selector_caff/templates/ticket_selector_price_details.template.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -10,39 +10,39 @@  discard block
 block discarded – undo
10 10
 if ($display_ticket_price) { ?>
11 11
     <section class="tckt-slctr-tkt-price-sctn">
12 12
         <h5><?php
13
-            echo apply_filters(
14
-                'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
15
-                esc_html__('Price', 'event_espresso')
16
-            ); ?></h5>
13
+			echo apply_filters(
14
+				'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
15
+				esc_html__('Price', 'event_espresso')
16
+			); ?></h5>
17 17
         <div class="tckt-slctr-tkt-details-tbl-wrap-dv">
18 18
             <table class="tckt-slctr-tkt-details-tbl">
19 19
                 <thead>
20 20
                 <tr>
21 21
                     <th class="ee-third-width"><span class="small-text">
22 22
                             <?php
23
-                            esc_html_e(
24
-                                'Name',
25
-                                'event_espresso'
26
-                            ); ?></span>
23
+							esc_html_e(
24
+								'Name',
25
+								'event_espresso'
26
+							); ?></span>
27 27
                     </th>
28 28
                     <th class="jst-cntr"><span class="small-text">
29 29
                             <?php
30
-                            esc_html_e(
31
-                                'Description',
32
-                                'event_espresso'
33
-                            ); ?></span>
30
+							esc_html_e(
31
+								'Description',
32
+								'event_espresso'
33
+							); ?></span>
34 34
                     </th>
35 35
                     <th class="ee-fourth-width jst-rght"><span class="small-text">
36 36
                             <?php
37
-                            esc_html_e(
38
-                                'Amount',
39
-                                'event_espresso'
40
-                            ); ?></span></th>
37
+							esc_html_e(
38
+								'Amount',
39
+								'event_espresso'
40
+							); ?></span></th>
41 41
                 </tr>
42 42
                 </thead>
43 43
                 <tbody>
44 44
                 <?php
45
-                if ($ticket->base_price() instanceof EE_Price) { ?>
45
+				if ($ticket->base_price() instanceof EE_Price) { ?>
46 46
                     <tr>
47 47
                         <td data-th="<?php esc_html_e('Name', 'event_espresso'); ?>" class="small-text" colspan="2">
48 48
                             <b><?php echo wp_kses($ticket->base_price()->name(), AllowedTags::getAllowedTags()); ?></b></td>
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
                             class="jst-rght small-text"><?php echo wp_kses($ticket->base_price()->pretty_price(), AllowedTags::getAllowedTags()); ?></td>
51 51
                     </tr>
52 52
                     <?php
53
-                    $running_total = $ticket->base_price()->amount();
54
-                } else {
55
-                    $running_total = 0;
56
-                }
57
-                // now add price modifiers
58
-                foreach ($ticket->price_modifiers() as $price_mod) { ?>
53
+					$running_total = $ticket->base_price()->amount();
54
+				} else {
55
+					$running_total = 0;
56
+				}
57
+				// now add price modifiers
58
+				foreach ($ticket->price_modifiers() as $price_mod) { ?>
59 59
                     <tr>
60 60
                         <td data-th="<?php esc_html_e('Name', 'event_espresso'); ?>"
61 61
                             class="jst-rght small-text"><?php echo wp_kses($price_mod->name(), AllowedTags::getAllowedTags()); ?></td>
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
                                 %
66 66
                             </td>
67 67
                             <?php
68
-                            $new_sub_total = $running_total * ($price_mod->amount() / 100);
69
-                            $new_sub_total = $price_mod->is_discount() ? $new_sub_total * -1 : $new_sub_total;
70
-                            ?>
68
+							$new_sub_total = $running_total * ($price_mod->amount() / 100);
69
+							$new_sub_total = $price_mod->is_discount() ? $new_sub_total * -1 : $new_sub_total;
70
+							?>
71 71
                         <?php } else { ?>
72 72
                             <?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1
73
-                                : $price_mod->amount(); ?>
73
+								: $price_mod->amount(); ?>
74 74
                             <td data-th="<?php esc_html_e('Description', 'event_espresso'); ?>"
75 75
                                 class="small-text"><?php echo wp_kses($price_mod->desc(), AllowedTags::getAllowedTags()); ?></td>
76 76
                             <?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1
77
-                                : $price_mod->amount(); ?>
77
+								: $price_mod->amount(); ?>
78 78
                         <?php } ?>
79 79
                         <td data-th="<?php esc_html_e('Amount', 'event_espresso'); ?>"
80 80
                             class="jst-rght small-text">
81 81
                             <?php
82
-                            echo EEH_Template::format_currency(
83
-                                $new_sub_total
84
-                            ); ?></td>
82
+							echo EEH_Template::format_currency(
83
+								$new_sub_total
84
+							); ?></td>
85 85
                         <?php $running_total += $new_sub_total; ?>
86 86
                     </tr>
87 87
                 <?php } ?>
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
                     <tr>
91 91
                         <td colspan="2" class="jst-rght small-text sbttl"><b>
92 92
                                 <?php
93
-                                esc_html_e(
94
-                                    'subtotal',
95
-                                    'event_espresso'
96
-                                ); ?></b></td>
93
+								esc_html_e(
94
+									'subtotal',
95
+									'event_espresso'
96
+								); ?></b></td>
97 97
                         <td data-th="<?php esc_html_e('subtotal', 'event_espresso'); ?>" class="jst-rght small-text">
98 98
                             <b><?php echo EEH_Template::format_currency($running_total); ?></b></td>
99 99
                     </tr>
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
                             <td data-th="<?php esc_html_e('Amount', 'event_espresso'); ?>"
110 110
                                 class="jst-rght small-text">
111 111
                                 <?php
112
-                                echo EEH_Template::format_currency(
113
-                                    $tax_amount
114
-                                ); ?></td>
112
+								echo EEH_Template::format_currency(
113
+									$tax_amount
114
+								); ?></td>
115 115
                             <?php $running_total += $tax_amount; ?>
116 116
                         </tr>
117 117
                     <?php } ?>
@@ -119,15 +119,15 @@  discard block
 block discarded – undo
119 119
                 <tr>
120 120
                     <td colspan="2" class="jst-rght small-text ttl-lbl-td">
121 121
                         <b><?php
122
-                            echo apply_filters(
123
-                                'FHEE__ticket_selector_chart_template__ticket_details_total_price',
124
-                                esc_html__('Total', 'event_espresso')
125
-                            ); ?></b></td>
122
+							echo apply_filters(
123
+								'FHEE__ticket_selector_chart_template__ticket_details_total_price',
124
+								esc_html__('Total', 'event_espresso')
125
+							); ?></b></td>
126 126
                     <td data-th="<?php
127
-                                    echo apply_filters(
128
-                                        'FHEE__ticket_selector_chart_template__ticket_details_total_price',
129
-                                        esc_html__('Total', 'event_espresso')
130
-                                    ); ?>" class="jst-rght small-text">
127
+									echo apply_filters(
128
+										'FHEE__ticket_selector_chart_template__ticket_details_total_price',
129
+										esc_html__('Total', 'event_espresso')
130
+									); ?>" class="jst-rght small-text">
131 131
                         <b><?php echo EEH_Template::format_currency($running_total); ?></b></td>
132 132
                 </tr>
133 133
                 </tbody>
Please login to merge, or discard this patch.
registration_form/espresso_events_Registration_Form_Hooks.class.php 1 patch
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -16,95 +16,95 @@  discard block
 block discarded – undo
16 16
 class espresso_events_Registration_Form_Hooks extends EE_Admin_Hooks
17 17
 {
18 18
 
19
-    /**
20
-     * @var EE_Event|null
21
-     */
22
-    protected $_event;
23
-
24
-
25
-    protected function _set_hooks_properties()
26
-    {
27
-
28
-        $this->_name      = 'registration_form';
29
-        $this->_metaboxes = [
30
-            0 => [
31
-                'page_route' => ['edit', 'create_new'],
32
-                'func'       => 'primary_questions',
33
-                'label'      => esc_html__('Questions for Primary Registrant', 'event_espresso'),
34
-                'priority'   => 'default',
35
-                'context'    => 'side',
36
-            ],
37
-        ];
38
-
39
-        // hook into the handler for saving question groups
40
-        add_filter(
41
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
42
-            [$this, 'modify_callbacks'],
43
-            10
44
-        );
45
-
46
-        // hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already
47
-        // restricted by page)
48
-        add_action('AHEE_EE_Admin_Page_CPT__restore_revision', [$this, 'restore_revision'], 10, 2);
49
-    }
50
-
51
-
52
-    /**
53
-     * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook
54
-     *
55
-     * @param $callbacks
56
-     * @return array
57
-     */
58
-    public function modify_callbacks($callbacks)
59
-    {
60
-        // now let's add the question group callback
61
-        $callbacks[] = [$this, 'primary_question_group_update'];
62
-        return $callbacks;
63
-    }
64
-
65
-
66
-    /**
67
-     * Hooked into revision restores.
68
-     *
69
-     * @param $post_id
70
-     * @param $revision_id
71
-     * @return EE_Base_Class
72
-     * @throws EE_Error
73
-     * @throws InvalidArgumentException
74
-     * @throws InvalidDataTypeException
75
-     * @throws InvalidInterfaceException
76
-     */
77
-    public function restore_revision($post_id, $revision_id)
78
-    {
79
-        $post_evt = EEM_Event::instance()->get_one_by_ID($post_id);
80
-        // restore revision for primary questions
81
-        if ($post_evt instanceof EE_Event) {
82
-            $post_evt->restore_revision(
83
-                $revision_id,
84
-                ['Question_Group'],
85
-                ['Question_Group' => ['Event_Question_Group.EQG_primary' => true]]
86
-            );
87
-        }
88
-        return $post_evt;
89
-    }
90
-
91
-
92
-    /**
93
-     * Content of metabox.
94
-     *
95
-     * @param $post_id
96
-     * @param $post
97
-     * @throws EE_Error
98
-     * @throws InvalidArgumentException
99
-     * @throws InvalidDataTypeException
100
-     * @throws InvalidInterfaceException
101
-     * @throws ReflectionException
102
-     */
103
-    public function primary_questions($post_id, $post)
104
-    {
105
-        $this->_event = $this->_adminpage_obj->get_event_object();
106
-        $event_id     = $this->_event->ID();
107
-        ?>
19
+	/**
20
+	 * @var EE_Event|null
21
+	 */
22
+	protected $_event;
23
+
24
+
25
+	protected function _set_hooks_properties()
26
+	{
27
+
28
+		$this->_name      = 'registration_form';
29
+		$this->_metaboxes = [
30
+			0 => [
31
+				'page_route' => ['edit', 'create_new'],
32
+				'func'       => 'primary_questions',
33
+				'label'      => esc_html__('Questions for Primary Registrant', 'event_espresso'),
34
+				'priority'   => 'default',
35
+				'context'    => 'side',
36
+			],
37
+		];
38
+
39
+		// hook into the handler for saving question groups
40
+		add_filter(
41
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
42
+			[$this, 'modify_callbacks'],
43
+			10
44
+		);
45
+
46
+		// hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already
47
+		// restricted by page)
48
+		add_action('AHEE_EE_Admin_Page_CPT__restore_revision', [$this, 'restore_revision'], 10, 2);
49
+	}
50
+
51
+
52
+	/**
53
+	 * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook
54
+	 *
55
+	 * @param $callbacks
56
+	 * @return array
57
+	 */
58
+	public function modify_callbacks($callbacks)
59
+	{
60
+		// now let's add the question group callback
61
+		$callbacks[] = [$this, 'primary_question_group_update'];
62
+		return $callbacks;
63
+	}
64
+
65
+
66
+	/**
67
+	 * Hooked into revision restores.
68
+	 *
69
+	 * @param $post_id
70
+	 * @param $revision_id
71
+	 * @return EE_Base_Class
72
+	 * @throws EE_Error
73
+	 * @throws InvalidArgumentException
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws InvalidInterfaceException
76
+	 */
77
+	public function restore_revision($post_id, $revision_id)
78
+	{
79
+		$post_evt = EEM_Event::instance()->get_one_by_ID($post_id);
80
+		// restore revision for primary questions
81
+		if ($post_evt instanceof EE_Event) {
82
+			$post_evt->restore_revision(
83
+				$revision_id,
84
+				['Question_Group'],
85
+				['Question_Group' => ['Event_Question_Group.EQG_primary' => true]]
86
+			);
87
+		}
88
+		return $post_evt;
89
+	}
90
+
91
+
92
+	/**
93
+	 * Content of metabox.
94
+	 *
95
+	 * @param $post_id
96
+	 * @param $post
97
+	 * @throws EE_Error
98
+	 * @throws InvalidArgumentException
99
+	 * @throws InvalidDataTypeException
100
+	 * @throws InvalidInterfaceException
101
+	 * @throws ReflectionException
102
+	 */
103
+	public function primary_questions($post_id, $post)
104
+	{
105
+		$this->_event = $this->_adminpage_obj->get_event_object();
106
+		$event_id     = $this->_event->ID();
107
+		?>
108 108
         <div class="inside">
109 109
             <p>
110 110
                 <strong>
@@ -112,64 +112,64 @@  discard block
 block discarded – undo
112 112
                 </strong>
113 113
                 <br />
114 114
                 <?php
115
-                printf(
116
-                    esc_html__(
117
-                        'Add a pre-populated %1$sgroup of questions%2$s to your event. The personal information group is required for all events',
118
-                        'event_espresso'
119
-                    ),
120
-                    '<a href="admin.php?page=espresso_registration_form" target="_blank">',
121
-                    '</a>'
122
-                )
123
-                ?>
115
+				printf(
116
+					esc_html__(
117
+						'Add a pre-populated %1$sgroup of questions%2$s to your event. The personal information group is required for all events',
118
+						'event_espresso'
119
+					),
120
+					'<a href="admin.php?page=espresso_registration_form" target="_blank">',
121
+					'</a>'
122
+				)
123
+				?>
124 124
             </p>
125 125
             <?php
126 126
 
127
-            $qsg_where['QSG_deleted'] = false;
128
-            $query_params             = apply_filters(
129
-                'FHEE__espresso_events_Registration_Form_Hooks__primary_questions__question_group_query_parameters',
130
-                [$qsg_where, 'order_by' => ['QSG_order' => 'ASC']]
131
-            );
132
-            $QSGs                     = EEM_Question_Group::instance()->get_all($query_params);
133
-            $EQGs                     = ! empty($event_id)
134
-                ? $this->_event->get_many_related(
135
-                    'Question_Group',
136
-                    [['Event_Question_Group.EQG_primary' => true]]
137
-                )
138
-                : [];
139
-            $EQGids                   = array_keys($EQGs);
140
-
141
-            if (! empty($QSGs)) {
142
-                $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
143
-                foreach ($QSGs as $QSG) {
144
-                    $QSG_ID          = absint($QSG->ID());
145
-                    $checked         = in_array($QSG_ID, $EQGids, true) || $QSG->get('QSG_system') === 1
146
-                        ? ' checked'
147
-                        : '';
148
-                    $visibility      = $QSG->get('QSG_system') === 1
149
-                        ? ' style="visibility:hidden"'
150
-                        : '';
151
-                    $edit_query_args = $this->_adminpage_obj->is_caf()
152
-                        ? [
153
-                            'action' => 'edit_question_group',
154
-                            'QSG_ID' => $QSG_ID,
155
-                        ]
156
-                        : ['action' => 'question_groups'];
157
-                    $edit_link       = EE_Admin_Page::add_query_args_and_nonce(
158
-                        $edit_query_args,
159
-                        EE_FORMS_ADMIN_URL
160
-                    );
161
-                    $edit_link_title = sprintf(
162
-                        esc_attr__('Edit %s Group', 'event_espresso'),
163
-                        $QSG->get('QSG_name')
164
-                    );
165
-
166
-                    $html .= '
127
+			$qsg_where['QSG_deleted'] = false;
128
+			$query_params             = apply_filters(
129
+				'FHEE__espresso_events_Registration_Form_Hooks__primary_questions__question_group_query_parameters',
130
+				[$qsg_where, 'order_by' => ['QSG_order' => 'ASC']]
131
+			);
132
+			$QSGs                     = EEM_Question_Group::instance()->get_all($query_params);
133
+			$EQGs                     = ! empty($event_id)
134
+				? $this->_event->get_many_related(
135
+					'Question_Group',
136
+					[['Event_Question_Group.EQG_primary' => true]]
137
+				)
138
+				: [];
139
+			$EQGids                   = array_keys($EQGs);
140
+
141
+			if (! empty($QSGs)) {
142
+				$html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
143
+				foreach ($QSGs as $QSG) {
144
+					$QSG_ID          = absint($QSG->ID());
145
+					$checked         = in_array($QSG_ID, $EQGids, true) || $QSG->get('QSG_system') === 1
146
+						? ' checked'
147
+						: '';
148
+					$visibility      = $QSG->get('QSG_system') === 1
149
+						? ' style="visibility:hidden"'
150
+						: '';
151
+					$edit_query_args = $this->_adminpage_obj->is_caf()
152
+						? [
153
+							'action' => 'edit_question_group',
154
+							'QSG_ID' => $QSG_ID,
155
+						]
156
+						: ['action' => 'question_groups'];
157
+					$edit_link       = EE_Admin_Page::add_query_args_and_nonce(
158
+						$edit_query_args,
159
+						EE_FORMS_ADMIN_URL
160
+					);
161
+					$edit_link_title = sprintf(
162
+						esc_attr__('Edit %s Group', 'event_espresso'),
163
+						$QSG->get('QSG_name')
164
+					);
165
+
166
+					$html .= '
167 167
 					<p id="event-question-group-' . $QSG_ID . '">
168 168
 						<input value="' . $QSG_ID . '" 
169 169
 						    type="checkbox"
170 170
 						    name="question_groups[' . $QSG_ID . ']" '
171
-                             . $visibility
172
-                             . $checked . ' 
171
+							 . $visibility
172
+							 . $checked . ' 
173 173
                         />
174 174
 						<a href="' . esc_url_raw($edit_link) . '" 
175 175
 						    title="' . esc_attr($edit_link_title) . '" 
@@ -178,62 +178,62 @@  discard block
 block discarded – undo
178 178
 						    ' . $QSG->get('QSG_name') . '
179 179
                         </a>
180 180
 					</p>';
181
-                }
182
-                $html .= count($QSGs) > 10 ? '</div>' : '';
183
-                echo wp_kses($html, AllowedTags::getWithFormTags());
184
-            } else {
185
-                esc_html_e(
186
-                    'There seems to be a problem with your questions. Please contact [email protected]',
187
-                    'event_espresso'
188
-                );
189
-            }
190
-            do_action('AHEE_event_editor_questions_notice');
191
-            ?>
181
+				}
182
+				$html .= count($QSGs) > 10 ? '</div>' : '';
183
+				echo wp_kses($html, AllowedTags::getWithFormTags());
184
+			} else {
185
+				esc_html_e(
186
+					'There seems to be a problem with your questions. Please contact [email protected]',
187
+					'event_espresso'
188
+				);
189
+			}
190
+			do_action('AHEE_event_editor_questions_notice');
191
+			?>
192 192
         </div>
193 193
         <?php
194
-    }
195
-
196
-
197
-    /**
198
-     * @param EE_Event $event
199
-     * @param array    $data
200
-     * @return bool
201
-     * @throws EE_Error
202
-     * @throws ReflectionException
203
-     */
204
-    public function primary_question_group_update($event, $data)
205
-    {
206
-        $question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : [];
207
-        $added_qgs       = array_keys($question_groups);
208
-        $success         = true;
209
-
210
-        // let's get all current question groups associated with this event.
211
-        $current_qgs = $event->get_many_related(
212
-            'Question_Group',
213
-            [['Event_Question_Group.EQG_primary' => true]]
214
-        );
215
-        $current_qgs = array_keys($current_qgs); // we just want the ids
216
-
217
-        // now let's get the groups selected in the editor and update (IF we have data)
218
-        if (! empty($question_groups)) {
219
-            foreach ($question_groups as $QSG_ID => $val) {
220
-                // add to event
221
-                if ($val) {
222
-                    $qg = $event->_add_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]);
223
-                }
224
-                // trip success to false if result is empty
225
-                $success = ! empty($qg) ? $success : false;
226
-            }
227
-        }
228
-
229
-        // wait a minute... are there question groups missing in the saved groups that ARE with the current event?
230
-        $removed_qgs = array_diff($current_qgs, $added_qgs);
231
-
232
-        foreach ($removed_qgs as $QSG_ID) {
233
-            $qg = $event->_remove_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]);
234
-            // trip success to false if result is empty
235
-            $success = ! empty($qg) ? $success : false;
236
-        }
237
-        return $success;
238
-    }
194
+	}
195
+
196
+
197
+	/**
198
+	 * @param EE_Event $event
199
+	 * @param array    $data
200
+	 * @return bool
201
+	 * @throws EE_Error
202
+	 * @throws ReflectionException
203
+	 */
204
+	public function primary_question_group_update($event, $data)
205
+	{
206
+		$question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : [];
207
+		$added_qgs       = array_keys($question_groups);
208
+		$success         = true;
209
+
210
+		// let's get all current question groups associated with this event.
211
+		$current_qgs = $event->get_many_related(
212
+			'Question_Group',
213
+			[['Event_Question_Group.EQG_primary' => true]]
214
+		);
215
+		$current_qgs = array_keys($current_qgs); // we just want the ids
216
+
217
+		// now let's get the groups selected in the editor and update (IF we have data)
218
+		if (! empty($question_groups)) {
219
+			foreach ($question_groups as $QSG_ID => $val) {
220
+				// add to event
221
+				if ($val) {
222
+					$qg = $event->_add_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]);
223
+				}
224
+				// trip success to false if result is empty
225
+				$success = ! empty($qg) ? $success : false;
226
+			}
227
+		}
228
+
229
+		// wait a minute... are there question groups missing in the saved groups that ARE with the current event?
230
+		$removed_qgs = array_diff($current_qgs, $added_qgs);
231
+
232
+		foreach ($removed_qgs as $QSG_ID) {
233
+			$qg = $event->_remove_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]);
234
+			// trip success to false if result is empty
235
+			$success = ! empty($qg) ? $success : false;
236
+		}
237
+		return $success;
238
+	}
239 239
 }
Please login to merge, or discard this patch.
registration_form/templates/questions_main_meta_box.template.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         EEH_HTML::h4(
35 35
             '<span class="dashicons dashicons-info"></span>'
36 36
             . esc_html__('Did you know...', 'event_espresso')
37
-        ) .
37
+        ).
38 38
         EEH_HTML::p(
39 39
             esc_html__(
40 40
                 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.',
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                                type="hidden"
96 96
                                value="<?php echo esc_attr($question->get('QST_order')); ?>"
97 97
                         />
98
-                        <?php if (! empty($QST_system)) { ?>
98
+                        <?php if ( ! empty($QST_system)) { ?>
99 99
                             <input id='QST_admin_label'
100 100
                                    name="QST_admin_label"
101 101
                                    type="hidden"
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
                         <?php } ?>
105 105
                         <br />
106 106
                         <p class="description">
107
-                            <?php if (! empty($QST_system)) { ?>
107
+                            <?php if ( ! empty($QST_system)) { ?>
108 108
                                 <span class="description" style="color:#D54E21;">
109 109
                                 <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso') ?>
110 110
                         </span>
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                         <br />
142 142
                         <p class="description">
143 143
                             <?php
144
-                            if (! empty($QST_system)) { ?>
144
+                            if ( ! empty($QST_system)) { ?>
145 145
                                 <span class="description" style="color:#D54E21;">
146 146
                                     <?php esc_html_e(
147 147
                                         'System question! This field cannot be changed.',
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
 
174 174
                         // Only display Confirm email for
175 175
                         if (empty($QST_system) || $QST_system !== EEM_Attendee::system_question_email_confirm) {
176
-                            unset($question_types[ EEM_Question::QST_type_email_confirm ]);
176
+                            unset($question_types[EEM_Question::QST_type_email_confirm]);
177 177
                         }
178 178
 
179 179
                         echo EEH_Form_Fields::select_input(
180
-                            'QST_type' . $id,
180
+                            'QST_type'.$id,
181 181
                             $question_types,
182 182
                             $question->type(),
183
-                            'id="QST_type' . $id . '"' . $disabled_attr
183
+                            'id="QST_type'.$id.'"'.$disabled_attr
184 184
                         ); // already escaped
185 185
                         if ($disabled) { ?>
186 186
                             <input id='QST_type'
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                     </th>
220 220
                     <td>
221 221
                         <input id="QST_max"
222
-                            <?php echo ($max_max === EE_INF ? '' : 'max="' . esc_attr($max_max) . '"'); ?>
222
+                            <?php echo ($max_max === EE_INF ? '' : 'max="'.esc_attr($max_max).'"'); ?>
223 223
                                min="1"
224 224
                                name="QST_max"
225 225
                                type="number"
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
                                 <?php
304 304
                                 $count            = 0;
305 305
                                 $question_options = $question->options();
306
-                                if (! empty($question_options)) {
306
+                                if ( ! empty($question_options)) {
307 307
                                     foreach ($question_options as $option_id => $option) {
308 308
                                         $disabled_attr = $has_answers || $option->get('QSO_system')
309 309
                                             ? 'disabled'
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
                                                 />
338 338
                                             </td>
339 339
                                             <td>
340
-                                                <?php if (! $option->system()) { ?>
340
+                                                <?php if ( ! $option->system()) { ?>
341 341
                                                     <span class="dashicons clickable dashicons-post-trash ee-icon-size-18 remove-option remove-item">
342 342
                                         </span>
343 343
                                                 <?php } ?>
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
                             ['text' => esc_html__('Required', 'event_espresso'), 'id' => 1],
441 441
                         ];
442 442
                         echo EEH_Form_Fields::select_input(
443
-                            'QST_required' . $id,
443
+                            'QST_required'.$id,
444 444
                             $requiredOptions,
445 445
                             $question->required(),
446
-                            'id="QST_required' . $id . '"' . $disabled_attr
446
+                            'id="QST_required'.$id.'"'.$disabled_attr
447 447
                         ); // already escaped
448 448
                         ?>
449 449
                         <p>
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
                                 ) ?>
465 465
                             </span>
466 466
                         </p>
467
-                        <?php if (! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?>
467
+                        <?php if ( ! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?>
468 468
                             <input type="hidden" id="QST_required" name="QST_required" value="1" />
469 469
                             <p>
470 470
                             <span class="description" style="color:#D54E21;">
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 2 patches
Indentation   +1397 added lines, -1397 removed lines patch added patch discarded remove patch
@@ -18,1412 +18,1412 @@
 block discarded – undo
18 18
 class General_Settings_Admin_Page extends EE_Admin_Page
19 19
 {
20 20
 
21
-    /**
22
-     * _question_group
23
-     * holds the specific question group object for the question group details screen
24
-     *
25
-     * @var object
26
-     */
27
-    protected $_question_group;
28
-
29
-
30
-    /**
31
-     * Initialize basic properties.
32
-     */
33
-    protected function _init_page_props()
34
-    {
35
-        $this->page_slug        = GEN_SET_PG_SLUG;
36
-        $this->page_label       = GEN_SET_LABEL;
37
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
38
-        $this->_admin_base_path = GEN_SET_ADMIN;
39
-    }
40
-
41
-
42
-    /**
43
-     * Set ajax hooks
44
-     */
45
-    protected function _ajax_hooks()
46
-    {
47
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
48
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
49
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
50
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
51
-    }
52
-
53
-
54
-    /**
55
-     * More page properties initialization.
56
-     */
57
-    protected function _define_page_props()
58
-    {
59
-        $this->_admin_page_title = GEN_SET_LABEL;
60
-        $this->_labels           = [
61
-            'publishbox' => esc_html__('Update Settings', 'event_espresso'),
62
-        ];
63
-    }
64
-
65
-
66
-    /**
67
-     * Set page routes property.
68
-     */
69
-    protected function _set_page_routes()
70
-    {
71
-        $this->_page_routes = [
72
-
73
-            'critical_pages'                => [
74
-                'func'       => '_espresso_page_settings',
75
-                'capability' => 'manage_options',
76
-            ],
77
-            'update_espresso_page_settings' => [
78
-                'func'       => '_update_espresso_page_settings',
79
-                'capability' => 'manage_options',
80
-                'noheader'   => true,
81
-            ],
82
-            'default'                       => [
83
-                'func'       => '_your_organization_settings',
84
-                'capability' => 'manage_options',
85
-            ],
86
-
87
-            'update_your_organization_settings' => [
88
-                'func'       => '_update_your_organization_settings',
89
-                'capability' => 'manage_options',
90
-                'noheader'   => true,
91
-            ],
92
-
93
-            'admin_option_settings' => [
94
-                'func'       => '_admin_option_settings',
95
-                'capability' => 'manage_options',
96
-            ],
97
-
98
-            'update_admin_option_settings' => [
99
-                'func'       => '_update_admin_option_settings',
100
-                'capability' => 'manage_options',
101
-                'noheader'   => true,
102
-            ],
103
-
104
-            'country_settings' => [
105
-                'func'       => '_country_settings',
106
-                'capability' => 'manage_options',
107
-            ],
108
-
109
-            'update_country_settings' => [
110
-                'func'       => '_update_country_settings',
111
-                'capability' => 'manage_options',
112
-                'noheader'   => true,
113
-            ],
114
-
115
-            'display_country_settings' => [
116
-                'func'       => 'display_country_settings',
117
-                'capability' => 'manage_options',
118
-                'noheader'   => true,
119
-            ],
120
-
121
-            'add_new_state' => [
122
-                'func'       => 'add_new_state',
123
-                'capability' => 'manage_options',
124
-                'noheader'   => true,
125
-            ],
126
-
127
-            'delete_state'            => [
128
-                'func'       => 'delete_state',
129
-                'capability' => 'manage_options',
130
-                'noheader'   => true,
131
-            ],
132
-            'privacy_settings'        => [
133
-                'func'       => 'privacySettings',
134
-                'capability' => 'manage_options',
135
-            ],
136
-            'update_privacy_settings' => [
137
-                'func'               => 'updatePrivacySettings',
138
-                'capability'         => 'manage_options',
139
-                'noheader'           => true,
140
-                'headers_sent_route' => 'privacy_settings',
141
-            ],
142
-        ];
143
-    }
144
-
145
-
146
-    /**
147
-     * Set page configuration property
148
-     */
149
-    protected function _set_page_config()
150
-    {
151
-        $this->_page_config = [
152
-            'critical_pages'        => [
153
-                'nav'           => [
154
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
155
-                    'order' => 50,
156
-                ],
157
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
158
-                'help_tabs'     => [
159
-                    'general_settings_critical_pages_help_tab' => [
160
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
161
-                        'filename' => 'general_settings_critical_pages',
162
-                    ],
163
-                ],
164
-                'require_nonce' => false,
165
-            ],
166
-            'default'               => [
167
-                'nav'           => [
168
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
169
-                    'order' => 20,
170
-                ],
171
-                'help_tabs'     => [
172
-                    'general_settings_your_organization_help_tab' => [
173
-                        'title'    => esc_html__('Your Organization', 'event_espresso'),
174
-                        'filename' => 'general_settings_your_organization',
175
-                    ],
176
-                ],
177
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
178
-                'require_nonce' => false,
179
-            ],
180
-            'admin_option_settings' => [
181
-                'nav'           => [
182
-                    'label' => esc_html__('Admin Options', 'event_espresso'),
183
-                    'order' => 60,
184
-                ],
185
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
186
-                'help_tabs'     => [
187
-                    'general_settings_admin_options_help_tab' => [
188
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
189
-                        'filename' => 'general_settings_admin_options',
190
-                    ],
191
-                ],
192
-                'require_nonce' => false,
193
-            ],
194
-            'country_settings'      => [
195
-                'nav'           => [
196
-                    'label' => esc_html__('Countries', 'event_espresso'),
197
-                    'order' => 70,
198
-                ],
199
-                'help_tabs'     => [
200
-                    'general_settings_countries_help_tab' => [
201
-                        'title'    => esc_html__('Countries', 'event_espresso'),
202
-                        'filename' => 'general_settings_countries',
203
-                    ],
204
-                ],
205
-                'require_nonce' => false,
206
-            ],
207
-            'privacy_settings'      => [
208
-                'nav'           => [
209
-                    'label' => esc_html__('Privacy', 'event_espresso'),
210
-                    'order' => 80,
211
-                ],
212
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
213
-                'require_nonce' => false,
214
-            ],
215
-        ];
216
-    }
217
-
218
-
219
-    protected function _add_screen_options()
220
-    {
221
-    }
222
-
223
-
224
-    protected function _add_feature_pointers()
225
-    {
226
-    }
227
-
228
-
229
-    /**
230
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
231
-     */
232
-    public function load_scripts_styles()
233
-    {
234
-        // styles
235
-        wp_enqueue_style('espresso-ui-theme');
236
-        // scripts
237
-        wp_enqueue_script('ee_admin_js');
238
-    }
239
-
240
-
241
-    /**
242
-     * Execute logic running on `admin_init`
243
-     */
244
-    public function admin_init()
245
-    {
246
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(__(
247
-            'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
248
-            'event_espresso'
249
-        ));
250
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(__(
251
-            'An error occurred! Please refresh the page and try again.',
252
-            'event_espresso'
253
-        ));
254
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(__(
255
-            'Are you sure you want to delete this State / Province?',
256
-            'event_espresso'
257
-        ));
258
-        $protocol                                                = is_ssl() ? 'https://' : 'http://';
259
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
260
-            'admin-ajax.php?page=espresso_general_settings',
261
-            $protocol
262
-        );
263
-    }
264
-
265
-
266
-    public function admin_notices()
267
-    {
268
-    }
269
-
270
-
271
-    public function admin_footer_scripts()
272
-    {
273
-    }
274
-
275
-
276
-    /**
277
-     * Enqueue scripts and styles for the default route.
278
-     */
279
-    public function load_scripts_styles_default()
280
-    {
281
-        // styles
282
-        wp_enqueue_style('thickbox');
283
-        // scripts
284
-        wp_enqueue_script('media-upload');
285
-        wp_enqueue_script('thickbox');
286
-        wp_register_script(
287
-            'organization_settings',
288
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
289
-            ['jquery', 'media-upload', 'thickbox'],
290
-            EVENT_ESPRESSO_VERSION,
291
-            true
292
-        );
293
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
294
-        wp_enqueue_script('organization_settings');
295
-        wp_enqueue_style('organization-css');
296
-        $confirm_image_delete = [
297
-            'text' => wp_strip_all_tags(
298
-                __(
299
-                    'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
300
-                    'event_espresso'
301
-                )
302
-            ),
303
-        ];
304
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
305
-    }
306
-
307
-
308
-    /**
309
-     * Enqueue scripts and styles for the country settings route.
310
-     */
311
-    public function load_scripts_styles_country_settings()
312
-    {
313
-        // scripts
314
-        wp_register_script(
315
-            'gen_settings_countries',
316
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
317
-            ['ee_admin_js'],
318
-            EVENT_ESPRESSO_VERSION,
319
-            true
320
-        );
321
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
322
-        wp_enqueue_script('gen_settings_countries');
323
-        wp_enqueue_style('organization-css');
324
-    }
325
-
326
-
327
-    /*************        Espresso Pages        *************/
328
-    /**
329
-     * _espresso_page_settings
330
-     *
331
-     * @throws EE_Error
332
-     * @throws DomainException
333
-     * @throws DomainException
334
-     * @throws InvalidDataTypeException
335
-     * @throws InvalidArgumentException
336
-     */
337
-    protected function _espresso_page_settings()
338
-    {
339
-        // Check to make sure all of the main pages are set up properly,
340
-        // if not create the default pages and display an admin notice
341
-        EEH_Activation::verify_default_pages_exist();
342
-        $this->_transient_garbage_collection();
343
-        $this->_template_args['values']             = $this->_yes_no_values;
344
-        $this->_template_args['reg_page_id']        = isset(EE_Registry::instance()->CFG->core->reg_page_id)
345
-            ? EE_Registry::instance()->CFG->core->reg_page_id
346
-            : null;
347
-        $this->_template_args['reg_page_obj']       = isset(EE_Registry::instance()->CFG->core->reg_page_id)
348
-            ? get_post(EE_Registry::instance()->CFG->core->reg_page_id)
349
-            : false;
350
-        $this->_template_args['txn_page_id']        = isset(EE_Registry::instance()->CFG->core->txn_page_id)
351
-            ? EE_Registry::instance()->CFG->core->txn_page_id
352
-            : null;
353
-        $this->_template_args['txn_page_obj']       = isset(EE_Registry::instance()->CFG->core->txn_page_id)
354
-            ? get_post(EE_Registry::instance()->CFG->core->txn_page_id)
355
-            : false;
356
-        $this->_template_args['thank_you_page_id']  = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
357
-            ? EE_Registry::instance()->CFG->core->thank_you_page_id
358
-            : null;
359
-        $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
360
-            ? get_post(EE_Registry::instance()->CFG->core->thank_you_page_id)
361
-            : false;
362
-        $this->_template_args['cancel_page_id']     = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
363
-            ? EE_Registry::instance()->CFG->core->cancel_page_id
364
-            : null;
365
-        $this->_template_args['cancel_page_obj']    = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
366
-            ? get_post(EE_Registry::instance()->CFG->core->cancel_page_id)
367
-            : false;
368
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
369
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
370
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
372
-            $this->_template_args,
373
-            true
374
-        );
375
-        $this->display_admin_page_with_sidebar();
376
-    }
377
-
378
-
379
-    /**
380
-     * Handler for updating espresso page settings.
381
-     *
382
-     * @throws EE_Error
383
-     */
384
-    protected function _update_espresso_page_settings()
385
-    {
386
-        // capture incoming request data && set page IDs
387
-        EE_Registry::instance()->CFG->core->reg_page_id       = isset($this->_req_data['reg_page_id'])
388
-            ? absint($this->_req_data['reg_page_id'])
389
-            : EE_Registry::instance()->CFG->core->reg_page_id;
390
-        EE_Registry::instance()->CFG->core->txn_page_id       = isset($this->_req_data['txn_page_id'])
391
-            ? absint($this->_req_data['txn_page_id'])
392
-            : EE_Registry::instance()->CFG->core->txn_page_id;
393
-        EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
394
-            ? absint($this->_req_data['thank_you_page_id'])
395
-            : EE_Registry::instance()->CFG->core->thank_you_page_id;
396
-        EE_Registry::instance()->CFG->core->cancel_page_id    = isset($this->_req_data['cancel_page_id'])
397
-            ? absint($this->_req_data['cancel_page_id'])
398
-            : EE_Registry::instance()->CFG->core->cancel_page_id;
399
-
400
-        EE_Registry::instance()->CFG->core = apply_filters(
401
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
402
-            EE_Registry::instance()->CFG->core,
403
-            $this->_req_data
404
-        );
405
-        $what                              = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
406
-        $this->_redirect_after_action(
407
-            $this->_update_espresso_configuration(
408
-                $what,
409
-                EE_Registry::instance()->CFG->core,
410
-                __FILE__,
411
-                __FUNCTION__,
412
-                __LINE__
413
-            ),
414
-            $what,
415
-            '',
416
-            [
417
-                'action' => 'critical_pages',
418
-            ],
419
-            true
420
-        );
421
-    }
422
-
423
-
424
-    /*************        Your Organization        *************/
425
-
426
-
427
-    /**
428
-     * @throws DomainException
429
-     * @throws EE_Error
430
-     * @throws InvalidArgumentException
431
-     * @throws InvalidDataTypeException
432
-     * @throws InvalidInterfaceException
433
-     */
434
-    protected function _your_organization_settings()
435
-    {
436
-        $this->_template_args['admin_page_content'] = '';
437
-        try {
438
-            /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
439
-            $organization_settings_form                 = $this->loader->getShared(
440
-                'EventEspresso\admin_pages\general_settings\OrganizationSettings'
441
-            );
442
-            $this->_template_args['admin_page_content'] = $organization_settings_form->display();
443
-        } catch (Exception $e) {
444
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
445
-        }
446
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
447
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
448
-        $this->display_admin_page_with_sidebar();
449
-    }
450
-
451
-
452
-    /**
453
-     * Handler for updating organization settings.
454
-     *
455
-     * @throws EE_Error
456
-     */
457
-    protected function _update_your_organization_settings()
458
-    {
459
-        try {
460
-            /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
461
-            $organization_settings_form  = $this->loader->getShared(
462
-                'EventEspresso\admin_pages\general_settings\OrganizationSettings'
463
-            );
464
-            $success                     = $organization_settings_form->process($this->_req_data);
465
-            EE_Registry::instance()->CFG = apply_filters(
466
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
467
-                EE_Registry::instance()->CFG
468
-            );
469
-        } catch (Exception $e) {
470
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
471
-            $success = false;
472
-        }
473
-
474
-        if ($success) {
475
-            $success = $this->_update_espresso_configuration(
476
-                esc_html__('Your Organization Settings', 'event_espresso'),
477
-                EE_Registry::instance()->CFG,
478
-                __FILE__,
479
-                __FUNCTION__,
480
-                __LINE__
481
-            );
482
-        }
483
-
484
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
485
-    }
486
-
487
-
488
-
489
-    /*************        Admin Options        *************/
490
-
491
-
492
-    /**
493
-     * _admin_option_settings
494
-     *
495
-     * @throws EE_Error
496
-     * @throws LogicException
497
-     */
498
-    protected function _admin_option_settings()
499
-    {
500
-        $this->_template_args['admin_page_content'] = '';
501
-        try {
502
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
503
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
504
-            $this->_template_args['values'] = $this->_yes_no_values;
505
-            // also need to account for the do_action that was in the old template
506
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
507
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
508
-        } catch (Exception $e) {
509
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
510
-        }
511
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
512
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
513
-        $this->display_admin_page_with_sidebar();
514
-    }
515
-
516
-
517
-    /**
518
-     * _update_admin_option_settings
519
-     *
520
-     * @throws EE_Error
521
-     * @throws InvalidDataTypeException
522
-     * @throws InvalidFormSubmissionException
523
-     * @throws InvalidArgumentException
524
-     * @throws LogicException
525
-     */
526
-    protected function _update_admin_option_settings()
527
-    {
528
-        try {
529
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
530
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
531
-            EE_Registry::instance()->CFG->admin = apply_filters(
532
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
533
-                EE_Registry::instance()->CFG->admin
534
-            );
535
-        } catch (Exception $e) {
536
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
537
-        }
538
-        $this->_redirect_after_action(
539
-            apply_filters(
540
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
541
-                $this->_update_espresso_configuration(
542
-                    'Admin Options',
543
-                    EE_Registry::instance()->CFG->admin,
544
-                    __FILE__,
545
-                    __FUNCTION__,
546
-                    __LINE__
547
-                )
548
-            ),
549
-            'Admin Options',
550
-            'updated',
551
-            ['action' => 'admin_option_settings']
552
-        );
553
-    }
554
-
555
-
556
-    /*************        Countries        *************/
557
-
558
-
559
-    /**
560
-     * @return string
561
-     */
562
-    protected function getCountryIsoForSite()
563
-    {
564
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
565
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
566
-            : 'US';
567
-    }
568
-
569
-
570
-    /**
571
-     * @param string          $CNT_ISO
572
-     * @param EE_Country|null $country
573
-     * @return EE_Base_Class|EE_Country
574
-     * @throws EE_Error
575
-     * @throws InvalidArgumentException
576
-     * @throws InvalidDataTypeException
577
-     * @throws InvalidInterfaceException
578
-     * @throws ReflectionException
579
-     */
580
-    protected function verifyOrGetCountryFromIso($CNT_ISO, EE_Country $country = null)
581
-    {
582
-        /** @var EE_Country $country */
583
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
584
-            ? $country
585
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
586
-    }
587
-
588
-
589
-    /**
590
-     * Output Country Settings view.
591
-     *
592
-     * @throws DomainException
593
-     * @throws EE_Error
594
-     * @throws InvalidArgumentException
595
-     * @throws InvalidDataTypeException
596
-     * @throws InvalidInterfaceException
597
-     * @throws ReflectionException
598
-     */
599
-    protected function _country_settings()
600
-    {
601
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
602
-        $CNT_ISO          = isset($this->_req_data['country'])
603
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
604
-            : $CNT_ISO_for_site;
605
-
606
-        // load field generator helper
607
-
608
-        $this->_template_args['values'] = $this->_yes_no_values;
609
-
610
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
611
-            EE_Question::new_instance(
612
-                [
613
-                    'QST_ID'           => 0,
614
-                    'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
615
-                    'QST_system'       => 'admin-country',
616
-                ]
617
-            ),
618
-            EE_Answer::new_instance(
619
-                [
620
-                    'ANS_ID'    => 0,
621
-                    'ANS_value' => $CNT_ISO,
622
-                ]
623
-            ),
624
-            [
625
-                'input_id'       => 'country',
626
-                'input_name'     => 'country',
627
-                'input_prefix'   => '',
628
-                'append_qstn_id' => false,
629
-            ]
630
-        );
631
-        $country                           = $this->verifyOrGetCountryFromIso($CNT_ISO_for_site);
632
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
633
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
634
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
635
-            $country->ID(),
636
-            $country
637
-        );
638
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
639
-            $country->ID(),
640
-            $country
641
-        );
642
-        $this->_template_args['CNT_name_for_site']        = $country->name();
643
-
644
-        $this->_set_add_edit_form_tags('update_country_settings');
645
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
646
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
647
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
648
-            $this->_template_args,
649
-            true
650
-        );
651
-        $this->display_admin_page_with_no_sidebar();
652
-    }
653
-
654
-
655
-    /**
656
-     * @param string          $CNT_ISO
657
-     * @param EE_Country|null $country
658
-     * @return string
659
-     * @throws DomainException
660
-     * @throws EE_Error
661
-     * @throws InvalidArgumentException
662
-     * @throws InvalidDataTypeException
663
-     * @throws InvalidInterfaceException
664
-     * @throws ReflectionException
665
-     */
666
-    public function display_country_settings($CNT_ISO = '', EE_Country $country = null)
667
-    {
668
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
669
-
670
-        $CNT_ISO = isset($this->_req_data['country'])
671
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
672
-            : $CNT_ISO;
673
-        if (! $CNT_ISO) {
674
-            return '';
675
-        }
676
-
677
-        // for ajax
678
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
679
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
680
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
681
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
682
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
683
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
684
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
685
-
686
-        $country_input_types            = [
687
-            'CNT_active'      => [
688
-                'type'             => 'RADIO_BTN',
689
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
690
-                'class'            => '',
691
-                'options'          => $this->_yes_no_values,
692
-                'use_desc_4_label' => true,
693
-            ],
694
-            'CNT_ISO'         => [
695
-                'type'       => 'TEXT',
696
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
697
-                'class'      => 'small-text',
698
-            ],
699
-            'CNT_ISO3'        => [
700
-                'type'       => 'TEXT',
701
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
702
-                'class'      => 'small-text',
703
-            ],
704
-            'RGN_ID'          => [
705
-                'type'       => 'TEXT',
706
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
707
-                'class'      => 'small-text',
708
-            ],
709
-            'CNT_name'        => [
710
-                'type'       => 'TEXT',
711
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
712
-                'class'      => 'regular-text',
713
-            ],
714
-            'CNT_cur_code'    => [
715
-                'type'       => 'TEXT',
716
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
717
-                'class'      => 'small-text',
718
-                'disabled'   => $CNT_cur_disabled,
719
-            ],
720
-            'CNT_cur_single'  => [
721
-                'type'       => 'TEXT',
722
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
723
-                'class'      => 'medium-text',
724
-                'disabled'   => $CNT_cur_disabled,
725
-            ],
726
-            'CNT_cur_plural'  => [
727
-                'type'       => 'TEXT',
728
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
729
-                'class'      => 'medium-text',
730
-                'disabled'   => $CNT_cur_disabled,
731
-            ],
732
-            'CNT_cur_sign'    => [
733
-                'type'         => 'TEXT',
734
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
735
-                'class'        => 'small-text',
736
-                'htmlentities' => false,
737
-                'disabled'     => $CNT_cur_disabled,
738
-            ],
739
-            'CNT_cur_sign_b4' => [
740
-                'type'             => 'RADIO_BTN',
741
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
742
-                'class'            => '',
743
-                'options'          => $this->_yes_no_values,
744
-                'use_desc_4_label' => true,
745
-                'disabled'         => $CNT_cur_disabled,
746
-            ],
747
-            'CNT_cur_dec_plc' => [
748
-                'type'       => 'RADIO_BTN',
749
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
750
-                'class'      => '',
751
-                'options'    => [
752
-                    ['id' => 0, 'text' => ''],
753
-                    ['id' => 1, 'text' => ''],
754
-                    ['id' => 2, 'text' => ''],
755
-                    ['id' => 3, 'text' => ''],
756
-                ],
757
-                'disabled'   => $CNT_cur_disabled,
758
-            ],
759
-            'CNT_cur_dec_mrk' => [
760
-                'type'             => 'RADIO_BTN',
761
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
762
-                'class'            => '',
763
-                'options'          => [
764
-                    [
765
-                        'id'   => ',',
766
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
767
-                    ],
768
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
769
-                ],
770
-                'use_desc_4_label' => true,
771
-                'disabled'         => $CNT_cur_disabled,
772
-            ],
773
-            'CNT_cur_thsnds'  => [
774
-                'type'             => 'RADIO_BTN',
775
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
776
-                'class'            => '',
777
-                'options'          => [
778
-                    [
779
-                        'id'   => ',',
780
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
781
-                    ],
782
-                    [
783
-                        'id'   => '.',
784
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
785
-                    ],
786
-                    [
787
-                        'id'   => '&nbsp;',
788
-                        'text' => esc_html__('(space)', 'event_espresso'),
789
-                    ],
790
-                ],
791
-                'use_desc_4_label' => true,
792
-                'disabled'         => $CNT_cur_disabled,
793
-            ],
794
-            'CNT_tel_code'    => [
795
-                'type'       => 'TEXT',
796
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
797
-                'class'      => 'small-text',
798
-            ],
799
-            'CNT_is_EU'       => [
800
-                'type'             => 'RADIO_BTN',
801
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
802
-                'class'            => '',
803
-                'options'          => $this->_yes_no_values,
804
-                'use_desc_4_label' => true,
805
-            ],
806
-        ];
807
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
808
-            $country,
809
-            $country_input_types
810
-        );
811
-        $country_details_settings       = EEH_Template::display_template(
812
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
813
-            $this->_template_args,
814
-            true
815
-        );
816
-
817
-        if (defined('DOING_AJAX')) {
818
-            $notices = EE_Error::get_notices(false, false, false);
819
-            echo wp_json_encode(
820
-                [
821
-                    'return_data' => $country_details_settings,
822
-                    'success'     => $notices['success'],
823
-                    'errors'      => $notices['errors'],
824
-                ]
825
-            );
826
-            die();
827
-        } else {
828
-            return $country_details_settings;
829
-        }
830
-    }
831
-
832
-
833
-    /**
834
-     * @param string          $CNT_ISO
835
-     * @param EE_Country|null $country
836
-     * @return string
837
-     * @throws DomainException
838
-     * @throws EE_Error
839
-     * @throws InvalidArgumentException
840
-     * @throws InvalidDataTypeException
841
-     * @throws InvalidInterfaceException
842
-     * @throws ReflectionException
843
-     */
844
-    public function display_country_states($CNT_ISO = '', EE_Country $country = null)
845
-    {
846
-
847
-        $CNT_ISO = isset($this->_req_data['country'])
848
-            ? sanitize_text_field($this->_req_data['country'])
849
-            : $CNT_ISO;
850
-        if (! $CNT_ISO) {
851
-            return '';
852
-        }
853
-        // for ajax
854
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
855
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
856
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
857
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10, 2);
858
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
859
-        if (empty($states)) {
860
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
861
-            $countrySubRegionDao = $this->loader->getShared(
862
-                'EventEspresso\core\services\address\CountrySubRegionDao'
863
-            );
864
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
865
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
866
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
867
-                    $states = EEM_State::instance()->get_all_states_for_these_countries(
868
-                        [$CNT_ISO => $CNT_ISO]
869
-                    );
870
-                }
871
-            }
872
-        }
873
-        if (is_array($states)) {
874
-            foreach ($states as $STA_ID => $state) {
875
-                if ($state instanceof EE_State) {
876
-                    // STA_abbrev    STA_name    STA_active
877
-                    $state_input_types                                             = [
878
-                        'STA_abbrev' => [
879
-                            'type'       => 'TEXT',
880
-                            'input_name' => 'states[' . $STA_ID . ']',
881
-                            'class'      => 'small-text',
882
-                        ],
883
-                        'STA_name'   => [
884
-                            'type'       => 'TEXT',
885
-                            'input_name' => 'states[' . $STA_ID . ']',
886
-                            'class'      => 'regular-text',
887
-                        ],
888
-                        'STA_active' => [
889
-                            'type'             => 'RADIO_BTN',
890
-                            'input_name'       => 'states[' . $STA_ID . ']',
891
-                            'options'          => $this->_yes_no_values,
892
-                            'use_desc_4_label' => true,
893
-                        ],
894
-                    ];
895
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           =
896
-                        EE_Question_Form_Input::generate_question_form_inputs_for_object(
897
-                            $state,
898
-                            $state_input_types
899
-                        );
900
-                    $query_args                                                    = [
901
-                        'action'     => 'delete_state',
902
-                        'STA_ID'     => $STA_ID,
903
-                        'CNT_ISO'    => $CNT_ISO,
904
-                        'STA_abbrev' => $state->abbrev(),
905
-                    ];
906
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
907
-                        EE_Admin_Page::add_query_args_and_nonce(
908
-                            $query_args,
909
-                            GEN_SET_ADMIN_URL
910
-                        );
911
-                }
912
-            }
913
-        } else {
914
-            $this->_template_args['states'] = false;
915
-        }
916
-
917
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
918
-            ['action' => 'add_new_state'],
919
-            GEN_SET_ADMIN_URL
920
-        );
921
-
922
-        $state_details_settings = EEH_Template::display_template(
923
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
924
-            $this->_template_args,
925
-            true
926
-        );
927
-
928
-        if (defined('DOING_AJAX')) {
929
-            $notices = EE_Error::get_notices(false, false, false);
930
-            echo wp_json_encode(
931
-                [
932
-                    'return_data' => $state_details_settings,
933
-                    'success'     => $notices['success'],
934
-                    'errors'      => $notices['errors'],
935
-                ]
936
-            );
937
-            die();
938
-        } else {
939
-            return $state_details_settings;
940
-        }
941
-    }
942
-
943
-
944
-    /**
945
-     *        add_new_state
946
-     *
947
-     * @access    public
948
-     * @return void
949
-     * @throws EE_Error
950
-     * @throws InvalidArgumentException
951
-     * @throws InvalidDataTypeException
952
-     * @throws InvalidInterfaceException
953
-     */
954
-    public function add_new_state()
955
-    {
956
-
957
-        $success = true;
958
-
959
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
960
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
961
-            : false;
962
-        if (! $CNT_ISO) {
963
-            EE_Error::add_error(
964
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
965
-                __FILE__,
966
-                __FUNCTION__,
967
-                __LINE__
968
-            );
969
-            $success = false;
970
-        }
971
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
972
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
973
-            : false;
974
-        if (! $STA_abbrev) {
975
-            EE_Error::add_error(
976
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
977
-                __FILE__,
978
-                __FUNCTION__,
979
-                __LINE__
980
-            );
981
-            $success = false;
982
-        }
983
-        $STA_name = isset($this->_req_data['STA_name'])
984
-            ? sanitize_text_field($this->_req_data['STA_name'])
985
-            : false;
986
-        if (! $STA_name) {
987
-            EE_Error::add_error(
988
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
989
-                __FILE__,
990
-                __FUNCTION__,
991
-                __LINE__
992
-            );
993
-            $success = false;
994
-        }
995
-
996
-        if ($success) {
997
-            $cols_n_values = [
998
-                'CNT_ISO'    => $CNT_ISO,
999
-                'STA_abbrev' => $STA_abbrev,
1000
-                'STA_name'   => $STA_name,
1001
-                'STA_active' => true,
1002
-            ];
1003
-            $success       = EEM_State::instance()->insert($cols_n_values);
1004
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1005
-        }
1006
-
1007
-        if (defined('DOING_AJAX')) {
1008
-            $notices = EE_Error::get_notices(false, false, false);
1009
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1010
-            die();
1011
-        } else {
1012
-            $this->_redirect_after_action($success, 'State', 'added', ['action' => 'country_settings']);
1013
-        }
1014
-    }
1015
-
1016
-
1017
-    /**
1018
-     * @return void
1019
-     * @throws EE_Error
1020
-     * @throws InvalidArgumentException
1021
-     * @throws InvalidDataTypeException
1022
-     * @throws InvalidInterfaceException
1023
-     */
1024
-    public function delete_state()
1025
-    {
1026
-        $CNT_ISO    = isset($this->_req_data['CNT_ISO'])
1027
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1028
-            : false;
1029
-        $STA_ID     = isset($this->_req_data['STA_ID'])
1030
-            ? sanitize_text_field($this->_req_data['STA_ID'])
1031
-            : false;
1032
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1033
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
1034
-            : false;
1035
-        if (! $STA_ID) {
1036
-            EE_Error::add_error(
1037
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1038
-                __FILE__,
1039
-                __FUNCTION__,
1040
-                __LINE__
1041
-            );
1042
-            return;
1043
-        }
1044
-
1045
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1046
-        if ($success !== false) {
1047
-            do_action(
1048
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1049
-                $CNT_ISO,
1050
-                $STA_ID,
1051
-                ['STA_abbrev' => $STA_abbrev]
1052
-            );
1053
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1054
-        }
1055
-        if (defined('DOING_AJAX')) {
1056
-            $notices                = EE_Error::get_notices(false);
1057
-            $notices['return_data'] = true;
1058
-            echo wp_json_encode($notices);
1059
-            die();
1060
-        } else {
1061
-            $this->_redirect_after_action(
1062
-                $success,
1063
-                'State',
1064
-                'deleted',
1065
-                ['action' => 'country_settings']
1066
-            );
1067
-        }
1068
-    }
1069
-
1070
-
1071
-    /**
1072
-     *        _update_country_settings
1073
-     *
1074
-     * @return void
1075
-     * @throws EE_Error
1076
-     * @throws InvalidArgumentException
1077
-     * @throws InvalidDataTypeException
1078
-     * @throws InvalidInterfaceException
1079
-     */
1080
-    protected function _update_country_settings()
1081
-    {
1082
-        // grab the country ISO code
1083
-        $CNT_ISO = isset($this->_req_data['country'])
1084
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
1085
-            : false;
1086
-        if (! $CNT_ISO) {
1087
-            EE_Error::add_error(
1088
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1089
-                __FILE__,
1090
-                __FUNCTION__,
1091
-                __LINE__
1092
-            );
1093
-
1094
-            return;
1095
-        }
1096
-        $cols_n_values             = [];
1097
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1098
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1099
-            : false;
1100
-        $cols_n_values['RGN_ID']   = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1101
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1102
-            : null;
1103
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1104
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1105
-            : null;
1106
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1107
-            $cols_n_values['CNT_cur_code'] = strtoupper(
1108
-                sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1109
-            );
1110
-        }
1111
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1112
-            $cols_n_values['CNT_cur_single'] = sanitize_text_field(
1113
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1114
-            );
1115
-        }
1116
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1117
-            $cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1118
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1119
-            );
1120
-        }
1121
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1122
-            $cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1123
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1124
-            );
1125
-        }
1126
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1127
-            $cols_n_values['CNT_cur_sign_b4'] = absint(
1128
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1129
-            );
1130
-        }
1131
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1132
-            $cols_n_values['CNT_cur_dec_plc'] = absint(
1133
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1134
-            );
1135
-        }
1136
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1137
-            $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1138
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1139
-            );
1140
-        }
1141
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1142
-            $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1143
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1144
-            );
1145
-        }
1146
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1147
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1148
-            : null;
1149
-        $cols_n_values['CNT_is_EU']    = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1150
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1151
-            : false;
1152
-        $cols_n_values['CNT_active']   = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1153
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1154
-            : false;
1155
-        // allow filtering of country data
1156
-        $cols_n_values = apply_filters(
1157
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1158
-            $cols_n_values
1159
-        );
1160
-
1161
-        // where values
1162
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1163
-        // run the update
1164
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1165
-
1166
-        if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1167
-            // allow filtering of states data
1168
-            $states = apply_filters(
1169
-                'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1170
-                $this->_req_data['states']
1171
-            );
1172
-
1173
-            // loop thru state data ( looks like : states[75][STA_name] )
1174
-            foreach ($states as $STA_ID => $state) {
1175
-                $cols_n_values = [
1176
-                    'CNT_ISO'    => $CNT_ISO,
1177
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1178
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1179
-                    'STA_active' => (bool) absint($state['STA_active']),
1180
-                ];
1181
-                // where values
1182
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1183
-                // run the update
1184
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1185
-                if ($success !== false) {
1186
-                    do_action(
1187
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1188
-                        $CNT_ISO,
1189
-                        $STA_ID,
1190
-                        $cols_n_values
1191
-                    );
1192
-                }
1193
-            }
1194
-        }
1195
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1196
-        if (
1197
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1198
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1199
-        ) {
1200
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1201
-            EE_Registry::instance()->CFG->update_espresso_config();
1202
-        }
1203
-
1204
-        if ($success !== false) {
1205
-            EE_Error::add_success(
1206
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1207
-            );
1208
-        }
1209
-        $this->_redirect_after_action(
1210
-            $success,
1211
-            '',
1212
-            '',
1213
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1214
-            true
1215
-        );
1216
-    }
1217
-
1218
-
1219
-    /**
1220
-     *        form_form_field_label_wrap
1221
-     *
1222
-     * @param string $label
1223
-     * @return        string
1224
-     */
1225
-    public function country_form_field_label_wrap($label, $required_text)
1226
-    {
1227
-        return '
21
+	/**
22
+	 * _question_group
23
+	 * holds the specific question group object for the question group details screen
24
+	 *
25
+	 * @var object
26
+	 */
27
+	protected $_question_group;
28
+
29
+
30
+	/**
31
+	 * Initialize basic properties.
32
+	 */
33
+	protected function _init_page_props()
34
+	{
35
+		$this->page_slug        = GEN_SET_PG_SLUG;
36
+		$this->page_label       = GEN_SET_LABEL;
37
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
38
+		$this->_admin_base_path = GEN_SET_ADMIN;
39
+	}
40
+
41
+
42
+	/**
43
+	 * Set ajax hooks
44
+	 */
45
+	protected function _ajax_hooks()
46
+	{
47
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
48
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
49
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
50
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
51
+	}
52
+
53
+
54
+	/**
55
+	 * More page properties initialization.
56
+	 */
57
+	protected function _define_page_props()
58
+	{
59
+		$this->_admin_page_title = GEN_SET_LABEL;
60
+		$this->_labels           = [
61
+			'publishbox' => esc_html__('Update Settings', 'event_espresso'),
62
+		];
63
+	}
64
+
65
+
66
+	/**
67
+	 * Set page routes property.
68
+	 */
69
+	protected function _set_page_routes()
70
+	{
71
+		$this->_page_routes = [
72
+
73
+			'critical_pages'                => [
74
+				'func'       => '_espresso_page_settings',
75
+				'capability' => 'manage_options',
76
+			],
77
+			'update_espresso_page_settings' => [
78
+				'func'       => '_update_espresso_page_settings',
79
+				'capability' => 'manage_options',
80
+				'noheader'   => true,
81
+			],
82
+			'default'                       => [
83
+				'func'       => '_your_organization_settings',
84
+				'capability' => 'manage_options',
85
+			],
86
+
87
+			'update_your_organization_settings' => [
88
+				'func'       => '_update_your_organization_settings',
89
+				'capability' => 'manage_options',
90
+				'noheader'   => true,
91
+			],
92
+
93
+			'admin_option_settings' => [
94
+				'func'       => '_admin_option_settings',
95
+				'capability' => 'manage_options',
96
+			],
97
+
98
+			'update_admin_option_settings' => [
99
+				'func'       => '_update_admin_option_settings',
100
+				'capability' => 'manage_options',
101
+				'noheader'   => true,
102
+			],
103
+
104
+			'country_settings' => [
105
+				'func'       => '_country_settings',
106
+				'capability' => 'manage_options',
107
+			],
108
+
109
+			'update_country_settings' => [
110
+				'func'       => '_update_country_settings',
111
+				'capability' => 'manage_options',
112
+				'noheader'   => true,
113
+			],
114
+
115
+			'display_country_settings' => [
116
+				'func'       => 'display_country_settings',
117
+				'capability' => 'manage_options',
118
+				'noheader'   => true,
119
+			],
120
+
121
+			'add_new_state' => [
122
+				'func'       => 'add_new_state',
123
+				'capability' => 'manage_options',
124
+				'noheader'   => true,
125
+			],
126
+
127
+			'delete_state'            => [
128
+				'func'       => 'delete_state',
129
+				'capability' => 'manage_options',
130
+				'noheader'   => true,
131
+			],
132
+			'privacy_settings'        => [
133
+				'func'       => 'privacySettings',
134
+				'capability' => 'manage_options',
135
+			],
136
+			'update_privacy_settings' => [
137
+				'func'               => 'updatePrivacySettings',
138
+				'capability'         => 'manage_options',
139
+				'noheader'           => true,
140
+				'headers_sent_route' => 'privacy_settings',
141
+			],
142
+		];
143
+	}
144
+
145
+
146
+	/**
147
+	 * Set page configuration property
148
+	 */
149
+	protected function _set_page_config()
150
+	{
151
+		$this->_page_config = [
152
+			'critical_pages'        => [
153
+				'nav'           => [
154
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
155
+					'order' => 50,
156
+				],
157
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
158
+				'help_tabs'     => [
159
+					'general_settings_critical_pages_help_tab' => [
160
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
161
+						'filename' => 'general_settings_critical_pages',
162
+					],
163
+				],
164
+				'require_nonce' => false,
165
+			],
166
+			'default'               => [
167
+				'nav'           => [
168
+					'label' => esc_html__('Your Organization', 'event_espresso'),
169
+					'order' => 20,
170
+				],
171
+				'help_tabs'     => [
172
+					'general_settings_your_organization_help_tab' => [
173
+						'title'    => esc_html__('Your Organization', 'event_espresso'),
174
+						'filename' => 'general_settings_your_organization',
175
+					],
176
+				],
177
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
178
+				'require_nonce' => false,
179
+			],
180
+			'admin_option_settings' => [
181
+				'nav'           => [
182
+					'label' => esc_html__('Admin Options', 'event_espresso'),
183
+					'order' => 60,
184
+				],
185
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
186
+				'help_tabs'     => [
187
+					'general_settings_admin_options_help_tab' => [
188
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
189
+						'filename' => 'general_settings_admin_options',
190
+					],
191
+				],
192
+				'require_nonce' => false,
193
+			],
194
+			'country_settings'      => [
195
+				'nav'           => [
196
+					'label' => esc_html__('Countries', 'event_espresso'),
197
+					'order' => 70,
198
+				],
199
+				'help_tabs'     => [
200
+					'general_settings_countries_help_tab' => [
201
+						'title'    => esc_html__('Countries', 'event_espresso'),
202
+						'filename' => 'general_settings_countries',
203
+					],
204
+				],
205
+				'require_nonce' => false,
206
+			],
207
+			'privacy_settings'      => [
208
+				'nav'           => [
209
+					'label' => esc_html__('Privacy', 'event_espresso'),
210
+					'order' => 80,
211
+				],
212
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
213
+				'require_nonce' => false,
214
+			],
215
+		];
216
+	}
217
+
218
+
219
+	protected function _add_screen_options()
220
+	{
221
+	}
222
+
223
+
224
+	protected function _add_feature_pointers()
225
+	{
226
+	}
227
+
228
+
229
+	/**
230
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
231
+	 */
232
+	public function load_scripts_styles()
233
+	{
234
+		// styles
235
+		wp_enqueue_style('espresso-ui-theme');
236
+		// scripts
237
+		wp_enqueue_script('ee_admin_js');
238
+	}
239
+
240
+
241
+	/**
242
+	 * Execute logic running on `admin_init`
243
+	 */
244
+	public function admin_init()
245
+	{
246
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(__(
247
+			'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
248
+			'event_espresso'
249
+		));
250
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(__(
251
+			'An error occurred! Please refresh the page and try again.',
252
+			'event_espresso'
253
+		));
254
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(__(
255
+			'Are you sure you want to delete this State / Province?',
256
+			'event_espresso'
257
+		));
258
+		$protocol                                                = is_ssl() ? 'https://' : 'http://';
259
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
260
+			'admin-ajax.php?page=espresso_general_settings',
261
+			$protocol
262
+		);
263
+	}
264
+
265
+
266
+	public function admin_notices()
267
+	{
268
+	}
269
+
270
+
271
+	public function admin_footer_scripts()
272
+	{
273
+	}
274
+
275
+
276
+	/**
277
+	 * Enqueue scripts and styles for the default route.
278
+	 */
279
+	public function load_scripts_styles_default()
280
+	{
281
+		// styles
282
+		wp_enqueue_style('thickbox');
283
+		// scripts
284
+		wp_enqueue_script('media-upload');
285
+		wp_enqueue_script('thickbox');
286
+		wp_register_script(
287
+			'organization_settings',
288
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
289
+			['jquery', 'media-upload', 'thickbox'],
290
+			EVENT_ESPRESSO_VERSION,
291
+			true
292
+		);
293
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
294
+		wp_enqueue_script('organization_settings');
295
+		wp_enqueue_style('organization-css');
296
+		$confirm_image_delete = [
297
+			'text' => wp_strip_all_tags(
298
+				__(
299
+					'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
300
+					'event_espresso'
301
+				)
302
+			),
303
+		];
304
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
305
+	}
306
+
307
+
308
+	/**
309
+	 * Enqueue scripts and styles for the country settings route.
310
+	 */
311
+	public function load_scripts_styles_country_settings()
312
+	{
313
+		// scripts
314
+		wp_register_script(
315
+			'gen_settings_countries',
316
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
317
+			['ee_admin_js'],
318
+			EVENT_ESPRESSO_VERSION,
319
+			true
320
+		);
321
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
322
+		wp_enqueue_script('gen_settings_countries');
323
+		wp_enqueue_style('organization-css');
324
+	}
325
+
326
+
327
+	/*************        Espresso Pages        *************/
328
+	/**
329
+	 * _espresso_page_settings
330
+	 *
331
+	 * @throws EE_Error
332
+	 * @throws DomainException
333
+	 * @throws DomainException
334
+	 * @throws InvalidDataTypeException
335
+	 * @throws InvalidArgumentException
336
+	 */
337
+	protected function _espresso_page_settings()
338
+	{
339
+		// Check to make sure all of the main pages are set up properly,
340
+		// if not create the default pages and display an admin notice
341
+		EEH_Activation::verify_default_pages_exist();
342
+		$this->_transient_garbage_collection();
343
+		$this->_template_args['values']             = $this->_yes_no_values;
344
+		$this->_template_args['reg_page_id']        = isset(EE_Registry::instance()->CFG->core->reg_page_id)
345
+			? EE_Registry::instance()->CFG->core->reg_page_id
346
+			: null;
347
+		$this->_template_args['reg_page_obj']       = isset(EE_Registry::instance()->CFG->core->reg_page_id)
348
+			? get_post(EE_Registry::instance()->CFG->core->reg_page_id)
349
+			: false;
350
+		$this->_template_args['txn_page_id']        = isset(EE_Registry::instance()->CFG->core->txn_page_id)
351
+			? EE_Registry::instance()->CFG->core->txn_page_id
352
+			: null;
353
+		$this->_template_args['txn_page_obj']       = isset(EE_Registry::instance()->CFG->core->txn_page_id)
354
+			? get_post(EE_Registry::instance()->CFG->core->txn_page_id)
355
+			: false;
356
+		$this->_template_args['thank_you_page_id']  = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
357
+			? EE_Registry::instance()->CFG->core->thank_you_page_id
358
+			: null;
359
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
360
+			? get_post(EE_Registry::instance()->CFG->core->thank_you_page_id)
361
+			: false;
362
+		$this->_template_args['cancel_page_id']     = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
363
+			? EE_Registry::instance()->CFG->core->cancel_page_id
364
+			: null;
365
+		$this->_template_args['cancel_page_obj']    = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
366
+			? get_post(EE_Registry::instance()->CFG->core->cancel_page_id)
367
+			: false;
368
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
369
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
370
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
372
+			$this->_template_args,
373
+			true
374
+		);
375
+		$this->display_admin_page_with_sidebar();
376
+	}
377
+
378
+
379
+	/**
380
+	 * Handler for updating espresso page settings.
381
+	 *
382
+	 * @throws EE_Error
383
+	 */
384
+	protected function _update_espresso_page_settings()
385
+	{
386
+		// capture incoming request data && set page IDs
387
+		EE_Registry::instance()->CFG->core->reg_page_id       = isset($this->_req_data['reg_page_id'])
388
+			? absint($this->_req_data['reg_page_id'])
389
+			: EE_Registry::instance()->CFG->core->reg_page_id;
390
+		EE_Registry::instance()->CFG->core->txn_page_id       = isset($this->_req_data['txn_page_id'])
391
+			? absint($this->_req_data['txn_page_id'])
392
+			: EE_Registry::instance()->CFG->core->txn_page_id;
393
+		EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
394
+			? absint($this->_req_data['thank_you_page_id'])
395
+			: EE_Registry::instance()->CFG->core->thank_you_page_id;
396
+		EE_Registry::instance()->CFG->core->cancel_page_id    = isset($this->_req_data['cancel_page_id'])
397
+			? absint($this->_req_data['cancel_page_id'])
398
+			: EE_Registry::instance()->CFG->core->cancel_page_id;
399
+
400
+		EE_Registry::instance()->CFG->core = apply_filters(
401
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
402
+			EE_Registry::instance()->CFG->core,
403
+			$this->_req_data
404
+		);
405
+		$what                              = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
406
+		$this->_redirect_after_action(
407
+			$this->_update_espresso_configuration(
408
+				$what,
409
+				EE_Registry::instance()->CFG->core,
410
+				__FILE__,
411
+				__FUNCTION__,
412
+				__LINE__
413
+			),
414
+			$what,
415
+			'',
416
+			[
417
+				'action' => 'critical_pages',
418
+			],
419
+			true
420
+		);
421
+	}
422
+
423
+
424
+	/*************        Your Organization        *************/
425
+
426
+
427
+	/**
428
+	 * @throws DomainException
429
+	 * @throws EE_Error
430
+	 * @throws InvalidArgumentException
431
+	 * @throws InvalidDataTypeException
432
+	 * @throws InvalidInterfaceException
433
+	 */
434
+	protected function _your_organization_settings()
435
+	{
436
+		$this->_template_args['admin_page_content'] = '';
437
+		try {
438
+			/** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
439
+			$organization_settings_form                 = $this->loader->getShared(
440
+				'EventEspresso\admin_pages\general_settings\OrganizationSettings'
441
+			);
442
+			$this->_template_args['admin_page_content'] = $organization_settings_form->display();
443
+		} catch (Exception $e) {
444
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
445
+		}
446
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
447
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
448
+		$this->display_admin_page_with_sidebar();
449
+	}
450
+
451
+
452
+	/**
453
+	 * Handler for updating organization settings.
454
+	 *
455
+	 * @throws EE_Error
456
+	 */
457
+	protected function _update_your_organization_settings()
458
+	{
459
+		try {
460
+			/** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
461
+			$organization_settings_form  = $this->loader->getShared(
462
+				'EventEspresso\admin_pages\general_settings\OrganizationSettings'
463
+			);
464
+			$success                     = $organization_settings_form->process($this->_req_data);
465
+			EE_Registry::instance()->CFG = apply_filters(
466
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
467
+				EE_Registry::instance()->CFG
468
+			);
469
+		} catch (Exception $e) {
470
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
471
+			$success = false;
472
+		}
473
+
474
+		if ($success) {
475
+			$success = $this->_update_espresso_configuration(
476
+				esc_html__('Your Organization Settings', 'event_espresso'),
477
+				EE_Registry::instance()->CFG,
478
+				__FILE__,
479
+				__FUNCTION__,
480
+				__LINE__
481
+			);
482
+		}
483
+
484
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
485
+	}
486
+
487
+
488
+
489
+	/*************        Admin Options        *************/
490
+
491
+
492
+	/**
493
+	 * _admin_option_settings
494
+	 *
495
+	 * @throws EE_Error
496
+	 * @throws LogicException
497
+	 */
498
+	protected function _admin_option_settings()
499
+	{
500
+		$this->_template_args['admin_page_content'] = '';
501
+		try {
502
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
503
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
504
+			$this->_template_args['values'] = $this->_yes_no_values;
505
+			// also need to account for the do_action that was in the old template
506
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
507
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
508
+		} catch (Exception $e) {
509
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
510
+		}
511
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
512
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
513
+		$this->display_admin_page_with_sidebar();
514
+	}
515
+
516
+
517
+	/**
518
+	 * _update_admin_option_settings
519
+	 *
520
+	 * @throws EE_Error
521
+	 * @throws InvalidDataTypeException
522
+	 * @throws InvalidFormSubmissionException
523
+	 * @throws InvalidArgumentException
524
+	 * @throws LogicException
525
+	 */
526
+	protected function _update_admin_option_settings()
527
+	{
528
+		try {
529
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
530
+			$admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
531
+			EE_Registry::instance()->CFG->admin = apply_filters(
532
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
533
+				EE_Registry::instance()->CFG->admin
534
+			);
535
+		} catch (Exception $e) {
536
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
537
+		}
538
+		$this->_redirect_after_action(
539
+			apply_filters(
540
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
541
+				$this->_update_espresso_configuration(
542
+					'Admin Options',
543
+					EE_Registry::instance()->CFG->admin,
544
+					__FILE__,
545
+					__FUNCTION__,
546
+					__LINE__
547
+				)
548
+			),
549
+			'Admin Options',
550
+			'updated',
551
+			['action' => 'admin_option_settings']
552
+		);
553
+	}
554
+
555
+
556
+	/*************        Countries        *************/
557
+
558
+
559
+	/**
560
+	 * @return string
561
+	 */
562
+	protected function getCountryIsoForSite()
563
+	{
564
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
565
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
566
+			: 'US';
567
+	}
568
+
569
+
570
+	/**
571
+	 * @param string          $CNT_ISO
572
+	 * @param EE_Country|null $country
573
+	 * @return EE_Base_Class|EE_Country
574
+	 * @throws EE_Error
575
+	 * @throws InvalidArgumentException
576
+	 * @throws InvalidDataTypeException
577
+	 * @throws InvalidInterfaceException
578
+	 * @throws ReflectionException
579
+	 */
580
+	protected function verifyOrGetCountryFromIso($CNT_ISO, EE_Country $country = null)
581
+	{
582
+		/** @var EE_Country $country */
583
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
584
+			? $country
585
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
586
+	}
587
+
588
+
589
+	/**
590
+	 * Output Country Settings view.
591
+	 *
592
+	 * @throws DomainException
593
+	 * @throws EE_Error
594
+	 * @throws InvalidArgumentException
595
+	 * @throws InvalidDataTypeException
596
+	 * @throws InvalidInterfaceException
597
+	 * @throws ReflectionException
598
+	 */
599
+	protected function _country_settings()
600
+	{
601
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
602
+		$CNT_ISO          = isset($this->_req_data['country'])
603
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
604
+			: $CNT_ISO_for_site;
605
+
606
+		// load field generator helper
607
+
608
+		$this->_template_args['values'] = $this->_yes_no_values;
609
+
610
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
611
+			EE_Question::new_instance(
612
+				[
613
+					'QST_ID'           => 0,
614
+					'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
615
+					'QST_system'       => 'admin-country',
616
+				]
617
+			),
618
+			EE_Answer::new_instance(
619
+				[
620
+					'ANS_ID'    => 0,
621
+					'ANS_value' => $CNT_ISO,
622
+				]
623
+			),
624
+			[
625
+				'input_id'       => 'country',
626
+				'input_name'     => 'country',
627
+				'input_prefix'   => '',
628
+				'append_qstn_id' => false,
629
+			]
630
+		);
631
+		$country                           = $this->verifyOrGetCountryFromIso($CNT_ISO_for_site);
632
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
633
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
634
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
635
+			$country->ID(),
636
+			$country
637
+		);
638
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
639
+			$country->ID(),
640
+			$country
641
+		);
642
+		$this->_template_args['CNT_name_for_site']        = $country->name();
643
+
644
+		$this->_set_add_edit_form_tags('update_country_settings');
645
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
646
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
647
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
648
+			$this->_template_args,
649
+			true
650
+		);
651
+		$this->display_admin_page_with_no_sidebar();
652
+	}
653
+
654
+
655
+	/**
656
+	 * @param string          $CNT_ISO
657
+	 * @param EE_Country|null $country
658
+	 * @return string
659
+	 * @throws DomainException
660
+	 * @throws EE_Error
661
+	 * @throws InvalidArgumentException
662
+	 * @throws InvalidDataTypeException
663
+	 * @throws InvalidInterfaceException
664
+	 * @throws ReflectionException
665
+	 */
666
+	public function display_country_settings($CNT_ISO = '', EE_Country $country = null)
667
+	{
668
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
669
+
670
+		$CNT_ISO = isset($this->_req_data['country'])
671
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
672
+			: $CNT_ISO;
673
+		if (! $CNT_ISO) {
674
+			return '';
675
+		}
676
+
677
+		// for ajax
678
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
679
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
680
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
681
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
682
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
683
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
684
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
685
+
686
+		$country_input_types            = [
687
+			'CNT_active'      => [
688
+				'type'             => 'RADIO_BTN',
689
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
690
+				'class'            => '',
691
+				'options'          => $this->_yes_no_values,
692
+				'use_desc_4_label' => true,
693
+			],
694
+			'CNT_ISO'         => [
695
+				'type'       => 'TEXT',
696
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
697
+				'class'      => 'small-text',
698
+			],
699
+			'CNT_ISO3'        => [
700
+				'type'       => 'TEXT',
701
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
702
+				'class'      => 'small-text',
703
+			],
704
+			'RGN_ID'          => [
705
+				'type'       => 'TEXT',
706
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
707
+				'class'      => 'small-text',
708
+			],
709
+			'CNT_name'        => [
710
+				'type'       => 'TEXT',
711
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
712
+				'class'      => 'regular-text',
713
+			],
714
+			'CNT_cur_code'    => [
715
+				'type'       => 'TEXT',
716
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
717
+				'class'      => 'small-text',
718
+				'disabled'   => $CNT_cur_disabled,
719
+			],
720
+			'CNT_cur_single'  => [
721
+				'type'       => 'TEXT',
722
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
723
+				'class'      => 'medium-text',
724
+				'disabled'   => $CNT_cur_disabled,
725
+			],
726
+			'CNT_cur_plural'  => [
727
+				'type'       => 'TEXT',
728
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
729
+				'class'      => 'medium-text',
730
+				'disabled'   => $CNT_cur_disabled,
731
+			],
732
+			'CNT_cur_sign'    => [
733
+				'type'         => 'TEXT',
734
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
735
+				'class'        => 'small-text',
736
+				'htmlentities' => false,
737
+				'disabled'     => $CNT_cur_disabled,
738
+			],
739
+			'CNT_cur_sign_b4' => [
740
+				'type'             => 'RADIO_BTN',
741
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
742
+				'class'            => '',
743
+				'options'          => $this->_yes_no_values,
744
+				'use_desc_4_label' => true,
745
+				'disabled'         => $CNT_cur_disabled,
746
+			],
747
+			'CNT_cur_dec_plc' => [
748
+				'type'       => 'RADIO_BTN',
749
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
750
+				'class'      => '',
751
+				'options'    => [
752
+					['id' => 0, 'text' => ''],
753
+					['id' => 1, 'text' => ''],
754
+					['id' => 2, 'text' => ''],
755
+					['id' => 3, 'text' => ''],
756
+				],
757
+				'disabled'   => $CNT_cur_disabled,
758
+			],
759
+			'CNT_cur_dec_mrk' => [
760
+				'type'             => 'RADIO_BTN',
761
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
762
+				'class'            => '',
763
+				'options'          => [
764
+					[
765
+						'id'   => ',',
766
+						'text' => esc_html__(', (comma)', 'event_espresso'),
767
+					],
768
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
769
+				],
770
+				'use_desc_4_label' => true,
771
+				'disabled'         => $CNT_cur_disabled,
772
+			],
773
+			'CNT_cur_thsnds'  => [
774
+				'type'             => 'RADIO_BTN',
775
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
776
+				'class'            => '',
777
+				'options'          => [
778
+					[
779
+						'id'   => ',',
780
+						'text' => esc_html__(', (comma)', 'event_espresso'),
781
+					],
782
+					[
783
+						'id'   => '.',
784
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
785
+					],
786
+					[
787
+						'id'   => '&nbsp;',
788
+						'text' => esc_html__('(space)', 'event_espresso'),
789
+					],
790
+				],
791
+				'use_desc_4_label' => true,
792
+				'disabled'         => $CNT_cur_disabled,
793
+			],
794
+			'CNT_tel_code'    => [
795
+				'type'       => 'TEXT',
796
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
797
+				'class'      => 'small-text',
798
+			],
799
+			'CNT_is_EU'       => [
800
+				'type'             => 'RADIO_BTN',
801
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
802
+				'class'            => '',
803
+				'options'          => $this->_yes_no_values,
804
+				'use_desc_4_label' => true,
805
+			],
806
+		];
807
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
808
+			$country,
809
+			$country_input_types
810
+		);
811
+		$country_details_settings       = EEH_Template::display_template(
812
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
813
+			$this->_template_args,
814
+			true
815
+		);
816
+
817
+		if (defined('DOING_AJAX')) {
818
+			$notices = EE_Error::get_notices(false, false, false);
819
+			echo wp_json_encode(
820
+				[
821
+					'return_data' => $country_details_settings,
822
+					'success'     => $notices['success'],
823
+					'errors'      => $notices['errors'],
824
+				]
825
+			);
826
+			die();
827
+		} else {
828
+			return $country_details_settings;
829
+		}
830
+	}
831
+
832
+
833
+	/**
834
+	 * @param string          $CNT_ISO
835
+	 * @param EE_Country|null $country
836
+	 * @return string
837
+	 * @throws DomainException
838
+	 * @throws EE_Error
839
+	 * @throws InvalidArgumentException
840
+	 * @throws InvalidDataTypeException
841
+	 * @throws InvalidInterfaceException
842
+	 * @throws ReflectionException
843
+	 */
844
+	public function display_country_states($CNT_ISO = '', EE_Country $country = null)
845
+	{
846
+
847
+		$CNT_ISO = isset($this->_req_data['country'])
848
+			? sanitize_text_field($this->_req_data['country'])
849
+			: $CNT_ISO;
850
+		if (! $CNT_ISO) {
851
+			return '';
852
+		}
853
+		// for ajax
854
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
855
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
856
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
857
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10, 2);
858
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
859
+		if (empty($states)) {
860
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
861
+			$countrySubRegionDao = $this->loader->getShared(
862
+				'EventEspresso\core\services\address\CountrySubRegionDao'
863
+			);
864
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
865
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
866
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
867
+					$states = EEM_State::instance()->get_all_states_for_these_countries(
868
+						[$CNT_ISO => $CNT_ISO]
869
+					);
870
+				}
871
+			}
872
+		}
873
+		if (is_array($states)) {
874
+			foreach ($states as $STA_ID => $state) {
875
+				if ($state instanceof EE_State) {
876
+					// STA_abbrev    STA_name    STA_active
877
+					$state_input_types                                             = [
878
+						'STA_abbrev' => [
879
+							'type'       => 'TEXT',
880
+							'input_name' => 'states[' . $STA_ID . ']',
881
+							'class'      => 'small-text',
882
+						],
883
+						'STA_name'   => [
884
+							'type'       => 'TEXT',
885
+							'input_name' => 'states[' . $STA_ID . ']',
886
+							'class'      => 'regular-text',
887
+						],
888
+						'STA_active' => [
889
+							'type'             => 'RADIO_BTN',
890
+							'input_name'       => 'states[' . $STA_ID . ']',
891
+							'options'          => $this->_yes_no_values,
892
+							'use_desc_4_label' => true,
893
+						],
894
+					];
895
+					$this->_template_args['states'][ $STA_ID ]['inputs']           =
896
+						EE_Question_Form_Input::generate_question_form_inputs_for_object(
897
+							$state,
898
+							$state_input_types
899
+						);
900
+					$query_args                                                    = [
901
+						'action'     => 'delete_state',
902
+						'STA_ID'     => $STA_ID,
903
+						'CNT_ISO'    => $CNT_ISO,
904
+						'STA_abbrev' => $state->abbrev(),
905
+					];
906
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
907
+						EE_Admin_Page::add_query_args_and_nonce(
908
+							$query_args,
909
+							GEN_SET_ADMIN_URL
910
+						);
911
+				}
912
+			}
913
+		} else {
914
+			$this->_template_args['states'] = false;
915
+		}
916
+
917
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
918
+			['action' => 'add_new_state'],
919
+			GEN_SET_ADMIN_URL
920
+		);
921
+
922
+		$state_details_settings = EEH_Template::display_template(
923
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
924
+			$this->_template_args,
925
+			true
926
+		);
927
+
928
+		if (defined('DOING_AJAX')) {
929
+			$notices = EE_Error::get_notices(false, false, false);
930
+			echo wp_json_encode(
931
+				[
932
+					'return_data' => $state_details_settings,
933
+					'success'     => $notices['success'],
934
+					'errors'      => $notices['errors'],
935
+				]
936
+			);
937
+			die();
938
+		} else {
939
+			return $state_details_settings;
940
+		}
941
+	}
942
+
943
+
944
+	/**
945
+	 *        add_new_state
946
+	 *
947
+	 * @access    public
948
+	 * @return void
949
+	 * @throws EE_Error
950
+	 * @throws InvalidArgumentException
951
+	 * @throws InvalidDataTypeException
952
+	 * @throws InvalidInterfaceException
953
+	 */
954
+	public function add_new_state()
955
+	{
956
+
957
+		$success = true;
958
+
959
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
960
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
961
+			: false;
962
+		if (! $CNT_ISO) {
963
+			EE_Error::add_error(
964
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
965
+				__FILE__,
966
+				__FUNCTION__,
967
+				__LINE__
968
+			);
969
+			$success = false;
970
+		}
971
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
972
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
973
+			: false;
974
+		if (! $STA_abbrev) {
975
+			EE_Error::add_error(
976
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
977
+				__FILE__,
978
+				__FUNCTION__,
979
+				__LINE__
980
+			);
981
+			$success = false;
982
+		}
983
+		$STA_name = isset($this->_req_data['STA_name'])
984
+			? sanitize_text_field($this->_req_data['STA_name'])
985
+			: false;
986
+		if (! $STA_name) {
987
+			EE_Error::add_error(
988
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
989
+				__FILE__,
990
+				__FUNCTION__,
991
+				__LINE__
992
+			);
993
+			$success = false;
994
+		}
995
+
996
+		if ($success) {
997
+			$cols_n_values = [
998
+				'CNT_ISO'    => $CNT_ISO,
999
+				'STA_abbrev' => $STA_abbrev,
1000
+				'STA_name'   => $STA_name,
1001
+				'STA_active' => true,
1002
+			];
1003
+			$success       = EEM_State::instance()->insert($cols_n_values);
1004
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1005
+		}
1006
+
1007
+		if (defined('DOING_AJAX')) {
1008
+			$notices = EE_Error::get_notices(false, false, false);
1009
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1010
+			die();
1011
+		} else {
1012
+			$this->_redirect_after_action($success, 'State', 'added', ['action' => 'country_settings']);
1013
+		}
1014
+	}
1015
+
1016
+
1017
+	/**
1018
+	 * @return void
1019
+	 * @throws EE_Error
1020
+	 * @throws InvalidArgumentException
1021
+	 * @throws InvalidDataTypeException
1022
+	 * @throws InvalidInterfaceException
1023
+	 */
1024
+	public function delete_state()
1025
+	{
1026
+		$CNT_ISO    = isset($this->_req_data['CNT_ISO'])
1027
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1028
+			: false;
1029
+		$STA_ID     = isset($this->_req_data['STA_ID'])
1030
+			? sanitize_text_field($this->_req_data['STA_ID'])
1031
+			: false;
1032
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
1033
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
1034
+			: false;
1035
+		if (! $STA_ID) {
1036
+			EE_Error::add_error(
1037
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1038
+				__FILE__,
1039
+				__FUNCTION__,
1040
+				__LINE__
1041
+			);
1042
+			return;
1043
+		}
1044
+
1045
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1046
+		if ($success !== false) {
1047
+			do_action(
1048
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1049
+				$CNT_ISO,
1050
+				$STA_ID,
1051
+				['STA_abbrev' => $STA_abbrev]
1052
+			);
1053
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1054
+		}
1055
+		if (defined('DOING_AJAX')) {
1056
+			$notices                = EE_Error::get_notices(false);
1057
+			$notices['return_data'] = true;
1058
+			echo wp_json_encode($notices);
1059
+			die();
1060
+		} else {
1061
+			$this->_redirect_after_action(
1062
+				$success,
1063
+				'State',
1064
+				'deleted',
1065
+				['action' => 'country_settings']
1066
+			);
1067
+		}
1068
+	}
1069
+
1070
+
1071
+	/**
1072
+	 *        _update_country_settings
1073
+	 *
1074
+	 * @return void
1075
+	 * @throws EE_Error
1076
+	 * @throws InvalidArgumentException
1077
+	 * @throws InvalidDataTypeException
1078
+	 * @throws InvalidInterfaceException
1079
+	 */
1080
+	protected function _update_country_settings()
1081
+	{
1082
+		// grab the country ISO code
1083
+		$CNT_ISO = isset($this->_req_data['country'])
1084
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
1085
+			: false;
1086
+		if (! $CNT_ISO) {
1087
+			EE_Error::add_error(
1088
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1089
+				__FILE__,
1090
+				__FUNCTION__,
1091
+				__LINE__
1092
+			);
1093
+
1094
+			return;
1095
+		}
1096
+		$cols_n_values             = [];
1097
+		$cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1098
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1099
+			: false;
1100
+		$cols_n_values['RGN_ID']   = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1101
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1102
+			: null;
1103
+		$cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1104
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1105
+			: null;
1106
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1107
+			$cols_n_values['CNT_cur_code'] = strtoupper(
1108
+				sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1109
+			);
1110
+		}
1111
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1112
+			$cols_n_values['CNT_cur_single'] = sanitize_text_field(
1113
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1114
+			);
1115
+		}
1116
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1117
+			$cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1118
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1119
+			);
1120
+		}
1121
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1122
+			$cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1123
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1124
+			);
1125
+		}
1126
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1127
+			$cols_n_values['CNT_cur_sign_b4'] = absint(
1128
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1129
+			);
1130
+		}
1131
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1132
+			$cols_n_values['CNT_cur_dec_plc'] = absint(
1133
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1134
+			);
1135
+		}
1136
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1137
+			$cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1138
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1139
+			);
1140
+		}
1141
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1142
+			$cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1143
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1144
+			);
1145
+		}
1146
+		$cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1147
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1148
+			: null;
1149
+		$cols_n_values['CNT_is_EU']    = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1150
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1151
+			: false;
1152
+		$cols_n_values['CNT_active']   = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1153
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1154
+			: false;
1155
+		// allow filtering of country data
1156
+		$cols_n_values = apply_filters(
1157
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1158
+			$cols_n_values
1159
+		);
1160
+
1161
+		// where values
1162
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1163
+		// run the update
1164
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1165
+
1166
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1167
+			// allow filtering of states data
1168
+			$states = apply_filters(
1169
+				'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1170
+				$this->_req_data['states']
1171
+			);
1172
+
1173
+			// loop thru state data ( looks like : states[75][STA_name] )
1174
+			foreach ($states as $STA_ID => $state) {
1175
+				$cols_n_values = [
1176
+					'CNT_ISO'    => $CNT_ISO,
1177
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1178
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1179
+					'STA_active' => (bool) absint($state['STA_active']),
1180
+				];
1181
+				// where values
1182
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1183
+				// run the update
1184
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1185
+				if ($success !== false) {
1186
+					do_action(
1187
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1188
+						$CNT_ISO,
1189
+						$STA_ID,
1190
+						$cols_n_values
1191
+					);
1192
+				}
1193
+			}
1194
+		}
1195
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1196
+		if (
1197
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1198
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1199
+		) {
1200
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1201
+			EE_Registry::instance()->CFG->update_espresso_config();
1202
+		}
1203
+
1204
+		if ($success !== false) {
1205
+			EE_Error::add_success(
1206
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1207
+			);
1208
+		}
1209
+		$this->_redirect_after_action(
1210
+			$success,
1211
+			'',
1212
+			'',
1213
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1214
+			true
1215
+		);
1216
+	}
1217
+
1218
+
1219
+	/**
1220
+	 *        form_form_field_label_wrap
1221
+	 *
1222
+	 * @param string $label
1223
+	 * @return        string
1224
+	 */
1225
+	public function country_form_field_label_wrap($label, $required_text)
1226
+	{
1227
+		return '
1228 1228
 			<tr>
1229 1229
 				<th>
1230 1230
 					' . $label . '
1231 1231
 				</th>';
1232
-    }
1233
-
1234
-
1235
-    /**
1236
-     *        form_form_field_input__wrap
1237
-     *
1238
-     * @param string $label
1239
-     * @return        string
1240
-     */
1241
-    public function country_form_field_input__wrap($input, $label)
1242
-    {
1243
-        return '
1232
+	}
1233
+
1234
+
1235
+	/**
1236
+	 *        form_form_field_input__wrap
1237
+	 *
1238
+	 * @param string $label
1239
+	 * @return        string
1240
+	 */
1241
+	public function country_form_field_input__wrap($input, $label)
1242
+	{
1243
+		return '
1244 1244
 				<td class="general-settings-country-input-td">
1245 1245
 					' . $input . '
1246 1246
 				</td>
1247 1247
 			</tr>';
1248
-    }
1249
-
1250
-
1251
-    /**
1252
-     *        form_form_field_label_wrap
1253
-     *
1254
-     * @param string $label
1255
-     * @param string $required_text
1256
-     * @return        string
1257
-     */
1258
-    public function state_form_field_label_wrap($label, $required_text)
1259
-    {
1260
-        return $required_text;
1261
-    }
1262
-
1263
-
1264
-    /**
1265
-     *        form_form_field_input__wrap
1266
-     *
1267
-     * @param string $label
1268
-     * @return        string
1269
-     */
1270
-    public function state_form_field_input__wrap($input, $label)
1271
-    {
1272
-        return '
1248
+	}
1249
+
1250
+
1251
+	/**
1252
+	 *        form_form_field_label_wrap
1253
+	 *
1254
+	 * @param string $label
1255
+	 * @param string $required_text
1256
+	 * @return        string
1257
+	 */
1258
+	public function state_form_field_label_wrap($label, $required_text)
1259
+	{
1260
+		return $required_text;
1261
+	}
1262
+
1263
+
1264
+	/**
1265
+	 *        form_form_field_input__wrap
1266
+	 *
1267
+	 * @param string $label
1268
+	 * @return        string
1269
+	 */
1270
+	public function state_form_field_input__wrap($input, $label)
1271
+	{
1272
+		return '
1273 1273
 				<td class="general-settings-country-state-input-td">
1274 1274
 					' . $input . '
1275 1275
 				</td>';
1276
-    }
1277
-
1278
-
1279
-    /***********/
1280
-
1281
-
1282
-    /**
1283
-     * displays edit and view links for critical EE pages
1284
-     *
1285
-     * @param int $ee_page_id
1286
-     * @return string
1287
-     */
1288
-    public static function edit_view_links($ee_page_id)
1289
-    {
1290
-        $links = '<a href="'
1291
-                 . add_query_arg(
1292
-                     ['post' => $ee_page_id, 'action' => 'edit'],
1293
-                     admin_url('post.php')
1294
-                 )
1295
-                 . '" >'
1296
-                 . esc_html__('Edit', 'event_espresso')
1297
-                 . '</a>';
1298
-        $links .= ' &nbsp;|&nbsp; ';
1299
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1300
-
1301
-        return $links;
1302
-    }
1303
-
1304
-
1305
-    /**
1306
-     * displays page and shortcode status for critical EE pages
1307
-     *
1308
-     * @param WP page object $ee_page
1309
-     * @return string
1310
-     */
1311
-    public static function page_and_shortcode_status($ee_page, $shortcode)
1312
-    {
1313
-
1314
-        // page status
1315
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1316
-            $pg_colour = 'green';
1317
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1318
-        } else {
1319
-            $pg_colour = 'red';
1320
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1321
-        }
1322
-
1323
-        // shortcode status
1324
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1325
-            $sc_colour = 'green';
1326
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1327
-        } else {
1328
-            $sc_colour = 'red';
1329
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1330
-        }
1331
-
1332
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1333
-               . $pg_status
1334
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1335
-    }
1336
-
1337
-
1338
-    /**
1339
-     * generates a dropdown of all parent pages - copied from WP core
1340
-     *
1341
-     * @param int  $default
1342
-     * @param int  $parent
1343
-     * @param int  $level
1344
-     * @param bool $echo
1345
-     * @return string;
1346
-     */
1347
-    public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0, $echo = true)
1348
-    {
1349
-        global $wpdb;
1350
-        $items  = $wpdb->get_results(
1351
-            $wpdb->prepare(
1352
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1353
-                $parent
1354
-            )
1355
-        );
1356
-        $output = '';
1357
-
1358
-        if ($items) {
1359
-            $level = absint($level);
1360
-            foreach ($items as $item) {
1361
-                $ID = absint($item->ID);
1362
-                $post_title = wp_strip_all_tags($item->post_title);
1363
-                $pad    = str_repeat('&nbsp;', $level * 3);
1364
-                $option = "\n\t";
1365
-                $option .= '<option class="level-' . $level . '" ';
1366
-                $option .= 'value="' . $ID . '" ';
1367
-                $option .= $ID === absint($default) ? ' selected' : '';
1368
-                $option .= '>';
1369
-                $option .= "$pad {$post_title}";
1370
-                $option .= '</option>';
1371
-                $output .= $option;
1372
-                ob_start();
1373
-                parent_dropdown($default, $item->ID, $level + 1);
1374
-                $output .= ob_get_clean();
1375
-            }
1376
-        }
1377
-        if ($echo) {
1378
-            echo wp_kses($output, AllowedTags::getAllowedTags());
1379
-            return '';
1380
-        }
1381
-        return $output;
1382
-    }
1383
-
1384
-
1385
-    /**
1386
-     * Loads the scripts for the privacy settings form
1387
-     */
1388
-    public function load_scripts_styles_privacy_settings()
1389
-    {
1390
-        $form_handler =
1391
-            $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1392
-        $form_handler->enqueueStylesAndScripts();
1393
-    }
1394
-
1395
-
1396
-    /**
1397
-     * display the privacy settings form
1398
-     *
1399
-     * @throws EE_Error
1400
-     */
1401
-    public function privacySettings()
1402
-    {
1403
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1404
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1405
-        $form_handler                               =
1406
-            $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1407
-        $this->_template_args['admin_page_content'] = $form_handler->display();
1408
-        $this->display_admin_page_with_sidebar();
1409
-    }
1410
-
1411
-
1412
-    /**
1413
-     * Update the privacy settings from form data
1414
-     *
1415
-     * @throws EE_Error
1416
-     */
1417
-    public function updatePrivacySettings()
1418
-    {
1419
-        $form_handler =
1420
-            $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1421
-        $success      = $form_handler->process($this->get_request_data());
1422
-        $this->_redirect_after_action(
1423
-            $success,
1424
-            esc_html__('Registration Form Options', 'event_espresso'),
1425
-            'updated',
1426
-            ['action' => 'privacy_settings']
1427
-        );
1428
-    }
1276
+	}
1277
+
1278
+
1279
+	/***********/
1280
+
1281
+
1282
+	/**
1283
+	 * displays edit and view links for critical EE pages
1284
+	 *
1285
+	 * @param int $ee_page_id
1286
+	 * @return string
1287
+	 */
1288
+	public static function edit_view_links($ee_page_id)
1289
+	{
1290
+		$links = '<a href="'
1291
+				 . add_query_arg(
1292
+					 ['post' => $ee_page_id, 'action' => 'edit'],
1293
+					 admin_url('post.php')
1294
+				 )
1295
+				 . '" >'
1296
+				 . esc_html__('Edit', 'event_espresso')
1297
+				 . '</a>';
1298
+		$links .= ' &nbsp;|&nbsp; ';
1299
+		$links .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1300
+
1301
+		return $links;
1302
+	}
1303
+
1304
+
1305
+	/**
1306
+	 * displays page and shortcode status for critical EE pages
1307
+	 *
1308
+	 * @param WP page object $ee_page
1309
+	 * @return string
1310
+	 */
1311
+	public static function page_and_shortcode_status($ee_page, $shortcode)
1312
+	{
1313
+
1314
+		// page status
1315
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1316
+			$pg_colour = 'green';
1317
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1318
+		} else {
1319
+			$pg_colour = 'red';
1320
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1321
+		}
1322
+
1323
+		// shortcode status
1324
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1325
+			$sc_colour = 'green';
1326
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1327
+		} else {
1328
+			$sc_colour = 'red';
1329
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1330
+		}
1331
+
1332
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1333
+			   . $pg_status
1334
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1335
+	}
1336
+
1337
+
1338
+	/**
1339
+	 * generates a dropdown of all parent pages - copied from WP core
1340
+	 *
1341
+	 * @param int  $default
1342
+	 * @param int  $parent
1343
+	 * @param int  $level
1344
+	 * @param bool $echo
1345
+	 * @return string;
1346
+	 */
1347
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0, $echo = true)
1348
+	{
1349
+		global $wpdb;
1350
+		$items  = $wpdb->get_results(
1351
+			$wpdb->prepare(
1352
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1353
+				$parent
1354
+			)
1355
+		);
1356
+		$output = '';
1357
+
1358
+		if ($items) {
1359
+			$level = absint($level);
1360
+			foreach ($items as $item) {
1361
+				$ID = absint($item->ID);
1362
+				$post_title = wp_strip_all_tags($item->post_title);
1363
+				$pad    = str_repeat('&nbsp;', $level * 3);
1364
+				$option = "\n\t";
1365
+				$option .= '<option class="level-' . $level . '" ';
1366
+				$option .= 'value="' . $ID . '" ';
1367
+				$option .= $ID === absint($default) ? ' selected' : '';
1368
+				$option .= '>';
1369
+				$option .= "$pad {$post_title}";
1370
+				$option .= '</option>';
1371
+				$output .= $option;
1372
+				ob_start();
1373
+				parent_dropdown($default, $item->ID, $level + 1);
1374
+				$output .= ob_get_clean();
1375
+			}
1376
+		}
1377
+		if ($echo) {
1378
+			echo wp_kses($output, AllowedTags::getAllowedTags());
1379
+			return '';
1380
+		}
1381
+		return $output;
1382
+	}
1383
+
1384
+
1385
+	/**
1386
+	 * Loads the scripts for the privacy settings form
1387
+	 */
1388
+	public function load_scripts_styles_privacy_settings()
1389
+	{
1390
+		$form_handler =
1391
+			$this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1392
+		$form_handler->enqueueStylesAndScripts();
1393
+	}
1394
+
1395
+
1396
+	/**
1397
+	 * display the privacy settings form
1398
+	 *
1399
+	 * @throws EE_Error
1400
+	 */
1401
+	public function privacySettings()
1402
+	{
1403
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1404
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1405
+		$form_handler                               =
1406
+			$this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1407
+		$this->_template_args['admin_page_content'] = $form_handler->display();
1408
+		$this->display_admin_page_with_sidebar();
1409
+	}
1410
+
1411
+
1412
+	/**
1413
+	 * Update the privacy settings from form data
1414
+	 *
1415
+	 * @throws EE_Error
1416
+	 */
1417
+	public function updatePrivacySettings()
1418
+	{
1419
+		$form_handler =
1420
+			$this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1421
+		$success      = $form_handler->process($this->get_request_data());
1422
+		$this->_redirect_after_action(
1423
+			$success,
1424
+			esc_html__('Registration Form Options', 'event_espresso'),
1425
+			'updated',
1426
+			['action' => 'privacy_settings']
1427
+		);
1428
+	}
1429 1429
 }
Please login to merge, or discard this patch.
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
             'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
248 248
             'event_espresso'
249 249
         ));
250
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(__(
250
+        EE_Registry::$i18n_js_strings['error_occurred'] = wp_strip_all_tags(__(
251 251
             'An error occurred! Please refresh the page and try again.',
252 252
             'event_espresso'
253 253
         ));
254
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(__(
254
+        EE_Registry::$i18n_js_strings['confirm_delete_state'] = wp_strip_all_tags(__(
255 255
             'Are you sure you want to delete this State / Province?',
256 256
             'event_espresso'
257 257
         ));
@@ -285,12 +285,12 @@  discard block
 block discarded – undo
285 285
         wp_enqueue_script('thickbox');
286 286
         wp_register_script(
287 287
             'organization_settings',
288
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
288
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
289 289
             ['jquery', 'media-upload', 'thickbox'],
290 290
             EVENT_ESPRESSO_VERSION,
291 291
             true
292 292
         );
293
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
293
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', [], EVENT_ESPRESSO_VERSION);
294 294
         wp_enqueue_script('organization_settings');
295 295
         wp_enqueue_style('organization-css');
296 296
         $confirm_image_delete = [
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
         // scripts
314 314
         wp_register_script(
315 315
             'gen_settings_countries',
316
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
316
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
317 317
             ['ee_admin_js'],
318 318
             EVENT_ESPRESSO_VERSION,
319 319
             true
320 320
         );
321
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
321
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', [], EVENT_ESPRESSO_VERSION);
322 322
         wp_enqueue_script('gen_settings_countries');
323 323
         wp_enqueue_style('organization-css');
324 324
     }
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
369 369
         $this->_set_publish_post_box_vars(null, false, false, null, false);
370 370
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
371
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
372 372
             $this->_template_args,
373 373
             true
374 374
         );
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
             EE_Registry::instance()->CFG->core,
403 403
             $this->_req_data
404 404
         );
405
-        $what                              = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
405
+        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
406 406
         $this->_redirect_after_action(
407 407
             $this->_update_espresso_configuration(
408 408
                 $what,
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
     {
528 528
         try {
529 529
             $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
530
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
530
+            $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
531 531
             EE_Registry::instance()->CFG->admin = apply_filters(
532 532
                 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
533 533
                 EE_Registry::instance()->CFG->admin
@@ -628,23 +628,23 @@  discard block
 block discarded – undo
628 628
                 'append_qstn_id' => false,
629 629
             ]
630 630
         );
631
-        $country                           = $this->verifyOrGetCountryFromIso($CNT_ISO_for_site);
631
+        $country = $this->verifyOrGetCountryFromIso($CNT_ISO_for_site);
632 632
         add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
633 633
         add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
634 634
         $this->_template_args['country_details_settings'] = $this->display_country_settings(
635 635
             $country->ID(),
636 636
             $country
637 637
         );
638
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
638
+        $this->_template_args['country_states_settings'] = $this->display_country_states(
639 639
             $country->ID(),
640 640
             $country
641 641
         );
642
-        $this->_template_args['CNT_name_for_site']        = $country->name();
642
+        $this->_template_args['CNT_name_for_site'] = $country->name();
643 643
 
644 644
         $this->_set_add_edit_form_tags('update_country_settings');
645 645
         $this->_set_publish_post_box_vars(null, false, false, null, false);
646 646
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
647
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
647
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
648 648
             $this->_template_args,
649 649
             true
650 650
         );
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
         $CNT_ISO = isset($this->_req_data['country'])
671 671
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
672 672
             : $CNT_ISO;
673
-        if (! $CNT_ISO) {
673
+        if ( ! $CNT_ISO) {
674 674
             return '';
675 675
         }
676 676
 
@@ -683,62 +683,62 @@  discard block
 block discarded – undo
683 683
         $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
684 684
         $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
685 685
 
686
-        $country_input_types            = [
686
+        $country_input_types = [
687 687
             'CNT_active'      => [
688 688
                 'type'             => 'RADIO_BTN',
689
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
689
+                'input_name'       => 'cntry['.$CNT_ISO.']',
690 690
                 'class'            => '',
691 691
                 'options'          => $this->_yes_no_values,
692 692
                 'use_desc_4_label' => true,
693 693
             ],
694 694
             'CNT_ISO'         => [
695 695
                 'type'       => 'TEXT',
696
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
696
+                'input_name' => 'cntry['.$CNT_ISO.']',
697 697
                 'class'      => 'small-text',
698 698
             ],
699 699
             'CNT_ISO3'        => [
700 700
                 'type'       => 'TEXT',
701
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
701
+                'input_name' => 'cntry['.$CNT_ISO.']',
702 702
                 'class'      => 'small-text',
703 703
             ],
704 704
             'RGN_ID'          => [
705 705
                 'type'       => 'TEXT',
706
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
706
+                'input_name' => 'cntry['.$CNT_ISO.']',
707 707
                 'class'      => 'small-text',
708 708
             ],
709 709
             'CNT_name'        => [
710 710
                 'type'       => 'TEXT',
711
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
711
+                'input_name' => 'cntry['.$CNT_ISO.']',
712 712
                 'class'      => 'regular-text',
713 713
             ],
714 714
             'CNT_cur_code'    => [
715 715
                 'type'       => 'TEXT',
716
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
716
+                'input_name' => 'cntry['.$CNT_ISO.']',
717 717
                 'class'      => 'small-text',
718 718
                 'disabled'   => $CNT_cur_disabled,
719 719
             ],
720 720
             'CNT_cur_single'  => [
721 721
                 'type'       => 'TEXT',
722
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
722
+                'input_name' => 'cntry['.$CNT_ISO.']',
723 723
                 'class'      => 'medium-text',
724 724
                 'disabled'   => $CNT_cur_disabled,
725 725
             ],
726 726
             'CNT_cur_plural'  => [
727 727
                 'type'       => 'TEXT',
728
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
728
+                'input_name' => 'cntry['.$CNT_ISO.']',
729 729
                 'class'      => 'medium-text',
730 730
                 'disabled'   => $CNT_cur_disabled,
731 731
             ],
732 732
             'CNT_cur_sign'    => [
733 733
                 'type'         => 'TEXT',
734
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
734
+                'input_name'   => 'cntry['.$CNT_ISO.']',
735 735
                 'class'        => 'small-text',
736 736
                 'htmlentities' => false,
737 737
                 'disabled'     => $CNT_cur_disabled,
738 738
             ],
739 739
             'CNT_cur_sign_b4' => [
740 740
                 'type'             => 'RADIO_BTN',
741
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
741
+                'input_name'       => 'cntry['.$CNT_ISO.']',
742 742
                 'class'            => '',
743 743
                 'options'          => $this->_yes_no_values,
744 744
                 'use_desc_4_label' => true,
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
             ],
747 747
             'CNT_cur_dec_plc' => [
748 748
                 'type'       => 'RADIO_BTN',
749
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
749
+                'input_name' => 'cntry['.$CNT_ISO.']',
750 750
                 'class'      => '',
751 751
                 'options'    => [
752 752
                     ['id' => 0, 'text' => ''],
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
             ],
759 759
             'CNT_cur_dec_mrk' => [
760 760
                 'type'             => 'RADIO_BTN',
761
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
761
+                'input_name'       => 'cntry['.$CNT_ISO.']',
762 762
                 'class'            => '',
763 763
                 'options'          => [
764 764
                     [
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
             ],
773 773
             'CNT_cur_thsnds'  => [
774 774
                 'type'             => 'RADIO_BTN',
775
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
775
+                'input_name'       => 'cntry['.$CNT_ISO.']',
776 776
                 'class'            => '',
777 777
                 'options'          => [
778 778
                     [
@@ -793,12 +793,12 @@  discard block
 block discarded – undo
793 793
             ],
794 794
             'CNT_tel_code'    => [
795 795
                 'type'       => 'TEXT',
796
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
796
+                'input_name' => 'cntry['.$CNT_ISO.']',
797 797
                 'class'      => 'small-text',
798 798
             ],
799 799
             'CNT_is_EU'       => [
800 800
                 'type'             => 'RADIO_BTN',
801
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
801
+                'input_name'       => 'cntry['.$CNT_ISO.']',
802 802
                 'class'            => '',
803 803
                 'options'          => $this->_yes_no_values,
804 804
                 'use_desc_4_label' => true,
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
             $country,
809 809
             $country_input_types
810 810
         );
811
-        $country_details_settings       = EEH_Template::display_template(
812
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
811
+        $country_details_settings = EEH_Template::display_template(
812
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
813 813
             $this->_template_args,
814 814
             true
815 815
         );
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
         $CNT_ISO = isset($this->_req_data['country'])
848 848
             ? sanitize_text_field($this->_req_data['country'])
849 849
             : $CNT_ISO;
850
-        if (! $CNT_ISO) {
850
+        if ( ! $CNT_ISO) {
851 851
             return '';
852 852
         }
853 853
         // for ajax
@@ -874,36 +874,36 @@  discard block
 block discarded – undo
874 874
             foreach ($states as $STA_ID => $state) {
875 875
                 if ($state instanceof EE_State) {
876 876
                     // STA_abbrev    STA_name    STA_active
877
-                    $state_input_types                                             = [
877
+                    $state_input_types = [
878 878
                         'STA_abbrev' => [
879 879
                             'type'       => 'TEXT',
880
-                            'input_name' => 'states[' . $STA_ID . ']',
880
+                            'input_name' => 'states['.$STA_ID.']',
881 881
                             'class'      => 'small-text',
882 882
                         ],
883 883
                         'STA_name'   => [
884 884
                             'type'       => 'TEXT',
885
-                            'input_name' => 'states[' . $STA_ID . ']',
885
+                            'input_name' => 'states['.$STA_ID.']',
886 886
                             'class'      => 'regular-text',
887 887
                         ],
888 888
                         'STA_active' => [
889 889
                             'type'             => 'RADIO_BTN',
890
-                            'input_name'       => 'states[' . $STA_ID . ']',
890
+                            'input_name'       => 'states['.$STA_ID.']',
891 891
                             'options'          => $this->_yes_no_values,
892 892
                             'use_desc_4_label' => true,
893 893
                         ],
894 894
                     ];
895
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           =
895
+                    $this->_template_args['states'][$STA_ID]['inputs'] =
896 896
                         EE_Question_Form_Input::generate_question_form_inputs_for_object(
897 897
                             $state,
898 898
                             $state_input_types
899 899
                         );
900
-                    $query_args                                                    = [
900
+                    $query_args = [
901 901
                         'action'     => 'delete_state',
902 902
                         'STA_ID'     => $STA_ID,
903 903
                         'CNT_ISO'    => $CNT_ISO,
904 904
                         'STA_abbrev' => $state->abbrev(),
905 905
                     ];
906
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
906
+                    $this->_template_args['states'][$STA_ID]['delete_state_url'] =
907 907
                         EE_Admin_Page::add_query_args_and_nonce(
908 908
                             $query_args,
909 909
                             GEN_SET_ADMIN_URL
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
         );
921 921
 
922 922
         $state_details_settings = EEH_Template::display_template(
923
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
923
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
924 924
             $this->_template_args,
925 925
             true
926 926
         );
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
         $CNT_ISO = isset($this->_req_data['CNT_ISO'])
960 960
             ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
961 961
             : false;
962
-        if (! $CNT_ISO) {
962
+        if ( ! $CNT_ISO) {
963 963
             EE_Error::add_error(
964 964
                 esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
965 965
                 __FILE__,
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
972 972
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
973 973
             : false;
974
-        if (! $STA_abbrev) {
974
+        if ( ! $STA_abbrev) {
975 975
             EE_Error::add_error(
976 976
                 esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
977 977
                 __FILE__,
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
         $STA_name = isset($this->_req_data['STA_name'])
984 984
             ? sanitize_text_field($this->_req_data['STA_name'])
985 985
             : false;
986
-        if (! $STA_name) {
986
+        if ( ! $STA_name) {
987 987
             EE_Error::add_error(
988 988
                 esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
989 989
                 __FILE__,
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
                 'STA_name'   => $STA_name,
1001 1001
                 'STA_active' => true,
1002 1002
             ];
1003
-            $success       = EEM_State::instance()->insert($cols_n_values);
1003
+            $success = EEM_State::instance()->insert($cols_n_values);
1004 1004
             EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1005 1005
         }
1006 1006
 
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1033 1033
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
1034 1034
             : false;
1035
-        if (! $STA_ID) {
1035
+        if ( ! $STA_ID) {
1036 1036
             EE_Error::add_error(
1037 1037
                 esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1038 1038
                 __FILE__,
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
         $CNT_ISO = isset($this->_req_data['country'])
1084 1084
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
1085 1085
             : false;
1086
-        if (! $CNT_ISO) {
1086
+        if ( ! $CNT_ISO) {
1087 1087
             EE_Error::add_error(
1088 1088
                 esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1089 1089
                 __FILE__,
@@ -1094,63 +1094,63 @@  discard block
 block discarded – undo
1094 1094
             return;
1095 1095
         }
1096 1096
         $cols_n_values             = [];
1097
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1098
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1097
+        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])
1098
+            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']))
1099 1099
             : false;
1100
-        $cols_n_values['RGN_ID']   = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1101
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1100
+        $cols_n_values['RGN_ID']   = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1101
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1102 1102
             : null;
1103
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1104
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1103
+        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1104
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1105 1105
             : null;
1106
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1106
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) {
1107 1107
             $cols_n_values['CNT_cur_code'] = strtoupper(
1108
-                sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1108
+                sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])
1109 1109
             );
1110 1110
         }
1111
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1111
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])) {
1112 1112
             $cols_n_values['CNT_cur_single'] = sanitize_text_field(
1113
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1113
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']
1114 1114
             );
1115 1115
         }
1116
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1116
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])) {
1117 1117
             $cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1118
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1118
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']
1119 1119
             );
1120 1120
         }
1121
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1121
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])) {
1122 1122
             $cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1123
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1123
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']
1124 1124
             );
1125 1125
         }
1126
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1126
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])) {
1127 1127
             $cols_n_values['CNT_cur_sign_b4'] = absint(
1128
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1128
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']
1129 1129
             );
1130 1130
         }
1131
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1131
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])) {
1132 1132
             $cols_n_values['CNT_cur_dec_plc'] = absint(
1133
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1133
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']
1134 1134
             );
1135 1135
         }
1136
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1136
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])) {
1137 1137
             $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1138
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1138
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']
1139 1139
             );
1140 1140
         }
1141
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1141
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])) {
1142 1142
             $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1143
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1143
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']
1144 1144
             );
1145 1145
         }
1146
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1147
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1146
+        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1147
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1148 1148
             : null;
1149
-        $cols_n_values['CNT_is_EU']    = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1150
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1149
+        $cols_n_values['CNT_is_EU']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1150
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1151 1151
             : false;
1152
-        $cols_n_values['CNT_active']   = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1153
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1152
+        $cols_n_values['CNT_active']   = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1153
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1154 1154
             : false;
1155 1155
         // allow filtering of country data
1156 1156
         $cols_n_values = apply_filters(
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
         return '
1228 1228
 			<tr>
1229 1229
 				<th>
1230
-					' . $label . '
1230
+					' . $label.'
1231 1231
 				</th>';
1232 1232
     }
1233 1233
 
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
     {
1243 1243
         return '
1244 1244
 				<td class="general-settings-country-input-td">
1245
-					' . $input . '
1245
+					' . $input.'
1246 1246
 				</td>
1247 1247
 			</tr>';
1248 1248
     }
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
     {
1272 1272
         return '
1273 1273
 				<td class="general-settings-country-state-input-td">
1274
-					' . $input . '
1274
+					' . $input.'
1275 1275
 				</td>';
1276 1276
     }
1277 1277
 
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
                  . esc_html__('Edit', 'event_espresso')
1297 1297
                  . '</a>';
1298 1298
         $links .= ' &nbsp;|&nbsp; ';
1299
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1299
+        $links .= '<a href="'.get_permalink($ee_page_id).'" >'.esc_html__('View', 'event_espresso').'</a>';
1300 1300
 
1301 1301
         return $links;
1302 1302
     }
@@ -1329,9 +1329,9 @@  discard block
 block discarded – undo
1329 1329
             $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1330 1330
         }
1331 1331
 
1332
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1332
+        return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'
1333 1333
                . $pg_status
1334
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1334
+               . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
1335 1335
     }
1336 1336
 
1337 1337
 
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
     public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0, $echo = true)
1348 1348
     {
1349 1349
         global $wpdb;
1350
-        $items  = $wpdb->get_results(
1350
+        $items = $wpdb->get_results(
1351 1351
             $wpdb->prepare(
1352 1352
                 "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1353 1353
                 $parent
@@ -1362,8 +1362,8 @@  discard block
 block discarded – undo
1362 1362
                 $post_title = wp_strip_all_tags($item->post_title);
1363 1363
                 $pad    = str_repeat('&nbsp;', $level * 3);
1364 1364
                 $option = "\n\t";
1365
-                $option .= '<option class="level-' . $level . '" ';
1366
-                $option .= 'value="' . $ID . '" ';
1365
+                $option .= '<option class="level-'.$level.'" ';
1366
+                $option .= 'value="'.$ID.'" ';
1367 1367
                 $option .= $ID === absint($default) ? ' selected' : '';
1368 1368
                 $option .= '>';
1369 1369
                 $option .= "$pad {$post_title}";
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page.core.php 2 patches
Indentation   +2521 added lines, -2521 removed lines patch added patch discarded remove patch
@@ -13,2525 +13,2525 @@
 block discarded – undo
13 13
 class Transactions_Admin_Page extends EE_Admin_Page
14 14
 {
15 15
 
16
-    /**
17
-     * @var EE_Transaction
18
-     */
19
-    private $_transaction;
20
-
21
-    /**
22
-     * @var EE_Session
23
-     */
24
-    private $_session;
25
-
26
-    /**
27
-     * @var array $_txn_status
28
-     */
29
-    private static $_txn_status;
30
-
31
-    /**
32
-     * @var array $_pay_status
33
-     */
34
-    private static $_pay_status;
35
-
36
-    /**
37
-     * @var array $_existing_reg_payment_REG_IDs
38
-     */
39
-    protected $_existing_reg_payment_REG_IDs;
40
-
41
-
42
-    /**
43
-     *    _init_page_props
44
-     *
45
-     * @return void
46
-     */
47
-    protected function _init_page_props()
48
-    {
49
-        $this->page_slug        = TXN_PG_SLUG;
50
-        $this->page_label       = esc_html__('Transactions', 'event_espresso');
51
-        $this->_admin_base_url  = TXN_ADMIN_URL;
52
-        $this->_admin_base_path = TXN_ADMIN;
53
-    }
54
-
55
-
56
-    /**
57
-     *    _ajax_hooks
58
-     *
59
-     * @return void
60
-     */
61
-    protected function _ajax_hooks()
62
-    {
63
-        add_action('wp_ajax_espresso_apply_payment', [$this, 'apply_payments_or_refunds']);
64
-        add_action('wp_ajax_espresso_apply_refund', [$this, 'apply_payments_or_refunds']);
65
-        add_action('wp_ajax_espresso_delete_payment', [$this, 'delete_payment']);
66
-    }
67
-
68
-
69
-    /**
70
-     *    _define_page_props
71
-     *
72
-     * @return void
73
-     */
74
-    protected function _define_page_props()
75
-    {
76
-        $this->_admin_page_title = $this->page_label;
77
-        $this->_labels           = [
78
-            'buttons' => [
79
-                'add'    => esc_html__('Add New Transaction', 'event_espresso'),
80
-                'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
81
-                'delete' => esc_html__('Delete Transaction', 'event_espresso'),
82
-            ],
83
-        ];
84
-    }
85
-
86
-
87
-    /**
88
-     *        grab url requests and route them
89
-     *
90
-     * @access private
91
-     * @return void
92
-     * @throws EE_Error
93
-     * @throws InvalidArgumentException
94
-     * @throws InvalidDataTypeException
95
-     * @throws InvalidInterfaceException
96
-     */
97
-    public function _set_page_routes()
98
-    {
99
-
100
-        $this->_set_transaction_status_array();
101
-        $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
102
-
103
-        $this->_page_routes = [
104
-
105
-            'default' => [
106
-                'func'       => '_transactions_overview_list_table',
107
-                'capability' => 'ee_read_transactions',
108
-            ],
109
-
110
-            'view_transaction' => [
111
-                'func'       => '_transaction_details',
112
-                'capability' => 'ee_read_transaction',
113
-                'obj_id'     => $TXN_ID,
114
-            ],
115
-
116
-            'send_payment_reminder' => [
117
-                'func'       => '_send_payment_reminder',
118
-                'noheader'   => true,
119
-                'capability' => 'ee_send_message',
120
-            ],
121
-
122
-            'espresso_apply_payment' => [
123
-                'func'       => 'apply_payments_or_refunds',
124
-                'noheader'   => true,
125
-                'capability' => 'ee_edit_payments',
126
-            ],
127
-
128
-            'espresso_apply_refund' => [
129
-                'func'       => 'apply_payments_or_refunds',
130
-                'noheader'   => true,
131
-                'capability' => 'ee_edit_payments',
132
-            ],
133
-
134
-            'espresso_delete_payment' => [
135
-                'func'       => 'delete_payment',
136
-                'noheader'   => true,
137
-                'capability' => 'ee_delete_payments',
138
-            ],
139
-
140
-            'espresso_recalculate_line_items' => [
141
-                'func'       => 'recalculateLineItems',
142
-                'noheader'   => true,
143
-                'capability' => 'ee_edit_payments',
144
-            ],
145
-
146
-        ];
147
-    }
148
-
149
-
150
-    protected function _set_page_config()
151
-    {
152
-        $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
153
-        $this->_page_config = [
154
-            'default'          => [
155
-                'nav'           => [
156
-                    'label' => esc_html__('Overview', 'event_espresso'),
157
-                    'order' => 10,
158
-                ],
159
-                'list_table'    => 'EE_Admin_Transactions_List_Table',
160
-                'help_tabs'     => [
161
-                    'transactions_overview_help_tab'                       => [
162
-                        'title'    => esc_html__('Transactions Overview', 'event_espresso'),
163
-                        'filename' => 'transactions_overview',
164
-                    ],
165
-                    'transactions_overview_table_column_headings_help_tab' => [
166
-                        'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
167
-                        'filename' => 'transactions_overview_table_column_headings',
168
-                    ],
169
-                    'transactions_overview_views_filters_help_tab'         => [
170
-                        'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
171
-                        'filename' => 'transactions_overview_views_filters_search',
172
-                    ],
173
-                ],
174
-                /**
175
-                 * commented out because currently we are not displaying tips for transaction list table status but this
176
-                 * may change in a later iteration so want to keep the code for then.
177
-                 */
178
-                // 'qtips' => array( 'Transactions_List_Table_Tips' ),
179
-                'require_nonce' => false,
180
-            ],
181
-            'view_transaction' => [
182
-                'nav'       => [
183
-                    'label'      => esc_html__('View Transaction', 'event_espresso'),
184
-                    'order'      => 5,
185
-                    'url'        => $TXN_ID
186
-                        ? add_query_arg(['TXN_ID' => $TXN_ID], $this->_current_page_view_url)
187
-                        : $this->_admin_base_url,
188
-                    'persistent' => false,
189
-                ],
190
-                'help_tabs' => [
191
-                    'transactions_view_transaction_help_tab'                                              => [
192
-                        'title'    => esc_html__('View Transaction', 'event_espresso'),
193
-                        'filename' => 'transactions_view_transaction',
194
-                    ],
195
-                    'transactions_view_transaction_transaction_details_table_help_tab'                    => [
196
-                        'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
197
-                        'filename' => 'transactions_view_transaction_transaction_details_table',
198
-                    ],
199
-                    'transactions_view_transaction_attendees_registered_help_tab'                         => [
200
-                        'title'    => esc_html__('Attendees Registered', 'event_espresso'),
201
-                        'filename' => 'transactions_view_transaction_attendees_registered',
202
-                    ],
203
-                    'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => [
204
-                        'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
205
-                        'filename' => 'transactions_view_transaction_primary_registrant_billing_information',
206
-                    ],
207
-                ],
208
-                'qtips'     => ['Transaction_Details_Tips'],
209
-                'metaboxes' => ['_transaction_details_metaboxes'],
210
-
211
-                'require_nonce' => false,
212
-            ],
213
-        ];
214
-    }
215
-
216
-
217
-    /**
218
-     * The below methods aren't used by this class currently
219
-     */
220
-    protected function _add_screen_options()
221
-    {
222
-        // noop
223
-    }
224
-
225
-
226
-    protected function _add_feature_pointers()
227
-    {
228
-        // noop
229
-    }
230
-
231
-
232
-    public function admin_init()
233
-    {
234
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
235
-        $event_name = $this->request->getRequestParam('event_name');
236
-        $redirect_from = $this->request->getRequestParam('redirect_from', '', 'url');
237
-        // IF a registration was JUST added via the admin...
238
-        if ($EVT_ID && $event_name && $redirect_from) {
239
-            // then set a cookie so that we can block any attempts to use
240
-            // the back button as a way to enter another registration.
241
-            setcookie('ee_registration_added', $EVT_ID, time() + WEEK_IN_SECONDS, '/');
242
-            // and update the global
243
-            $_COOKIE['ee_registration_added'] = $EVT_ID;
244
-        }
245
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__(
246
-            'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247
-            'event_espresso'
248
-        );
249
-        EE_Registry::$i18n_js_strings['error_occurred']          = esc_html__(
250
-            'An error occurred! Please refresh the page and try again.',
251
-            'event_espresso'
252
-        );
253
-        EE_Registry::$i18n_js_strings['txn_status_array']        = self::$_txn_status;
254
-        EE_Registry::$i18n_js_strings['pay_status_array']        = self::$_pay_status;
255
-        EE_Registry::$i18n_js_strings['payments_total']          = esc_html__('Payments Total', 'event_espresso');
256
-        EE_Registry::$i18n_js_strings['transaction_overpaid']    = esc_html__(
257
-            'This transaction has been overpaid ! Payments Total',
258
-            'event_espresso'
259
-        );
260
-    }
261
-
262
-
263
-    public function admin_notices()
264
-    {
265
-        // noop
266
-    }
267
-
268
-
269
-    public function admin_footer_scripts()
270
-    {
271
-        // noop
272
-    }
273
-
274
-
275
-    /**
276
-     * _set_transaction_status_array
277
-     * sets list of transaction statuses
278
-     *
279
-     * @access private
280
-     * @return void
281
-     * @throws EE_Error
282
-     * @throws InvalidArgumentException
283
-     * @throws InvalidDataTypeException
284
-     * @throws InvalidInterfaceException
285
-     */
286
-    private function _set_transaction_status_array()
287
-    {
288
-        self::$_txn_status = EEM_Transaction::instance()->status_array(true);
289
-    }
290
-
291
-
292
-    /**
293
-     * get_transaction_status_array
294
-     * return the transaction status array for wp_list_table
295
-     *
296
-     * @access public
297
-     * @return array
298
-     */
299
-    public function get_transaction_status_array()
300
-    {
301
-        return self::$_txn_status;
302
-    }
303
-
304
-
305
-    /**
306
-     *    get list of payment statuses
307
-     *
308
-     * @access private
309
-     * @return void
310
-     * @throws EE_Error
311
-     * @throws InvalidArgumentException
312
-     * @throws InvalidDataTypeException
313
-     * @throws InvalidInterfaceException
314
-     */
315
-    private function _get_payment_status_array()
316
-    {
317
-        self::$_pay_status                      = EEM_Payment::instance()->status_array(true);
318
-        $this->_template_args['payment_status'] = self::$_pay_status;
319
-    }
320
-
321
-
322
-    /**
323
-     *    _add_screen_options_default
324
-     *
325
-     * @access protected
326
-     * @return void
327
-     * @throws InvalidArgumentException
328
-     * @throws InvalidDataTypeException
329
-     * @throws InvalidInterfaceException
330
-     */
331
-    protected function _add_screen_options_default()
332
-    {
333
-        $this->_per_page_screen_option();
334
-    }
335
-
336
-
337
-    /**
338
-     * load_scripts_styles
339
-     *
340
-     * @access public
341
-     * @return void
342
-     */
343
-    public function load_scripts_styles()
344
-    {
345
-        // enqueue style
346
-        wp_register_style(
347
-            'espresso_txn',
348
-            TXN_ASSETS_URL . 'espresso_transactions_admin.css',
349
-            [],
350
-            EVENT_ESPRESSO_VERSION
351
-        );
352
-        wp_enqueue_style('espresso_txn');
353
-        // scripts
354
-        wp_register_script(
355
-            'espresso_txn',
356
-            TXN_ASSETS_URL . 'espresso_transactions_admin.js',
357
-            [
358
-                'ee_admin_js',
359
-                'ee-datepicker',
360
-                'jquery-ui-datepicker',
361
-                'jquery-ui-draggable',
362
-                'ee-dialog',
363
-                'ee-accounting',
364
-                'ee-serialize-full-array',
365
-            ],
366
-            EVENT_ESPRESSO_VERSION,
367
-            true
368
-        );
369
-        wp_enqueue_script('espresso_txn');
370
-    }
371
-
372
-
373
-    /**
374
-     *    load_scripts_styles_view_transaction
375
-     *
376
-     * @access public
377
-     * @return void
378
-     */
379
-    public function load_scripts_styles_view_transaction()
380
-    {
381
-        // styles
382
-        wp_enqueue_style('espresso-ui-theme');
383
-    }
384
-
385
-
386
-    /**
387
-     *    load_scripts_styles_default
388
-     *
389
-     * @access public
390
-     * @return void
391
-     */
392
-    public function load_scripts_styles_default()
393
-    {
394
-        // styles
395
-        wp_enqueue_style('espresso-ui-theme');
396
-    }
397
-
398
-
399
-    /**
400
-     *    _set_list_table_views_default
401
-     *
402
-     * @access protected
403
-     * @return void
404
-     */
405
-    protected function _set_list_table_views_default()
406
-    {
407
-        $this->_views = [
408
-            'all'        => [
409
-                'slug'  => 'all',
410
-                'label' => esc_html__('View All Transactions', 'event_espresso'),
411
-                'count' => 0,
412
-            ],
413
-            'abandoned'  => [
414
-                'slug'  => 'abandoned',
415
-                'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
416
-                'count' => 0,
417
-            ],
418
-            'incomplete' => [
419
-                'slug'  => 'incomplete',
420
-                'label' => esc_html__('Incomplete Transactions', 'event_espresso'),
421
-                'count' => 0,
422
-            ],
423
-        ];
424
-        if (
425
-            /**
426
-             * Filters whether a link to the "Failed Transactions" list table
427
-             * appears on the Transactions Admin Page list table.
428
-             * List display can be turned back on via the following:
429
-             * add_filter(
430
-             *     'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
431
-             *     '__return_true'
432
-             * );
433
-             *
434
-             * @param boolean                 $display_failed_txns_list
435
-             * @param Transactions_Admin_Page $this
436
-             * @since 4.9.70.p
437
-             */
438
-            apply_filters(
439
-                'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
440
-                false,
441
-                $this
442
-            )
443
-        ) {
444
-            $this->_views['failed'] = [
445
-                'slug'  => 'failed',
446
-                'label' => esc_html__('Failed Transactions', 'event_espresso'),
447
-                'count' => 0,
448
-            ];
449
-        }
450
-    }
451
-
452
-
453
-    /**
454
-     * _set_transaction_object
455
-     * This sets the _transaction property for the transaction details screen
456
-     *
457
-     * @access private
458
-     * @return void
459
-     * @throws EE_Error
460
-     * @throws InvalidArgumentException
461
-     * @throws RuntimeException
462
-     * @throws InvalidDataTypeException
463
-     * @throws InvalidInterfaceException
464
-     * @throws ReflectionException
465
-     */
466
-    private function _set_transaction_object()
467
-    {
468
-        if ($this->_transaction instanceof EE_Transaction) {
469
-            return;
470
-        } //get out we've already set the object
471
-
472
-        $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
473
-
474
-        // get transaction object
475
-        $this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
476
-        $this->_session     = $this->_transaction instanceof EE_Transaction
477
-            ? $this->_transaction->session_data()
478
-            : null;
479
-        if ($this->_transaction instanceof EE_Transaction) {
480
-            $this->_transaction->verify_abandoned_transaction_status();
481
-        }
482
-
483
-        if (! $this->_transaction instanceof EE_Transaction) {
484
-            $error_msg = sprintf(
485
-                esc_html__(
486
-                    'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
487
-                    'event_espresso'
488
-                ),
489
-                $TXN_ID
490
-            );
491
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
492
-        }
493
-    }
494
-
495
-
496
-    /**
497
-     *    _transaction_legend_items
498
-     *
499
-     * @access protected
500
-     * @return array
501
-     * @throws EE_Error
502
-     * @throws InvalidArgumentException
503
-     * @throws ReflectionException
504
-     * @throws InvalidDataTypeException
505
-     * @throws InvalidInterfaceException
506
-     */
507
-    protected function _transaction_legend_items()
508
-    {
509
-        EE_Registry::instance()->load_helper('MSG_Template');
510
-        $items = [];
511
-
512
-        if (
513
-            EE_Registry::instance()->CAP->current_user_can(
514
-                'ee_read_global_messages',
515
-                'view_filtered_messages'
516
-            )
517
-        ) {
518
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
519
-            if (
520
-                is_array($related_for_icon)
521
-                && isset($related_for_icon['css_class'], $related_for_icon['label'])
522
-            ) {
523
-                $items['view_related_messages'] = [
524
-                    'class' => $related_for_icon['css_class'],
525
-                    'desc'  => $related_for_icon['label'],
526
-                ];
527
-            }
528
-        }
529
-
530
-        $items = apply_filters(
531
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
532
-            array_merge(
533
-                $items,
534
-                [
535
-                    'view_details'          => [
536
-                        'class' => 'dashicons dashicons-cart',
537
-                        'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
538
-                    ],
539
-                    'view_invoice'          => [
540
-                        'class' => 'dashicons dashicons-media-spreadsheet',
541
-                        'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
542
-                    ],
543
-                    'view_receipt'          => [
544
-                        'class' => 'dashicons dashicons-media-default',
545
-                        'desc'  => esc_html__('View Transaction Receipt', 'event_espresso'),
546
-                    ],
547
-                    'view_registration'     => [
548
-                        'class' => 'dashicons dashicons-clipboard',
549
-                        'desc'  => esc_html__('View Registration Details', 'event_espresso'),
550
-                    ],
551
-                    'payment_overview_link' => [
552
-                        'class' => 'dashicons dashicons-money',
553
-                        'desc'  => esc_html__('Make Payment on Frontend', 'event_espresso'),
554
-                    ],
555
-                ]
556
-            )
557
-        );
558
-
559
-        if (
560
-            EEH_MSG_Template::is_mt_active('payment_reminder')
561
-            && EE_Registry::instance()->CAP->current_user_can(
562
-                'ee_send_message',
563
-                'espresso_transactions_send_payment_reminder'
564
-            )
565
-        ) {
566
-            $items['send_payment_reminder'] = [
567
-                'class' => 'dashicons dashicons-email-alt',
568
-                'desc'  => esc_html__('Send Payment Reminder', 'event_espresso'),
569
-            ];
570
-        } else {
571
-            $items['blank*'] = [
572
-                'class' => '',
573
-                'desc'  => '',
574
-            ];
575
-        }
576
-        $more_items = apply_filters(
577
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
578
-            [
579
-                'overpaid'   => [
580
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
581
-                    'desc'  => EEH_Template::pretty_status(
582
-                        EEM_Transaction::overpaid_status_code,
583
-                        false,
584
-                        'sentence'
585
-                    ),
586
-                ],
587
-                'complete'   => [
588
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
589
-                    'desc'  => EEH_Template::pretty_status(
590
-                        EEM_Transaction::complete_status_code,
591
-                        false,
592
-                        'sentence'
593
-                    ),
594
-                ],
595
-                'incomplete' => [
596
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
597
-                    'desc'  => EEH_Template::pretty_status(
598
-                        EEM_Transaction::incomplete_status_code,
599
-                        false,
600
-                        'sentence'
601
-                    ),
602
-                ],
603
-                'abandoned'  => [
604
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
605
-                    'desc'  => EEH_Template::pretty_status(
606
-                        EEM_Transaction::abandoned_status_code,
607
-                        false,
608
-                        'sentence'
609
-                    ),
610
-                ],
611
-                'failed'     => [
612
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
613
-                    'desc'  => EEH_Template::pretty_status(
614
-                        EEM_Transaction::failed_status_code,
615
-                        false,
616
-                        'sentence'
617
-                    ),
618
-                ],
619
-            ]
620
-        );
621
-
622
-        return array_merge($items, $more_items);
623
-    }
624
-
625
-
626
-    /**
627
-     *    _transactions_overview_list_table
628
-     *
629
-     * @access protected
630
-     * @return void
631
-     * @throws DomainException
632
-     * @throws EE_Error
633
-     * @throws InvalidArgumentException
634
-     * @throws InvalidDataTypeException
635
-     * @throws InvalidInterfaceException
636
-     * @throws ReflectionException
637
-     */
638
-    protected function _transactions_overview_list_table()
639
-    {
640
-        $this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
641
-
642
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
643
-        $event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
644
-        $this->_template_args['admin_page_header'] = $event instanceof EE_Event
645
-            ? sprintf(
646
-                esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'),
647
-                '<h3>',
648
-                '<a href="'
649
-                . EE_Admin_Page::add_query_args_and_nonce(
650
-                    ['action' => 'edit', 'post' => $event->ID()],
651
-                    EVENTS_ADMIN_URL
652
-                )
653
-                . '" title="'
654
-                . esc_attr__('Click to Edit event', 'event_espresso')
655
-                . '">' . $event->name() . '</a>',
656
-                '</h3>'
657
-            )
658
-            : '';
659
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_transaction_legend_items());
660
-        $this->display_admin_list_table_page_with_no_sidebar();
661
-    }
662
-
663
-
664
-    /**
665
-     *    _transaction_details
666
-     * generates HTML for the View Transaction Details Admin page
667
-     *
668
-     * @access protected
669
-     * @return void
670
-     * @throws DomainException
671
-     * @throws EE_Error
672
-     * @throws InvalidArgumentException
673
-     * @throws InvalidDataTypeException
674
-     * @throws InvalidInterfaceException
675
-     * @throws RuntimeException
676
-     * @throws ReflectionException
677
-     */
678
-    protected function _transaction_details()
679
-    {
680
-        do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
681
-
682
-        $this->_set_transaction_status_array();
683
-
684
-        $this->_template_args                      = [];
685
-        $this->_template_args['transactions_page'] = $this->_wp_page_slug;
686
-
687
-        $this->_set_transaction_object();
688
-
689
-        if (! $this->_transaction instanceof EE_Transaction) {
690
-            return;
691
-        }
692
-
693
-        $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
694
-        $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
695
-
696
-        $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
697
-        $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
698
-
699
-        $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->status_ID() ];
700
-        $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
701
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->status_ID();
702
-
703
-        $this->_template_args['grand_total'] = $this->_transaction->total();
704
-        $this->_template_args['total_paid']  = $this->_transaction->paid();
705
-
706
-        $amount_due                         = $this->_transaction->total() - $this->_transaction->paid();
707
-        $this->_template_args['amount_due'] = EEH_Template::format_currency(
708
-            $amount_due,
709
-            true
710
-        );
711
-        if (EE_Registry::instance()->CFG->currency->sign_b4) {
712
-            $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign
713
-                                                  . $this->_template_args['amount_due'];
714
-        } else {
715
-            $this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign;
716
-        }
717
-        $this->_template_args['amount_due_class'] = '';
718
-
719
-        if ($this->_transaction->paid() === $this->_transaction->total()) {
720
-            // paid in full
721
-            $this->_template_args['amount_due'] = false;
722
-        } elseif ($this->_transaction->paid() > $this->_transaction->total()) {
723
-            // overpaid
724
-            $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
725
-        } elseif ($this->_transaction->total() > (float) 0) {
726
-            if ($this->_transaction->paid() > (float) 0) {
727
-                // monies owing
728
-                $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
729
-            } elseif ($this->_transaction->paid() === (float) 0) {
730
-                // no payments made yet
731
-                $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
732
-            }
733
-        } elseif ($this->_transaction->total() === (float) 0) {
734
-            // free event
735
-            $this->_template_args['amount_due'] = false;
736
-        }
737
-
738
-        $payment_method = $this->_transaction->payment_method();
739
-
740
-        $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
741
-            ? $payment_method->admin_name()
742
-            : esc_html__('Unknown', 'event_espresso');
743
-
744
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
745
-        // link back to overview
746
-        $this->_template_args['txn_overview_url'] = $this->request->getServerParam(
747
-            'HTTP_REFERER',
748
-            TXN_ADMIN_URL
749
-        );
750
-
751
-
752
-        // next link
753
-        $next_txn                                 = $this->_transaction->next(
754
-            null,
755
-            [['STS_ID' => ['!=', EEM_Transaction::failed_status_code]]],
756
-            'TXN_ID'
757
-        );
758
-        $this->_template_args['next_transaction'] = $next_txn
759
-            ? $this->_next_link(
760
-                EE_Admin_Page::add_query_args_and_nonce(
761
-                    ['action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']],
762
-                    TXN_ADMIN_URL
763
-                ),
764
-                'dashicons dashicons-arrow-right ee-icon-size-22'
765
-            )
766
-            : '';
767
-        // previous link
768
-        $previous_txn                                 = $this->_transaction->previous(
769
-            null,
770
-            [['STS_ID' => ['!=', EEM_Transaction::failed_status_code]]],
771
-            'TXN_ID'
772
-        );
773
-        $this->_template_args['previous_transaction'] = $previous_txn
774
-            ? $this->_previous_link(
775
-                EE_Admin_Page::add_query_args_and_nonce(
776
-                    ['action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']],
777
-                    TXN_ADMIN_URL
778
-                ),
779
-                'dashicons dashicons-arrow-left ee-icon-size-22'
780
-            )
781
-            : '';
782
-
783
-        $EVT_ID        = $this->request->getRequestParam('EVT_ID', 0, 'int');
784
-        $event_name    = $this->request->getRequestParam('event_name');
785
-        $redirect_from = $this->request->getRequestParam('redirect_from', '', 'url');
786
-
787
-        // were we just redirected here after adding a new registration ???
788
-        if ($EVT_ID && $event_name && $redirect_from) {
789
-            if (
790
-                EE_Registry::instance()->CAP->current_user_can(
791
-                    'ee_edit_registrations',
792
-                    'espresso_registrations_new_registration',
793
-                    $EVT_ID
794
-                )
795
-            ) {
796
-                $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
797
-                $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
798
-                    [
799
-                        'page'     => 'espresso_registrations',
800
-                        'action'   => 'new_registration',
801
-                        'return'   => 'default',
802
-                        'TXN_ID'   => $this->_transaction->ID(),
803
-                        'event_id' => $EVT_ID,
804
-                    ],
805
-                    REG_ADMIN_URL
806
-                );
807
-                $this->_admin_page_title .= '">';
808
-
809
-                $this->_admin_page_title .= sprintf(
810
-                    esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
811
-                    htmlentities(urldecode($event_name), ENT_QUOTES, 'UTF-8')
812
-                );
813
-                $this->_admin_page_title .= '</a>';
814
-            }
815
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
816
-        }
817
-        // grab messages at the last second
818
-        $this->_template_args['notices'] = EE_Error::get_notices();
819
-        // path to template
820
-        $template_path                             = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
821
-        $this->_template_args['admin_page_header'] = EEH_Template::display_template(
822
-            $template_path,
823
-            $this->_template_args,
824
-            true
825
-        );
826
-
827
-        // the details template wrapper
828
-        $this->display_admin_page_with_sidebar();
829
-    }
830
-
831
-
832
-    /**
833
-     *        _transaction_details_metaboxes
834
-     *
835
-     * @access protected
836
-     * @return void
837
-     * @throws EE_Error
838
-     * @throws InvalidArgumentException
839
-     * @throws InvalidDataTypeException
840
-     * @throws InvalidInterfaceException
841
-     * @throws RuntimeException
842
-     * @throws ReflectionException
843
-     */
844
-    protected function _transaction_details_metaboxes()
845
-    {
846
-
847
-        $this->_set_transaction_object();
848
-
849
-        if (! $this->_transaction instanceof EE_Transaction) {
850
-            return;
851
-        }
852
-        add_meta_box(
853
-            'edit-txn-details-mbox',
854
-            esc_html__('Transaction Details', 'event_espresso'),
855
-            [$this, 'txn_details_meta_box'],
856
-            $this->_wp_page_slug,
857
-            'normal',
858
-            'high'
859
-        );
860
-        add_meta_box(
861
-            'edit-txn-attendees-mbox',
862
-            esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
863
-            [$this, 'txn_attendees_meta_box'],
864
-            $this->_wp_page_slug,
865
-            'normal',
866
-            'high',
867
-            ['TXN_ID' => $this->_transaction->ID()]
868
-        );
869
-        add_meta_box(
870
-            'edit-txn-registrant-mbox',
871
-            esc_html__('Primary Contact', 'event_espresso'),
872
-            [$this, 'txn_registrant_side_meta_box'],
873
-            $this->_wp_page_slug,
874
-            'side',
875
-            'high'
876
-        );
877
-        add_meta_box(
878
-            'edit-txn-billing-info-mbox',
879
-            esc_html__('Billing Information', 'event_espresso'),
880
-            [$this, 'txn_billing_info_side_meta_box'],
881
-            $this->_wp_page_slug,
882
-            'side',
883
-            'high'
884
-        );
885
-    }
886
-
887
-
888
-    /**
889
-     * Callback for transaction actions metabox.
890
-     *
891
-     * @param EE_Transaction|null $transaction
892
-     * @return string
893
-     * @throws DomainException
894
-     * @throws EE_Error
895
-     * @throws InvalidArgumentException
896
-     * @throws InvalidDataTypeException
897
-     * @throws InvalidInterfaceException
898
-     * @throws ReflectionException
899
-     * @throws RuntimeException
900
-     */
901
-    public function getActionButtons(EE_Transaction $transaction = null)
902
-    {
903
-        $content = '';
904
-        $actions = [];
905
-        if (! $transaction instanceof EE_Transaction) {
906
-            return $content;
907
-        }
908
-        /** @var EE_Registration $primary_registration */
909
-        $primary_registration = $transaction->primary_registration();
910
-        $attendee             = $primary_registration instanceof EE_Registration
911
-            ? $primary_registration->attendee()
912
-            : null;
913
-
914
-        if (
915
-            $attendee instanceof EE_Attendee
916
-            && EE_Registry::instance()->CAP->current_user_can(
917
-                'ee_send_message',
918
-                'espresso_transactions_send_payment_reminder'
919
-            )
920
-        ) {
921
-            $actions['payment_reminder'] =
922
-                EEH_MSG_Template::is_mt_active('payment_reminder')
923
-                && $this->_transaction->status_ID() !== EEM_Transaction::complete_status_code
924
-                && $this->_transaction->status_ID() !== EEM_Transaction::overpaid_status_code
925
-                    ? EEH_Template::get_button_or_link(
926
-                        EE_Admin_Page::add_query_args_and_nonce(
927
-                            [
928
-                            'action'      => 'send_payment_reminder',
929
-                            'TXN_ID'      => $this->_transaction->ID(),
930
-                            'redirect_to' => 'view_transaction',
931
-                            ],
932
-                            TXN_ADMIN_URL
933
-                        ),
934
-                        esc_html__(' Send Payment Reminder', 'event_espresso'),
935
-                        'button secondary-button',
936
-                        'dashicons dashicons-email-alt'
937
-                    )
938
-                    : '';
939
-        }
940
-
941
-        if (
942
-            EE_Registry::instance()->CAP->current_user_can(
943
-                'ee_edit_payments',
944
-                'espresso_transactions_recalculate_line_items'
945
-            )
946
-        ) {
947
-            $actions['recalculate_line_items'] = EEH_Template::get_button_or_link(
948
-                EE_Admin_Page::add_query_args_and_nonce(
949
-                    [
950
-                        'action'      => 'espresso_recalculate_line_items',
951
-                        'TXN_ID'      => $this->_transaction->ID(),
952
-                        'redirect_to' => 'view_transaction',
953
-                    ],
954
-                    TXN_ADMIN_URL
955
-                ),
956
-                esc_html__(' Recalculate Taxes and Total', 'event_espresso'),
957
-                'button secondary-button',
958
-                'dashicons dashicons-update'
959
-            );
960
-        }
961
-
962
-        if (
963
-            $primary_registration instanceof EE_Registration
964
-            && EEH_MSG_Template::is_mt_active('receipt')
965
-        ) {
966
-            $actions['receipt'] = EEH_Template::get_button_or_link(
967
-                $primary_registration->receipt_url(),
968
-                esc_html__('View Receipt', 'event_espresso'),
969
-                'button secondary-button',
970
-                'dashicons dashicons-media-default'
971
-            );
972
-        }
973
-
974
-        if (
975
-            $primary_registration instanceof EE_Registration
976
-            && EEH_MSG_Template::is_mt_active('invoice')
977
-        ) {
978
-            $actions['invoice'] = EEH_Template::get_button_or_link(
979
-                $primary_registration->invoice_url(),
980
-                esc_html__('View Invoice', 'event_espresso'),
981
-                'button secondary-button',
982
-                'dashicons dashicons-media-spreadsheet'
983
-            );
984
-        }
985
-        $actions = array_filter(
986
-            apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction)
987
-        );
988
-        if ($actions) {
989
-            $content = '<ul>';
990
-            $content .= '<li>' . implode('</li><li>', $actions) . '</li>';
991
-            $content .= '</uL>';
992
-        }
993
-        return $content;
994
-    }
995
-
996
-
997
-    /**
998
-     * txn_details_meta_box
999
-     * generates HTML for the Transaction main meta box
1000
-     *
1001
-     * @return void
1002
-     * @throws DomainException
1003
-     * @throws EE_Error
1004
-     * @throws InvalidArgumentException
1005
-     * @throws InvalidDataTypeException
1006
-     * @throws InvalidInterfaceException
1007
-     * @throws RuntimeException
1008
-     * @throws ReflectionException
1009
-     */
1010
-    public function txn_details_meta_box()
1011
-    {
1012
-        $this->_set_transaction_object();
1013
-        $this->_template_args['TXN_ID']              = $this->_transaction->ID();
1014
-        $this->_template_args['attendee']            =
1015
-            $this->_transaction->primary_registration() instanceof EE_Registration
1016
-                ? $this->_transaction->primary_registration()->attendee()
1017
-                : null;
1018
-        $this->_template_args['can_edit_payments']   = EE_Registry::instance()->CAP->current_user_can(
1019
-            'ee_edit_payments',
1020
-            'apply_payment_or_refund_from_registration_details'
1021
-        );
1022
-        $this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can(
1023
-            'ee_delete_payments',
1024
-            'delete_payment_from_registration_details'
1025
-        );
1026
-
1027
-        // get line table
1028
-        EEH_Autoloader::register_line_item_display_autoloaders();
1029
-        $Line_Item_Display                       = new EE_Line_Item_Display(
1030
-            'admin_table',
1031
-            'EE_Admin_Table_Line_Item_Display_Strategy'
1032
-        );
1033
-        $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item(
1034
-            $this->_transaction->total_line_item()
1035
-        );
1036
-        $this->_template_args['REG_code']        =
1037
-            $this->_transaction->primary_registration() instanceof EE_Registration
1038
-                ? $this->_transaction->primary_registration()->reg_code()
1039
-                : null;
1040
-        // process taxes
1041
-        $taxes                         = $this->_transaction->line_items([['LIN_type' => EEM_Line_Item::type_tax]]);
1042
-        $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1043
-
1044
-        $this->_template_args['grand_total']     = EEH_Template::format_currency(
1045
-            $this->_transaction->total(),
1046
-            false,
1047
-            false
1048
-        );
1049
-        $this->_template_args['grand_raw_total'] = $this->_transaction->total();
1050
-        $this->_template_args['TXN_status']      = $this->_transaction->status_ID();
1051
-
1052
-        // process payment details
1053
-        $payments = $this->_transaction->payments();
1054
-        if (! empty($payments)) {
1055
-            $this->_template_args['payments']              = $payments;
1056
-            $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1057
-        } else {
1058
-            $this->_template_args['payments']              = false;
1059
-            $this->_template_args['existing_reg_payments'] = [];
1060
-        }
1061
-
1062
-        $this->_template_args['edit_payment_url']   = add_query_arg(['action' => 'edit_payment'], TXN_ADMIN_URL);
1063
-        $this->_template_args['delete_payment_url'] = add_query_arg(
1064
-            ['action' => 'espresso_delete_payment'],
1065
-            TXN_ADMIN_URL
1066
-        );
1067
-
1068
-        if (isset($txn_details['invoice_number'])) {
1069
-            $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
1070
-            $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__(
1071
-                'Invoice Number',
1072
-                'event_espresso'
1073
-            );
1074
-        }
1075
-
1076
-        $this->_template_args['txn_details']['registration_session']['value'] =
1077
-            $this->_transaction->primary_registration() instanceof EE_Registration
1078
-                ? $this->_transaction->primary_registration()->session_ID()
1079
-                : null;
1080
-        $this->_template_args['txn_details']['registration_session']['label'] = esc_html__(
1081
-            'Registration Session',
1082
-            'event_espresso'
1083
-        );
1084
-
1085
-        $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address'])
1086
-            ? $this->_session['ip_address']
1087
-            : '';
1088
-        $this->_template_args['txn_details']['ip_address']['label'] = esc_html__(
1089
-            'Transaction placed from IP',
1090
-            'event_espresso'
1091
-        );
1092
-
1093
-        $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent'])
1094
-            ? $this->_session['user_agent']
1095
-            : '';
1096
-        $this->_template_args['txn_details']['user_agent']['label'] = esc_html__(
1097
-            'Registrant User Agent',
1098
-            'event_espresso'
1099
-        );
1100
-
1101
-        $reg_steps = '<ul>';
1102
-        foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
1103
-            if ($reg_step_status === true) {
1104
-                $reg_steps .= '<li style="color:#70cc50">'
1105
-                              . sprintf(
1106
-                                  esc_html__('%1$s : Completed', 'event_espresso'),
1107
-                                  ucwords(str_replace('_', ' ', $reg_step))
1108
-                              )
1109
-                              . '</li>';
1110
-            } elseif ($reg_step_status !== false && is_numeric($reg_step_status)) {
1111
-                $reg_steps .= '<li style="color:#2EA2CC">'
1112
-                              . sprintf(
1113
-                                  esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1114
-                                  ucwords(str_replace('_', ' ', $reg_step)),
1115
-                                  date(
1116
-                                      get_option('date_format') . ' ' . get_option('time_format'),
1117
-                                      $reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1118
-                                  )
1119
-                              )
1120
-                              . '</li>';
1121
-            } else {
1122
-                $reg_steps .= '<li style="color:#E76700">'
1123
-                              . sprintf(
1124
-                                  esc_html__('%1$s : Never Initiated', 'event_espresso'),
1125
-                                  ucwords(str_replace('_', ' ', $reg_step))
1126
-                              )
1127
-                              . '</li>';
1128
-            }
1129
-        }
1130
-        $reg_steps                                                 .= '</ul>';
1131
-        $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1132
-        $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1133
-            'Registration Step Progress',
1134
-            'event_espresso'
1135
-        );
1136
-
1137
-
1138
-        $this->_get_registrations_to_apply_payment_to();
1139
-        $this->_get_payment_methods($payments);
1140
-        $this->_get_payment_status_array();
1141
-        $this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1142
-
1143
-        $this->_template_args['transaction_form_url']    = add_query_arg(
1144
-            [
1145
-                'action'  => 'edit_transaction',
1146
-                'process' => 'transaction',
1147
-            ],
1148
-            TXN_ADMIN_URL
1149
-        );
1150
-        $this->_template_args['apply_payment_form_url']  = add_query_arg(
1151
-            [
1152
-                'page'   => 'espresso_transactions',
1153
-                'action' => 'espresso_apply_payment',
1154
-            ],
1155
-            WP_AJAX_URL
1156
-        );
1157
-        $this->_template_args['delete_payment_form_url'] = add_query_arg(
1158
-            [
1159
-                'page'   => 'espresso_transactions',
1160
-                'action' => 'espresso_delete_payment',
1161
-            ],
1162
-            WP_AJAX_URL
1163
-        );
1164
-
1165
-        $this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction);
1166
-
1167
-        // 'espresso_delete_payment_nonce'
1168
-
1169
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1170
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1171
-    }
1172
-
1173
-
1174
-    /**
1175
-     * _get_registration_payment_IDs
1176
-     *    generates an array of Payment IDs and their corresponding Registration IDs
1177
-     *
1178
-     * @access protected
1179
-     * @param EE_Payment[] $payments
1180
-     * @return array
1181
-     * @throws EE_Error
1182
-     * @throws InvalidArgumentException
1183
-     * @throws InvalidDataTypeException
1184
-     * @throws InvalidInterfaceException
1185
-     * @throws ReflectionException
1186
-     */
1187
-    protected function _get_registration_payment_IDs($payments = [])
1188
-    {
1189
-        $existing_reg_payments = [];
1190
-        // get all reg payments for these payments
1191
-        $reg_payments = EEM_Registration_Payment::instance()->get_all(
1192
-            [
1193
-                [
1194
-                    'PAY_ID' => [
1195
-                        'IN',
1196
-                        array_keys($payments),
1197
-                    ],
1198
-                ],
1199
-            ]
1200
-        );
1201
-        if (! empty($reg_payments)) {
1202
-            foreach ($payments as $payment) {
1203
-                if (! $payment instanceof EE_Payment) {
1204
-                    continue;
1205
-                } elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1206
-                    $existing_reg_payments[ $payment->ID() ] = [];
1207
-                }
1208
-                foreach ($reg_payments as $reg_payment) {
1209
-                    if (
1210
-                        $reg_payment instanceof EE_Registration_Payment
1211
-                        && $reg_payment->payment_ID() === $payment->ID()
1212
-                    ) {
1213
-                        $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1214
-                    }
1215
-                }
1216
-            }
1217
-        }
1218
-
1219
-        return $existing_reg_payments;
1220
-    }
1221
-
1222
-
1223
-    /**
1224
-     * _get_registrations_to_apply_payment_to
1225
-     *    generates HTML for displaying a series of checkboxes in the admin payment modal window
1226
-     * which allows the admin to only apply the payment to the specific registrations
1227
-     *
1228
-     * @access protected
1229
-     * @return void
1230
-     * @throws EE_Error
1231
-     * @throws InvalidArgumentException
1232
-     * @throws InvalidDataTypeException
1233
-     * @throws InvalidInterfaceException
1234
-     * @throws ReflectionException
1235
-     */
1236
-    protected function _get_registrations_to_apply_payment_to()
1237
-    {
1238
-        // we want any registration with an active status (ie: not deleted or cancelled)
1239
-        $query_params                      = [
1240
-            [
1241
-                'STS_ID' => [
1242
-                    'IN',
1243
-                    [
1244
-                        EEM_Registration::status_id_approved,
1245
-                        EEM_Registration::status_id_pending_payment,
1246
-                        EEM_Registration::status_id_not_approved,
1247
-                    ],
1248
-                ],
1249
-            ],
1250
-        ];
1251
-        $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
1252
-            '',
1253
-            'txn-admin-apply-payment-to-registrations-dv',
1254
-            '',
1255
-            'clear: both; margin: 1.5em 0 0; display: none;'
1256
-        );
1257
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1258
-        $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1259
-        $registrations_to_apply_payment_to .= EEH_HTML::thead(
1260
-            EEH_HTML::tr(
1261
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1262
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1263
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1264
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1265
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1266
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1267
-                EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1268
-            )
1269
-        );
1270
-        $registrations_to_apply_payment_to .= EEH_HTML::tbody();
1271
-        // get registrations for TXN
1272
-        $registrations         = $this->_transaction->registrations($query_params);
1273
-        $existing_reg_payments = $this->_template_args['existing_reg_payments'];
1274
-        foreach ($registrations as $registration) {
1275
-            if ($registration instanceof EE_Registration) {
1276
-                $attendee_name                     = $registration->attendee() instanceof EE_Attendee
1277
-                    ? $registration->attendee()->full_name()
1278
-                    : esc_html__('Unknown Attendee', 'event_espresso');
1279
-                $owing                             = $registration->final_price() - $registration->paid();
1280
-                $taxable                           = $registration->ticket()->taxable()
1281
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1282
-                    : '';
1283
-                $checked                           = empty($existing_reg_payments)
1284
-                                                     || in_array($registration->ID(), $existing_reg_payments, true)
1285
-                    ? ' checked'
1286
-                    : '';
1287
-                $disabled                          = $registration->final_price() > 0 ? '' : ' disabled';
1288
-                $registrations_to_apply_payment_to .= EEH_HTML::tr(
1289
-                    EEH_HTML::td($registration->ID()) .
1290
-                    EEH_HTML::td($attendee_name) .
1291
-                    EEH_HTML::td(
1292
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1293
-                    ) .
1294
-                    EEH_HTML::td($registration->event_name()) .
1295
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1296
-                    EEH_HTML::td(
1297
-                        EEH_Template::format_currency($owing),
1298
-                        '',
1299
-                        'txn-admin-payment-owing-td jst-cntr'
1300
-                    ) .
1301
-                    EEH_HTML::td(
1302
-                        '<input type="checkbox" value="' . $registration->ID()
1303
-                        . '" name="txn_admin_payment[registrations]"'
1304
-                        . $checked . $disabled . '>',
1305
-                        '',
1306
-                        'jst-cntr'
1307
-                    ),
1308
-                    'apply-payment-registration-row-' . $registration->ID()
1309
-                );
1310
-            }
1311
-        }
1312
-        $registrations_to_apply_payment_to                         .= EEH_HTML::tbodyx();
1313
-        $registrations_to_apply_payment_to                         .= EEH_HTML::tablex();
1314
-        $registrations_to_apply_payment_to                         .= EEH_HTML::divx();
1315
-        $registrations_to_apply_payment_to                         .= EEH_HTML::p(
1316
-            esc_html__(
1317
-                'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.',
1318
-                'event_espresso'
1319
-            ),
1320
-            '',
1321
-            'clear description'
1322
-        );
1323
-        $registrations_to_apply_payment_to                         .= EEH_HTML::divx();
1324
-        $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1325
-    }
1326
-
1327
-
1328
-    /**
1329
-     * _get_reg_status_selection
1330
-     *
1331
-     * @return void
1332
-     * @throws EE_Error
1333
-     * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1334
-     *         instead of events.
1335
-     * @access protected
1336
-     */
1337
-    protected function _get_reg_status_selection()
1338
-    {
1339
-        // first get all possible statuses
1340
-        $statuses = EEM_Registration::reg_status_array([], true);
1341
-        // let's add a "don't change" option.
1342
-        $status_array['NAN']                                 = esc_html__('Leave the Same', 'event_espresso');
1343
-        $status_array                                        = array_merge($status_array, $statuses);
1344
-        $this->_template_args['status_change_select']        = EEH_Form_Fields::select_input(
1345
-            'txn_reg_status_change[reg_status]',
1346
-            $status_array,
1347
-            'NAN',
1348
-            'id="txn-admin-payment-reg-status-inp"',
1349
-            'txn-reg-status-change-reg-status'
1350
-        );
1351
-        $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input(
1352
-            'delete_txn_reg_status_change[reg_status]',
1353
-            $status_array,
1354
-            'NAN',
1355
-            'delete-txn-admin-payment-reg-status-inp',
1356
-            'delete-txn-reg-status-change-reg-status'
1357
-        );
1358
-    }
1359
-
1360
-
1361
-    /**
1362
-     *    _get_payment_methods
1363
-     * Gets all the payment methods available generally, or the ones that are already
1364
-     * selected on these payments (in case their payment methods are no longer active).
1365
-     * Has the side-effect of updating the template args' payment_methods item
1366
-     *
1367
-     * @access private
1368
-     * @param EE_Payment[] to show on this page
1369
-     * @return void
1370
-     * @throws EE_Error
1371
-     * @throws InvalidArgumentException
1372
-     * @throws InvalidDataTypeException
1373
-     * @throws InvalidInterfaceException
1374
-     * @throws ReflectionException
1375
-     */
1376
-    private function _get_payment_methods($payments = [])
1377
-    {
1378
-        $payment_methods_of_payments = [];
1379
-        foreach ($payments as $payment) {
1380
-            if ($payment instanceof EE_Payment) {
1381
-                $payment_methods_of_payments[] = $payment->ID();
1382
-            }
1383
-        }
1384
-        if ($payment_methods_of_payments) {
1385
-            $query_args = [
1386
-                [
1387
-                    'OR*payment_method_for_payment' => [
1388
-                        'PMD_ID'    => ['IN', $payment_methods_of_payments],
1389
-                        'PMD_scope' => ['LIKE', '%' . EEM_Payment_Method::scope_admin . '%'],
1390
-                    ],
1391
-                ],
1392
-            ];
1393
-        } else {
1394
-            $query_args = [['PMD_scope' => ['LIKE', '%' . EEM_Payment_Method::scope_admin . '%']]];
1395
-        }
1396
-        $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1397
-    }
1398
-
1399
-
1400
-    /**
1401
-     * txn_attendees_meta_box
1402
-     *    generates HTML for the Attendees Transaction main meta box
1403
-     *
1404
-     * @access public
1405
-     * @param WP_Post $post
1406
-     * @param array   $metabox
1407
-     * @return void
1408
-     * @throws DomainException
1409
-     * @throws EE_Error
1410
-     * @throws InvalidArgumentException
1411
-     * @throws InvalidDataTypeException
1412
-     * @throws InvalidInterfaceException
1413
-     * @throws ReflectionException
1414
-     */
1415
-    public function txn_attendees_meta_box($post, $metabox = ['args' => []])
1416
-    {
1417
-
1418
-        /** @noinspection NonSecureExtractUsageInspection */
1419
-        extract($metabox['args']);
1420
-        $this->_template_args['post']            = $post;
1421
-        $this->_template_args['event_attendees'] = [];
1422
-        // process items in cart
1423
-        $line_items = $this->_transaction->get_many_related(
1424
-            'Line_Item',
1425
-            [['LIN_type' => 'line-item']]
1426
-        );
1427
-        if (! empty($line_items)) {
1428
-            foreach ($line_items as $item) {
1429
-                if ($item instanceof EE_Line_Item) {
1430
-                    switch ($item->OBJ_type()) {
1431
-                        case 'Event':
1432
-                            break;
1433
-                        case 'Ticket':
1434
-                            $ticket = $item->ticket();
1435
-                            // right now we're only handling tickets here.
1436
-                            // Cause its expected that only tickets will have attendees right?
1437
-                            if (! $ticket instanceof EE_Ticket) {
1438
-                                break;
1439
-                            }
1440
-                            try {
1441
-                                $event_name = $ticket->get_event_name();
1442
-                            } catch (Exception $e) {
1443
-                                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1444
-                                $event_name = esc_html__('Unknown Event', 'event_espresso');
1445
-                            }
1446
-                            $event_name   .= ' - ' . $item->name();
1447
-                            $ticket_price = EEH_Template::format_currency($item->unit_price());
1448
-                            // now get all of the registrations for this transaction that use this ticket
1449
-                            $registrations = $ticket->registrations(
1450
-                                [['TXN_ID' => $this->_transaction->ID()]]
1451
-                            );
1452
-                            foreach ($registrations as $registration) {
1453
-                                if (! $registration instanceof EE_Registration) {
1454
-                                    break;
1455
-                                }
1456
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1457
-                                    = $registration->status_ID();
1458
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1459
-                                    = $registration->count();
1460
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1461
-                                    = $event_name;
1462
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1463
-                                    = $ticket_price;
1464
-                                // attendee info
1465
-                                $attendee = $registration->get_first_related('Attendee');
1466
-                                if ($attendee instanceof EE_Attendee) {
1467
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1468
-                                        = $attendee->ID();
1469
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1470
-                                        = $attendee->full_name();
1471
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']
1472
-                                        = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1473
-                                          . esc_html__(
1474
-                                              ' Event',
1475
-                                              'event_espresso'
1476
-                                          )
1477
-                                          . '">' . $attendee->email() . '</a>';
1478
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']
1479
-                                        = EEH_Address::format($attendee, 'inline', false, false);
1480
-                                } else {
1481
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']   = '';
1482
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1483
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']    = '';
1484
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']  = '';
1485
-                                }
1486
-                            }
1487
-                            break;
1488
-                    }
1489
-                }
1490
-            }
1491
-
1492
-            $this->_template_args['transaction_form_url'] = add_query_arg(
1493
-                [
1494
-                    'action'  => 'edit_transaction',
1495
-                    'process' => 'attendees',
1496
-                ],
1497
-                TXN_ADMIN_URL
1498
-            );
1499
-            echo EEH_Template::display_template(
1500
-                TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1501
-                $this->_template_args,
1502
-                true
1503
-            );
1504
-        } else {
1505
-            printf(
1506
-                esc_html__(
1507
-                    '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1508
-                    'event_espresso'
1509
-                ),
1510
-                '<p class="important-notice">',
1511
-                '</p>'
1512
-            );
1513
-        }
1514
-    }
1515
-
1516
-
1517
-    /**
1518
-     * txn_registrant_side_meta_box
1519
-     * generates HTML for the Edit Transaction side meta box
1520
-     *
1521
-     * @access public
1522
-     * @return void
1523
-     * @throws DomainException
1524
-     * @throws EE_Error
1525
-     * @throws InvalidArgumentException
1526
-     * @throws InvalidDataTypeException
1527
-     * @throws InvalidInterfaceException
1528
-     * @throws ReflectionException
1529
-     */
1530
-    public function txn_registrant_side_meta_box()
1531
-    {
1532
-        $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1533
-            ? $this->_transaction->primary_registration()->get_first_related('Attendee')
1534
-            : null;
1535
-        if (! $primary_att instanceof EE_Attendee) {
1536
-            $this->_template_args['no_attendee_message'] = esc_html__(
1537
-                'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1538
-                'event_espresso'
1539
-            );
1540
-            $primary_att                           = EEM_Attendee::instance()->create_default_object();
1541
-        }
1542
-        $this->_template_args['ATT_ID']            = $primary_att->ID();
1543
-        $this->_template_args['prime_reg_fname']   = $primary_att->fname();
1544
-        $this->_template_args['prime_reg_lname']   = $primary_att->lname();
1545
-        $this->_template_args['prime_reg_email']   = $primary_att->email();
1546
-        $this->_template_args['prime_reg_phone']   = $primary_att->phone();
1547
-        $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(
1548
-            [
1549
-                'action' => 'edit_attendee',
1550
-                'post'   => $primary_att->ID(),
1551
-            ],
1552
-            REG_ADMIN_URL
1553
-        );
1554
-        // get formatted address for registrant
1555
-        $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1556
-        echo EEH_Template::display_template(
1557
-            TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1558
-            $this->_template_args,
1559
-            true
1560
-        );
1561
-    }
1562
-
1563
-
1564
-    /**
1565
-     * txn_billing_info_side_meta_box
1566
-     *    generates HTML for the Edit Transaction side meta box
1567
-     *
1568
-     * @access public
1569
-     * @return void
1570
-     * @throws DomainException
1571
-     * @throws EE_Error
1572
-     * @throws ReflectionException
1573
-     */
1574
-    public function txn_billing_info_side_meta_box()
1575
-    {
1576
-
1577
-        $this->_template_args['billing_form']     = $this->_transaction->billing_info();
1578
-        $this->_template_args['billing_form_url'] = add_query_arg(
1579
-            ['action' => 'edit_transaction', 'process' => 'billing'],
1580
-            TXN_ADMIN_URL
1581
-        );
1582
-
1583
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1584
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1585
-    }
1586
-
1587
-
1588
-    /**
1589
-     * apply_payments_or_refunds
1590
-     *    registers a payment or refund made towards a transaction
1591
-     *
1592
-     * @access public
1593
-     * @return void
1594
-     * @throws EE_Error
1595
-     * @throws InvalidArgumentException
1596
-     * @throws ReflectionException
1597
-     * @throws RuntimeException
1598
-     * @throws InvalidDataTypeException
1599
-     * @throws InvalidInterfaceException
1600
-     */
1601
-    public function apply_payments_or_refunds()
1602
-    {
1603
-        $json_response_data = ['return_data' => false];
1604
-        $valid_data         = $this->_validate_payment_request_data();
1605
-        $has_access         = EE_Registry::instance()->CAP->current_user_can(
1606
-            'ee_edit_payments',
1607
-            'apply_payment_or_refund_from_registration_details'
1608
-        );
1609
-        if (! empty($valid_data) && $has_access) {
1610
-            $PAY_ID = $valid_data['PAY_ID'];
1611
-            // save  the new payment
1612
-            $payment = $this->_create_payment_from_request_data($valid_data);
1613
-            // get the TXN for this payment
1614
-            $transaction = $payment->transaction();
1615
-            // verify transaction
1616
-            if ($transaction instanceof EE_Transaction) {
1617
-                // calculate_total_payments_and_update_status
1618
-                $this->_process_transaction_payments($transaction);
1619
-                $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1620
-                $this->_remove_existing_registration_payments($payment, $PAY_ID);
1621
-                // apply payment to registrations (if applicable)
1622
-                if (! empty($REG_IDs)) {
1623
-                    $this->_update_registration_payments($transaction, $payment, $REG_IDs);
1624
-                    $this->_maybe_send_notifications();
1625
-                    // now process status changes for the same registrations
1626
-                    $this->_process_registration_status_change($transaction, $REG_IDs);
1627
-                }
1628
-                $this->_maybe_send_notifications($payment);
1629
-                // prepare to render page
1630
-                $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1631
-                do_action(
1632
-                    'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording',
1633
-                    $transaction,
1634
-                    $payment
1635
-                );
1636
-            } else {
1637
-                EE_Error::add_error(
1638
-                    esc_html__(
1639
-                        'A valid Transaction for this payment could not be retrieved.',
1640
-                        'event_espresso'
1641
-                    ),
1642
-                    __FILE__,
1643
-                    __FUNCTION__,
1644
-                    __LINE__
1645
-                );
1646
-            }
1647
-        } elseif ($has_access) {
1648
-            EE_Error::add_error(
1649
-                esc_html__(
1650
-                    'The payment form data could not be processed. Please try again.',
1651
-                    'event_espresso'
1652
-                ),
1653
-                __FILE__,
1654
-                __FUNCTION__,
1655
-                __LINE__
1656
-            );
1657
-        } else {
1658
-            EE_Error::add_error(
1659
-                esc_html__(
1660
-                    'You do not have access to apply payments or refunds to a registration.',
1661
-                    'event_espresso'
1662
-                ),
1663
-                __FILE__,
1664
-                __FUNCTION__,
1665
-                __LINE__
1666
-            );
1667
-        }
1668
-        $notices              = EE_Error::get_notices(
1669
-            false,
1670
-            false,
1671
-            false
1672
-        );
1673
-        $this->_template_args = [
1674
-            'data'    => $json_response_data,
1675
-            'error'   => $notices['errors'],
1676
-            'success' => $notices['success'],
1677
-        ];
1678
-        $this->_return_json();
1679
-    }
1680
-
1681
-
1682
-    /**
1683
-     * _validate_payment_request_data
1684
-     *
1685
-     * @return array
1686
-     * @throws EE_Error
1687
-     * @throws InvalidArgumentException
1688
-     * @throws InvalidDataTypeException
1689
-     * @throws InvalidInterfaceException
1690
-     */
1691
-    protected function _validate_payment_request_data()
1692
-    {
1693
-        if (! $this->request->requestParamIsSet('txn_admin_payment')) {
1694
-            return [];
1695
-        }
1696
-        $payment_form = $this->_generate_payment_form_section();
1697
-        try {
1698
-            if ($payment_form->was_submitted()) {
1699
-                $payment_form->receive_form_submission();
1700
-                if (! $payment_form->is_valid()) {
1701
-                    $submission_error_messages = [];
1702
-                    foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1703
-                        if ($validation_error instanceof EE_Validation_Error) {
1704
-                            $form_input = $validation_error->get_form_section();
1705
-                            $submission_error_messages[] = sprintf(
1706
-                                _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1707
-                                $form_input instanceof EE_Form_Input_Base ? $form_input->html_label_text() : '',
1708
-                                $validation_error->getMessage()
1709
-                            );
1710
-                        }
1711
-                    }
1712
-                    EE_Error::add_error(
1713
-                        implode('<br />', $submission_error_messages),
1714
-                        __FILE__,
1715
-                        __FUNCTION__,
1716
-                        __LINE__
1717
-                    );
1718
-                    return [];
1719
-                }
1720
-            }
1721
-        } catch (EE_Error $e) {
1722
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1723
-            return [];
1724
-        }
1725
-
1726
-        return $payment_form->valid_data();
1727
-    }
1728
-
1729
-
1730
-    /**
1731
-     * _generate_payment_form_section
1732
-     *
1733
-     * @return EE_Form_Section_Proper
1734
-     * @throws EE_Error
1735
-     */
1736
-    protected function _generate_payment_form_section()
1737
-    {
1738
-        return new EE_Form_Section_Proper(
1739
-            [
1740
-                'name'        => 'txn_admin_payment',
1741
-                'subsections' => [
1742
-                    'PAY_ID'          => new EE_Text_Input(
1743
-                        [
1744
-                            'default'               => 0,
1745
-                            'required'              => false,
1746
-                            'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1747
-                            'validation_strategies' => [new EE_Int_Normalization()],
1748
-                        ]
1749
-                    ),
1750
-                    'TXN_ID'          => new EE_Text_Input(
1751
-                        [
1752
-                            'default'               => 0,
1753
-                            'required'              => true,
1754
-                            'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1755
-                            'validation_strategies' => [new EE_Int_Normalization()],
1756
-                        ]
1757
-                    ),
1758
-                    'type'            => new EE_Text_Input(
1759
-                        [
1760
-                            'default'               => 1,
1761
-                            'required'              => true,
1762
-                            'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1763
-                            'validation_strategies' => [new EE_Int_Normalization()],
1764
-                        ]
1765
-                    ),
1766
-                    'amount'          => new EE_Text_Input(
1767
-                        [
1768
-                            'default'               => 0,
1769
-                            'required'              => true,
1770
-                            'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1771
-                            'validation_strategies' => [new EE_Float_Normalization()],
1772
-                        ]
1773
-                    ),
1774
-                    'status'          => new EE_Text_Input(
1775
-                        [
1776
-                            'default'         => EEM_Payment::status_id_approved,
1777
-                            'required'        => true,
1778
-                            'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1779
-                        ]
1780
-                    ),
1781
-                    'PMD_ID'          => new EE_Text_Input(
1782
-                        [
1783
-                            'default'               => 2,
1784
-                            'required'              => true,
1785
-                            'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1786
-                            'validation_strategies' => [new EE_Int_Normalization()],
1787
-                        ]
1788
-                    ),
1789
-                    'date'            => new EE_Text_Input(
1790
-                        [
1791
-                            'default'         => time(),
1792
-                            'required'        => true,
1793
-                            'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1794
-                        ]
1795
-                    ),
1796
-                    'txn_id_chq_nmbr' => new EE_Text_Input(
1797
-                        [
1798
-                            'default'               => '',
1799
-                            'required'              => false,
1800
-                            'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1801
-                            'validation_strategies' => [
1802
-                                new EE_Max_Length_Validation_Strategy(
1803
-                                    esc_html__('Input too long', 'event_espresso'),
1804
-                                    100
1805
-                                ),
1806
-                            ],
1807
-                        ]
1808
-                    ),
1809
-                    'po_number'       => new EE_Text_Input(
1810
-                        [
1811
-                            'default'               => '',
1812
-                            'required'              => false,
1813
-                            'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1814
-                            'validation_strategies' => [
1815
-                                new EE_Max_Length_Validation_Strategy(
1816
-                                    esc_html__('Input too long', 'event_espresso'),
1817
-                                    100
1818
-                                ),
1819
-                            ],
1820
-                        ]
1821
-                    ),
1822
-                    'accounting'      => new EE_Text_Input(
1823
-                        [
1824
-                            'default'               => '',
1825
-                            'required'              => false,
1826
-                            'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1827
-                            'validation_strategies' => [
1828
-                                new EE_Max_Length_Validation_Strategy(
1829
-                                    esc_html__('Input too long', 'event_espresso'),
1830
-                                    100
1831
-                                ),
1832
-                            ],
1833
-                        ]
1834
-                    ),
1835
-                ],
1836
-            ]
1837
-        );
1838
-    }
1839
-
1840
-
1841
-    /**
1842
-     * _create_payment_from_request_data
1843
-     *
1844
-     * @param array $valid_data
1845
-     * @return EE_Payment
1846
-     * @throws EE_Error
1847
-     * @throws InvalidArgumentException
1848
-     * @throws InvalidDataTypeException
1849
-     * @throws InvalidInterfaceException
1850
-     * @throws ReflectionException
1851
-     */
1852
-    protected function _create_payment_from_request_data($valid_data)
1853
-    {
1854
-        $PAY_ID = $valid_data['PAY_ID'];
1855
-        // get payment amount
1856
-        $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1857
-        // payments have a type value of 1 and refunds have a type value of -1
1858
-        // so multiplying amount by type will give a positive value for payments, and negative values for refunds
1859
-        $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1860
-        // for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1861
-        $date    = $valid_data['date']
1862
-            ? preg_replace('/\s+/', ' ', $valid_data['date'])
1863
-            : date('Y-m-d g:i a', current_time('timestamp'));
1864
-        $payment = EE_Payment::new_instance(
1865
-            [
1866
-                'TXN_ID'              => $valid_data['TXN_ID'],
1867
-                'STS_ID'              => $valid_data['status'],
1868
-                'PAY_timestamp'       => $date,
1869
-                'PAY_source'          => EEM_Payment_Method::scope_admin,
1870
-                'PMD_ID'              => $valid_data['PMD_ID'],
1871
-                'PAY_amount'          => $amount,
1872
-                'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1873
-                'PAY_po_number'       => $valid_data['po_number'],
1874
-                'PAY_extra_accntng'   => $valid_data['accounting'],
1875
-                'PAY_details'         => $valid_data,
1876
-                'PAY_ID'              => $PAY_ID,
1877
-            ],
1878
-            '',
1879
-            ['Y-m-d', 'g:i a']
1880
-        );
1881
-
1882
-        if (! $payment->save()) {
1883
-            EE_Error::add_error(
1884
-                sprintf(
1885
-                    esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1886
-                    $payment->ID()
1887
-                ),
1888
-                __FILE__,
1889
-                __FUNCTION__,
1890
-                __LINE__
1891
-            );
1892
-        }
1893
-
1894
-        return $payment;
1895
-    }
1896
-
1897
-
1898
-    /**
1899
-     * _process_transaction_payments
1900
-     *
1901
-     * @param EE_Transaction $transaction
1902
-     * @return void
1903
-     * @throws EE_Error
1904
-     * @throws InvalidArgumentException
1905
-     * @throws ReflectionException
1906
-     * @throws InvalidDataTypeException
1907
-     * @throws InvalidInterfaceException
1908
-     */
1909
-    protected function _process_transaction_payments(EE_Transaction $transaction)
1910
-    {
1911
-        /** @type EE_Transaction_Payments $transaction_payments */
1912
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1913
-        // update the transaction with this payment
1914
-        if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1915
-            EE_Error::add_success(
1916
-                esc_html__(
1917
-                    'The payment has been processed successfully.',
1918
-                    'event_espresso'
1919
-                ),
1920
-                __FILE__,
1921
-                __FUNCTION__,
1922
-                __LINE__
1923
-            );
1924
-        } else {
1925
-            EE_Error::add_error(
1926
-                esc_html__(
1927
-                    'The payment was processed successfully but the amount paid for the transaction was not updated.',
1928
-                    'event_espresso'
1929
-                ),
1930
-                __FILE__,
1931
-                __FUNCTION__,
1932
-                __LINE__
1933
-            );
1934
-        }
1935
-    }
1936
-
1937
-
1938
-    /**
1939
-     * _get_REG_IDs_to_apply_payment_to
1940
-     * returns a list of registration IDs that the payment will apply to
1941
-     *
1942
-     * @param EE_Payment $payment
1943
-     * @return array
1944
-     * @throws EE_Error
1945
-     * @throws InvalidArgumentException
1946
-     * @throws InvalidDataTypeException
1947
-     * @throws InvalidInterfaceException
1948
-     * @throws ReflectionException
1949
-     */
1950
-    protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1951
-    {
1952
-        // grab array of IDs for specific registrations to apply changes to
1953
-        $REG_IDs = $this->request->getRequestParam('txn_admin_payment[registrations]', [], 'int', true);
1954
-        // nothing specified ? then get all reg IDs
1955
-        if (empty($REG_IDs)) {
1956
-            $registrations = $payment->transaction()->registrations();
1957
-            $REG_IDs       = ! empty($registrations)
1958
-                ? array_keys($registrations)
1959
-                : $this->_get_existing_reg_payment_REG_IDs($payment);
1960
-        }
1961
-
1962
-        // ensure that REG_IDs are integers and NOT strings
1963
-        return array_map('intval', $REG_IDs);
1964
-    }
1965
-
1966
-
1967
-    /**
1968
-     * @return array
1969
-     */
1970
-    public function existing_reg_payment_REG_IDs()
1971
-    {
1972
-        return $this->_existing_reg_payment_REG_IDs;
1973
-    }
1974
-
1975
-
1976
-    /**
1977
-     * @param array $existing_reg_payment_REG_IDs
1978
-     */
1979
-    public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1980
-    {
1981
-        $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1982
-    }
1983
-
1984
-
1985
-    /**
1986
-     * _get_existing_reg_payment_REG_IDs
1987
-     * returns a list of registration IDs that the payment is currently related to
1988
-     * as recorded in the database
1989
-     *
1990
-     * @param EE_Payment $payment
1991
-     * @return array
1992
-     * @throws EE_Error
1993
-     * @throws InvalidArgumentException
1994
-     * @throws InvalidDataTypeException
1995
-     * @throws InvalidInterfaceException
1996
-     * @throws ReflectionException
1997
-     */
1998
-    protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
1999
-    {
2000
-        if ($this->existing_reg_payment_REG_IDs() === null) {
2001
-            // let's get any existing reg payment records for this payment
2002
-            $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
2003
-            // but we only want the REG IDs, so grab the array keys
2004
-            $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs)
2005
-                ? array_keys($existing_reg_payment_REG_IDs)
2006
-                : [];
2007
-            $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
2008
-        }
2009
-
2010
-        return $this->existing_reg_payment_REG_IDs();
2011
-    }
2012
-
2013
-
2014
-    /**
2015
-     * _remove_existing_registration_payments
2016
-     * this calculates the difference between existing relations
2017
-     * to the supplied payment and the new list registration IDs,
2018
-     * removes any related registrations that no longer apply,
2019
-     * and then updates the registration paid fields
2020
-     *
2021
-     * @param EE_Payment $payment
2022
-     * @param int        $PAY_ID
2023
-     * @return bool;
2024
-     * @throws EE_Error
2025
-     * @throws InvalidArgumentException
2026
-     * @throws ReflectionException
2027
-     * @throws InvalidDataTypeException
2028
-     * @throws InvalidInterfaceException
2029
-     */
2030
-    protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
2031
-    {
2032
-        // newly created payments will have nothing recorded for $PAY_ID
2033
-        if (absint($PAY_ID) === 0) {
2034
-            return false;
2035
-        }
2036
-        $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2037
-        if (empty($existing_reg_payment_REG_IDs)) {
2038
-            return false;
2039
-        }
2040
-        /** @type EE_Transaction_Payments $transaction_payments */
2041
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2042
-
2043
-        return $transaction_payments->delete_registration_payments_and_update_registrations(
2044
-            $payment,
2045
-            [
2046
-                [
2047
-                    'PAY_ID' => $payment->ID(),
2048
-                    'REG_ID' => ['IN', $existing_reg_payment_REG_IDs],
2049
-                ],
2050
-            ]
2051
-        );
2052
-    }
2053
-
2054
-
2055
-    /**
2056
-     * _update_registration_payments
2057
-     * this applies the payments to the selected registrations
2058
-     * but only if they have not already been paid for
2059
-     *
2060
-     * @param EE_Transaction $transaction
2061
-     * @param EE_Payment     $payment
2062
-     * @param array          $REG_IDs
2063
-     * @return void
2064
-     * @throws EE_Error
2065
-     * @throws InvalidArgumentException
2066
-     * @throws ReflectionException
2067
-     * @throws RuntimeException
2068
-     * @throws InvalidDataTypeException
2069
-     * @throws InvalidInterfaceException
2070
-     */
2071
-    protected function _update_registration_payments(
2072
-        EE_Transaction $transaction,
2073
-        EE_Payment $payment,
2074
-        $REG_IDs = []
2075
-    ) {
2076
-        // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
2077
-        // so let's do that using our set of REG_IDs from the form
2078
-        $registration_query_where_params = [
2079
-            'REG_ID' => ['IN', $REG_IDs],
2080
-        ];
2081
-        // but add in some conditions regarding payment,
2082
-        // so that we don't apply payments to registrations that are free or have already been paid for
2083
-        // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2084
-        if (! $payment->is_a_refund()) {
2085
-            $registration_query_where_params['REG_final_price']  = ['!=', 0];
2086
-            $registration_query_where_params['REG_final_price*'] = ['!=', 'REG_paid', true];
2087
-        }
2088
-        $registrations = $transaction->registrations([$registration_query_where_params]);
2089
-        if (! empty($registrations)) {
2090
-            /** @type EE_Payment_Processor $payment_processor */
2091
-            $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2092
-            $payment_processor->process_registration_payments($transaction, $payment, $registrations);
2093
-        }
2094
-    }
2095
-
2096
-
2097
-    /**
2098
-     * _process_registration_status_change
2099
-     * This processes requested registration status changes for all the registrations
2100
-     * on a given transaction and (optionally) sends out notifications for the changes.
2101
-     *
2102
-     * @param EE_Transaction $transaction
2103
-     * @param array          $REG_IDs
2104
-     * @return bool
2105
-     * @throws EE_Error
2106
-     * @throws InvalidArgumentException
2107
-     * @throws ReflectionException
2108
-     * @throws InvalidDataTypeException
2109
-     * @throws InvalidInterfaceException
2110
-     */
2111
-    protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = [])
2112
-    {
2113
-        // first if there is no change in status then we get out.
2114
-        $reg_status = $this->request->getRequestParam('txn_reg_status_change[reg_status]', 'NAN');
2115
-        if ($reg_status === 'NAN') {
2116
-            // no error message, no change requested, just nothing to do man.
2117
-            return false;
2118
-        }
2119
-        /** @type EE_Transaction_Processor $transaction_processor */
2120
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
2121
-
2122
-        // made it here dude?  Oh WOW.  K, let's take care of changing the statuses
2123
-        return $transaction_processor->manually_update_registration_statuses(
2124
-            $transaction,
2125
-            $reg_status,
2126
-            [['REG_ID' => ['IN', $REG_IDs]]]
2127
-        );
2128
-    }
2129
-
2130
-
2131
-    /**
2132
-     * _build_payment_json_response
2133
-     *
2134
-     * @access public
2135
-     * @param EE_Payment  $payment
2136
-     * @param array       $REG_IDs
2137
-     * @param bool | null $delete_txn_reg_status_change
2138
-     * @return array
2139
-     * @throws EE_Error
2140
-     * @throws InvalidArgumentException
2141
-     * @throws InvalidDataTypeException
2142
-     * @throws InvalidInterfaceException
2143
-     * @throws ReflectionException
2144
-     */
2145
-    protected function _build_payment_json_response(
2146
-        EE_Payment $payment,
2147
-        $REG_IDs = [],
2148
-        $delete_txn_reg_status_change = null
2149
-    ) {
2150
-        // was the payment deleted ?
2151
-        if (is_bool($delete_txn_reg_status_change)) {
2152
-            return [
2153
-                'PAY_ID'                       => $payment->ID(),
2154
-                'amount'                       => $payment->amount(),
2155
-                'total_paid'                   => $payment->transaction()->paid(),
2156
-                'txn_status'                   => $payment->transaction()->status_ID(),
2157
-                'pay_status'                   => $payment->STS_ID(),
2158
-                'registrations'                => $this->_registration_payment_data_array($REG_IDs),
2159
-                'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
2160
-            ];
2161
-        }
2162
-
2163
-        $this->_get_payment_status_array();
2164
-        return [
2165
-            'amount'           => $payment->amount(),
2166
-            'total_paid'       => $payment->transaction()->paid(),
2167
-            'txn_status'       => $payment->transaction()->status_ID(),
2168
-            'pay_status'       => $payment->STS_ID(),
2169
-            'PAY_ID'           => $payment->ID(),
2170
-            'STS_ID'           => $payment->STS_ID(),
2171
-            'status'           => self::$_pay_status[ $payment->STS_ID() ],
2172
-            'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2173
-            'method'           => strtoupper($payment->source()),
2174
-            'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
2175
-            'gateway'          => $payment->payment_method()
2176
-                ? $payment->payment_method()->admin_name()
2177
-                : esc_html__('Unknown', 'event_espresso'),
2178
-            'gateway_response' => $payment->gateway_response(),
2179
-            'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
2180
-            'po_number'        => $payment->po_number(),
2181
-            'extra_accntng'    => $payment->extra_accntng(),
2182
-            'registrations'    => $this->_registration_payment_data_array($REG_IDs),
2183
-        ];
2184
-    }
2185
-
2186
-
2187
-    /**
2188
-     * delete_payment
2189
-     *    delete a payment or refund made towards a transaction
2190
-     *
2191
-     * @access public
2192
-     * @return void
2193
-     * @throws EE_Error
2194
-     * @throws InvalidArgumentException
2195
-     * @throws ReflectionException
2196
-     * @throws InvalidDataTypeException
2197
-     * @throws InvalidInterfaceException
2198
-     */
2199
-    public function delete_payment()
2200
-    {
2201
-        $json_response_data = ['return_data' => false];
2202
-        $PAY_ID = $this->request->getRequestParam('delete_txn_admin_payment[PAY_ID]', 0, 'int');
2203
-
2204
-        $can_delete         = EE_Registry::instance()->CAP->current_user_can(
2205
-            'ee_delete_payments',
2206
-            'delete_payment_from_registration_details'
2207
-        );
2208
-        if ($PAY_ID && $can_delete) {
2209
-            $delete_txn_reg_status_change = $this->request->getRequestParam(
2210
-                'delete_txn_reg_status_change',
2211
-                false,
2212
-                'bool'
2213
-            );
2214
-            $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
2215
-            if ($payment instanceof EE_Payment) {
2216
-                $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2217
-                /** @type EE_Transaction_Payments $transaction_payments */
2218
-                $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2219
-                if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
2220
-                    $json_response_data['return_data'] = $this->_build_payment_json_response(
2221
-                        $payment,
2222
-                        $REG_IDs,
2223
-                        $delete_txn_reg_status_change
2224
-                    );
2225
-                    if ($delete_txn_reg_status_change) {
2226
-                        // MAKE sure we also add the delete_txn_req_status_change to the
2227
-                        // request data because that's how messages will be looking for it.
2228
-                        $this->request->setRequestParam('txn_reg_status_change', $delete_txn_reg_status_change);
2229
-                        $this->_maybe_send_notifications();
2230
-                        $this->_process_registration_status_change($payment->transaction(), $REG_IDs);
2231
-                    }
2232
-                }
2233
-            } else {
2234
-                EE_Error::add_error(
2235
-                    esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
2236
-                    __FILE__,
2237
-                    __FUNCTION__,
2238
-                    __LINE__
2239
-                );
2240
-            }
2241
-        } elseif ($can_delete) {
2242
-            EE_Error::add_error(
2243
-                esc_html__(
2244
-                    'A valid Payment ID was not received, therefore payment form data could not be loaded.',
2245
-                    'event_espresso'
2246
-                ),
2247
-                __FILE__,
2248
-                __FUNCTION__,
2249
-                __LINE__
2250
-            );
2251
-        } else {
2252
-            EE_Error::add_error(
2253
-                esc_html__(
2254
-                    'You do not have access to delete a payment.',
2255
-                    'event_espresso'
2256
-                ),
2257
-                __FILE__,
2258
-                __FUNCTION__,
2259
-                __LINE__
2260
-            );
2261
-        }
2262
-        $notices              = EE_Error::get_notices(false, false, false);
2263
-        $this->_template_args = [
2264
-            'data'      => $json_response_data,
2265
-            'success'   => $notices['success'],
2266
-            'error'     => $notices['errors'],
2267
-            'attention' => $notices['attention'],
2268
-        ];
2269
-        $this->_return_json();
2270
-    }
2271
-
2272
-
2273
-    /**
2274
-     * _registration_payment_data_array
2275
-     * adds info for 'owing' and 'paid' for each registration to the json response
2276
-     *
2277
-     * @access protected
2278
-     * @param array $REG_IDs
2279
-     * @return array
2280
-     * @throws EE_Error
2281
-     * @throws InvalidArgumentException
2282
-     * @throws InvalidDataTypeException
2283
-     * @throws InvalidInterfaceException
2284
-     * @throws ReflectionException
2285
-     */
2286
-    protected function _registration_payment_data_array($REG_IDs)
2287
-    {
2288
-        $registration_payment_data = [];
2289
-        // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2290
-        if (! empty($REG_IDs)) {
2291
-            $registrations = EEM_Registration::instance()->get_all([['REG_ID' => ['IN', $REG_IDs]]]);
2292
-            foreach ($registrations as $registration) {
2293
-                if ($registration instanceof EE_Registration) {
2294
-                    $registration_payment_data[ $registration->ID() ] = [
2295
-                        'paid'  => $registration->pretty_paid(),
2296
-                        'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2297
-                    ];
2298
-                }
2299
-            }
2300
-        }
2301
-
2302
-        return $registration_payment_data;
2303
-    }
2304
-
2305
-
2306
-    /**
2307
-     * _maybe_send_notifications
2308
-     * determines whether or not the admin has indicated that notifications should be sent.
2309
-     * If so, will toggle a filter switch for delivering registration notices.
2310
-     * If passed an EE_Payment object, then it will trigger payment notifications instead.
2311
-     *
2312
-     * @access protected
2313
-     * @param EE_Payment | null $payment
2314
-     */
2315
-    protected function _maybe_send_notifications($payment = null)
2316
-    {
2317
-        switch ($payment instanceof EE_Payment) {
2318
-            // payment notifications
2319
-            case true:
2320
-                if ($this->request->getRequestParam('txn_payments[send_notifications]', false, 'bool')) {
2321
-                    $this->_process_payment_notification($payment);
2322
-                }
2323
-                break;
2324
-            // registration notifications
2325
-            case false:
2326
-                if ($this->request->getRequestParam('txn_reg_status_change[send_notifications]', false, 'bool')) {
2327
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
2328
-                }
2329
-                break;
2330
-        }
2331
-    }
2332
-
2333
-
2334
-    /**
2335
-     * _send_payment_reminder
2336
-     *    generates HTML for the View Transaction Details Admin page
2337
-     *
2338
-     * @access protected
2339
-     * @return void
2340
-     * @throws EE_Error
2341
-     * @throws InvalidArgumentException
2342
-     * @throws InvalidDataTypeException
2343
-     * @throws InvalidInterfaceException
2344
-     */
2345
-    protected function _send_payment_reminder()
2346
-    {
2347
-        $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
2348
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2349
-        $redirect_to = $this->request->getRequestParam('redirect_to');
2350
-        $query_args  = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID,] : [];
2351
-        do_action(
2352
-            'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2353
-            $transaction
2354
-        );
2355
-        $this->_redirect_after_action(
2356
-            false,
2357
-            esc_html__('payment reminder', 'event_espresso'),
2358
-            esc_html__('sent', 'event_espresso'),
2359
-            $query_args,
2360
-            true
2361
-        );
2362
-    }
2363
-
2364
-
2365
-    /**
2366
-     *  get_transactions
2367
-     *    get transactions for given parameters (used by list table)
2368
-     *
2369
-     * @param int     $per_page how many transactions displayed per page
2370
-     * @param boolean $count   return the count or objects
2371
-     * @param string  $view
2372
-     * @return EE_Transaction[]|int int = count || array of transaction objects
2373
-     * @throws EE_Error
2374
-     * @throws InvalidArgumentException
2375
-     * @throws InvalidDataTypeException
2376
-     * @throws InvalidInterfaceException
2377
-     */
2378
-    public function get_transactions($per_page, $count = false, $view = '')
2379
-    {
2380
-        $start_date = wp_strip_all_tags(
2381
-            $this->request->getRequestParam('txn-filter-start-date', date('m/d/Y', strtotime('-10 year')))
2382
-        );
2383
-        $end_date = wp_strip_all_tags(
2384
-            $this->request->getRequestParam('txn-filter-end-date', date('m/d/Y'))
2385
-        );
2386
-
2387
-        // make sure our timestamps start and end right at the boundaries for each day
2388
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2389
-        $end_date   = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2390
-
2391
-
2392
-        // convert to timestamps
2393
-        $start_date = strtotime($start_date);
2394
-        $end_date   = strtotime($end_date);
2395
-
2396
-        // makes sure start date is the lowest value and vice versa
2397
-        $start_date = min($start_date, $end_date);
2398
-        $end_date   = max($start_date, $end_date);
2399
-
2400
-        // convert to correct format for query
2401
-        $start_date = EEM_Transaction::instance()->convert_datetime_for_query(
2402
-            'TXN_timestamp',
2403
-            date('Y-m-d H:i:s', $start_date),
2404
-            'Y-m-d H:i:s'
2405
-        );
2406
-        $end_date   = EEM_Transaction::instance()->convert_datetime_for_query(
2407
-            'TXN_timestamp',
2408
-            date('Y-m-d H:i:s', $end_date),
2409
-            'Y-m-d H:i:s'
2410
-        );
2411
-
2412
-
2413
-        // set orderby
2414
-        $orderby = $this->request->getRequestParam('orderby');
2415
-
2416
-        switch ($orderby) {
2417
-            case 'TXN_ID':
2418
-                break;
2419
-            case 'ATT_fname':
2420
-                $orderby = 'Registration.Attendee.ATT_fname';
2421
-                break;
2422
-            case 'event_name':
2423
-                $orderby = 'Registration.Event.EVT_name';
2424
-                break;
2425
-            default: // 'TXN_timestamp'
2426
-                $orderby = 'TXN_timestamp';
2427
-        }
2428
-
2429
-        $sort         = $this->request->getRequestParam('order', 'DESC');
2430
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
2431
-
2432
-        $per_page = absint($per_page) ? $per_page : 10;
2433
-        $per_page = $this->request->getRequestParam('perpage', $per_page, 'int');
2434
-
2435
-        $offset = ($current_page - 1) * $per_page;
2436
-        $limit  = [$offset, $per_page];
2437
-
2438
-        $_where = [
2439
-            'TXN_timestamp'          => ['BETWEEN', [$start_date, $end_date]],
2440
-            'Registration.REG_count' => 1,
2441
-        ];
2442
-
2443
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
2444
-        if ($EVT_ID) {
2445
-            $_where['Registration.EVT_ID'] = $EVT_ID;
2446
-        }
2447
-
2448
-        $search_term = $this->request->getRequestParam('s');
2449
-        if ($search_term) {
2450
-            $search_term = '%' . $search_term . '%';
2451
-            $_where['OR']  = [
2452
-                'Registration.Event.EVT_name'         => ['LIKE', $search_term],
2453
-                'Registration.Event.EVT_desc'         => ['LIKE', $search_term],
2454
-                'Registration.Event.EVT_short_desc'   => ['LIKE', $search_term],
2455
-                'Registration.Attendee.ATT_full_name' => ['LIKE', $search_term],
2456
-                'Registration.Attendee.ATT_fname'     => ['LIKE', $search_term],
2457
-                'Registration.Attendee.ATT_lname'     => ['LIKE', $search_term],
2458
-                'Registration.Attendee.ATT_short_bio' => ['LIKE', $search_term],
2459
-                'Registration.Attendee.ATT_email'     => ['LIKE', $search_term],
2460
-                'Registration.Attendee.ATT_address'   => ['LIKE', $search_term],
2461
-                'Registration.Attendee.ATT_address2'  => ['LIKE', $search_term],
2462
-                'Registration.Attendee.ATT_city'      => ['LIKE', $search_term],
2463
-                'Registration.REG_final_price'        => ['LIKE', $search_term],
2464
-                'Registration.REG_code'               => ['LIKE', $search_term],
2465
-                'Registration.REG_count'              => ['LIKE', $search_term],
2466
-                'Registration.REG_group_size'         => ['LIKE', $search_term],
2467
-                'Registration.Ticket.TKT_name'        => ['LIKE', $search_term],
2468
-                'Registration.Ticket.TKT_description' => ['LIKE', $search_term],
2469
-                'Payment.PAY_source'                  => ['LIKE', $search_term],
2470
-                'Payment.Payment_Method.PMD_name'     => ['LIKE', $search_term],
2471
-                'TXN_session_data'                    => ['LIKE', $search_term],
2472
-                'Payment.PAY_txn_id_chq_nmbr'         => ['LIKE', $search_term],
2473
-            ];
2474
-        }
2475
-
2476
-        $status = $this->request->getRequestParam('status');
2477
-        // failed transactions
2478
-        $failed     = (! empty($status) && $status === 'failed' && ! $count) || ($count && $view === 'failed');
2479
-        $abandoned  = (! empty($status) && $status === 'abandoned' && ! $count) || ($count && $view === 'abandoned');
2480
-        $incomplete = (! empty($status) && $status === 'incomplete' && ! $count) || ($count && $view === 'incomplete');
2481
-
2482
-        if ($failed) {
2483
-            $_where['STS_ID'] = EEM_Transaction::failed_status_code;
2484
-        } elseif ($abandoned) {
2485
-            $_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
2486
-        } elseif ($incomplete) {
2487
-            $_where['STS_ID'] = EEM_Transaction::incomplete_status_code;
2488
-        } else {
2489
-            $_where['STS_ID']  = ['!=', EEM_Transaction::failed_status_code];
2490
-            $_where['STS_ID*'] = ['!=', EEM_Transaction::abandoned_status_code];
2491
-        }
2492
-
2493
-        $query_params = apply_filters(
2494
-            'FHEE__Transactions_Admin_Page___get_transactions_query_params',
2495
-            [
2496
-                $_where,
2497
-                'order_by'                 => [$orderby => $sort],
2498
-                'limit'                    => $limit,
2499
-                'default_where_conditions' => EEM_Base::default_where_conditions_this_only,
2500
-            ],
2501
-            $this->request->requestParams(),
2502
-            $view,
2503
-            $count
2504
-        );
2505
-
2506
-        return $count
2507
-            ? EEM_Transaction::instance()->count([$query_params[0]], 'TXN_ID', true)
2508
-            : EEM_Transaction::instance()->get_all($query_params);
2509
-    }
2510
-
2511
-
2512
-    /**
2513
-     * @throws EE_Error
2514
-     * @throws InvalidArgumentException
2515
-     * @throws InvalidDataTypeException
2516
-     * @throws InvalidInterfaceException
2517
-     * @throws ReflectionException
2518
-     * @throws RuntimeException
2519
-     * @since 4.9.79.p
2520
-     */
2521
-    public function recalculateLineItems()
2522
-    {
2523
-        $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
2524
-        /** @var EE_Transaction $transaction */
2525
-        $transaction     = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2526
-        $success         = $transaction->recalculateLineItems();
2527
-        $redirect_to = $this->request->getRequestParam('redirect_to');
2528
-        $query_args = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID,] : [];
2529
-        $this->_redirect_after_action(
2530
-            $success,
2531
-            esc_html__('Transaction taxes and totals', 'event_espresso'),
2532
-            esc_html__('recalculated', 'event_espresso'),
2533
-            $query_args,
2534
-            true
2535
-        );
2536
-    }
16
+	/**
17
+	 * @var EE_Transaction
18
+	 */
19
+	private $_transaction;
20
+
21
+	/**
22
+	 * @var EE_Session
23
+	 */
24
+	private $_session;
25
+
26
+	/**
27
+	 * @var array $_txn_status
28
+	 */
29
+	private static $_txn_status;
30
+
31
+	/**
32
+	 * @var array $_pay_status
33
+	 */
34
+	private static $_pay_status;
35
+
36
+	/**
37
+	 * @var array $_existing_reg_payment_REG_IDs
38
+	 */
39
+	protected $_existing_reg_payment_REG_IDs;
40
+
41
+
42
+	/**
43
+	 *    _init_page_props
44
+	 *
45
+	 * @return void
46
+	 */
47
+	protected function _init_page_props()
48
+	{
49
+		$this->page_slug        = TXN_PG_SLUG;
50
+		$this->page_label       = esc_html__('Transactions', 'event_espresso');
51
+		$this->_admin_base_url  = TXN_ADMIN_URL;
52
+		$this->_admin_base_path = TXN_ADMIN;
53
+	}
54
+
55
+
56
+	/**
57
+	 *    _ajax_hooks
58
+	 *
59
+	 * @return void
60
+	 */
61
+	protected function _ajax_hooks()
62
+	{
63
+		add_action('wp_ajax_espresso_apply_payment', [$this, 'apply_payments_or_refunds']);
64
+		add_action('wp_ajax_espresso_apply_refund', [$this, 'apply_payments_or_refunds']);
65
+		add_action('wp_ajax_espresso_delete_payment', [$this, 'delete_payment']);
66
+	}
67
+
68
+
69
+	/**
70
+	 *    _define_page_props
71
+	 *
72
+	 * @return void
73
+	 */
74
+	protected function _define_page_props()
75
+	{
76
+		$this->_admin_page_title = $this->page_label;
77
+		$this->_labels           = [
78
+			'buttons' => [
79
+				'add'    => esc_html__('Add New Transaction', 'event_espresso'),
80
+				'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
81
+				'delete' => esc_html__('Delete Transaction', 'event_espresso'),
82
+			],
83
+		];
84
+	}
85
+
86
+
87
+	/**
88
+	 *        grab url requests and route them
89
+	 *
90
+	 * @access private
91
+	 * @return void
92
+	 * @throws EE_Error
93
+	 * @throws InvalidArgumentException
94
+	 * @throws InvalidDataTypeException
95
+	 * @throws InvalidInterfaceException
96
+	 */
97
+	public function _set_page_routes()
98
+	{
99
+
100
+		$this->_set_transaction_status_array();
101
+		$TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
102
+
103
+		$this->_page_routes = [
104
+
105
+			'default' => [
106
+				'func'       => '_transactions_overview_list_table',
107
+				'capability' => 'ee_read_transactions',
108
+			],
109
+
110
+			'view_transaction' => [
111
+				'func'       => '_transaction_details',
112
+				'capability' => 'ee_read_transaction',
113
+				'obj_id'     => $TXN_ID,
114
+			],
115
+
116
+			'send_payment_reminder' => [
117
+				'func'       => '_send_payment_reminder',
118
+				'noheader'   => true,
119
+				'capability' => 'ee_send_message',
120
+			],
121
+
122
+			'espresso_apply_payment' => [
123
+				'func'       => 'apply_payments_or_refunds',
124
+				'noheader'   => true,
125
+				'capability' => 'ee_edit_payments',
126
+			],
127
+
128
+			'espresso_apply_refund' => [
129
+				'func'       => 'apply_payments_or_refunds',
130
+				'noheader'   => true,
131
+				'capability' => 'ee_edit_payments',
132
+			],
133
+
134
+			'espresso_delete_payment' => [
135
+				'func'       => 'delete_payment',
136
+				'noheader'   => true,
137
+				'capability' => 'ee_delete_payments',
138
+			],
139
+
140
+			'espresso_recalculate_line_items' => [
141
+				'func'       => 'recalculateLineItems',
142
+				'noheader'   => true,
143
+				'capability' => 'ee_edit_payments',
144
+			],
145
+
146
+		];
147
+	}
148
+
149
+
150
+	protected function _set_page_config()
151
+	{
152
+		$TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
153
+		$this->_page_config = [
154
+			'default'          => [
155
+				'nav'           => [
156
+					'label' => esc_html__('Overview', 'event_espresso'),
157
+					'order' => 10,
158
+				],
159
+				'list_table'    => 'EE_Admin_Transactions_List_Table',
160
+				'help_tabs'     => [
161
+					'transactions_overview_help_tab'                       => [
162
+						'title'    => esc_html__('Transactions Overview', 'event_espresso'),
163
+						'filename' => 'transactions_overview',
164
+					],
165
+					'transactions_overview_table_column_headings_help_tab' => [
166
+						'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
167
+						'filename' => 'transactions_overview_table_column_headings',
168
+					],
169
+					'transactions_overview_views_filters_help_tab'         => [
170
+						'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
171
+						'filename' => 'transactions_overview_views_filters_search',
172
+					],
173
+				],
174
+				/**
175
+				 * commented out because currently we are not displaying tips for transaction list table status but this
176
+				 * may change in a later iteration so want to keep the code for then.
177
+				 */
178
+				// 'qtips' => array( 'Transactions_List_Table_Tips' ),
179
+				'require_nonce' => false,
180
+			],
181
+			'view_transaction' => [
182
+				'nav'       => [
183
+					'label'      => esc_html__('View Transaction', 'event_espresso'),
184
+					'order'      => 5,
185
+					'url'        => $TXN_ID
186
+						? add_query_arg(['TXN_ID' => $TXN_ID], $this->_current_page_view_url)
187
+						: $this->_admin_base_url,
188
+					'persistent' => false,
189
+				],
190
+				'help_tabs' => [
191
+					'transactions_view_transaction_help_tab'                                              => [
192
+						'title'    => esc_html__('View Transaction', 'event_espresso'),
193
+						'filename' => 'transactions_view_transaction',
194
+					],
195
+					'transactions_view_transaction_transaction_details_table_help_tab'                    => [
196
+						'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
197
+						'filename' => 'transactions_view_transaction_transaction_details_table',
198
+					],
199
+					'transactions_view_transaction_attendees_registered_help_tab'                         => [
200
+						'title'    => esc_html__('Attendees Registered', 'event_espresso'),
201
+						'filename' => 'transactions_view_transaction_attendees_registered',
202
+					],
203
+					'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => [
204
+						'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
205
+						'filename' => 'transactions_view_transaction_primary_registrant_billing_information',
206
+					],
207
+				],
208
+				'qtips'     => ['Transaction_Details_Tips'],
209
+				'metaboxes' => ['_transaction_details_metaboxes'],
210
+
211
+				'require_nonce' => false,
212
+			],
213
+		];
214
+	}
215
+
216
+
217
+	/**
218
+	 * The below methods aren't used by this class currently
219
+	 */
220
+	protected function _add_screen_options()
221
+	{
222
+		// noop
223
+	}
224
+
225
+
226
+	protected function _add_feature_pointers()
227
+	{
228
+		// noop
229
+	}
230
+
231
+
232
+	public function admin_init()
233
+	{
234
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
235
+		$event_name = $this->request->getRequestParam('event_name');
236
+		$redirect_from = $this->request->getRequestParam('redirect_from', '', 'url');
237
+		// IF a registration was JUST added via the admin...
238
+		if ($EVT_ID && $event_name && $redirect_from) {
239
+			// then set a cookie so that we can block any attempts to use
240
+			// the back button as a way to enter another registration.
241
+			setcookie('ee_registration_added', $EVT_ID, time() + WEEK_IN_SECONDS, '/');
242
+			// and update the global
243
+			$_COOKIE['ee_registration_added'] = $EVT_ID;
244
+		}
245
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__(
246
+			'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247
+			'event_espresso'
248
+		);
249
+		EE_Registry::$i18n_js_strings['error_occurred']          = esc_html__(
250
+			'An error occurred! Please refresh the page and try again.',
251
+			'event_espresso'
252
+		);
253
+		EE_Registry::$i18n_js_strings['txn_status_array']        = self::$_txn_status;
254
+		EE_Registry::$i18n_js_strings['pay_status_array']        = self::$_pay_status;
255
+		EE_Registry::$i18n_js_strings['payments_total']          = esc_html__('Payments Total', 'event_espresso');
256
+		EE_Registry::$i18n_js_strings['transaction_overpaid']    = esc_html__(
257
+			'This transaction has been overpaid ! Payments Total',
258
+			'event_espresso'
259
+		);
260
+	}
261
+
262
+
263
+	public function admin_notices()
264
+	{
265
+		// noop
266
+	}
267
+
268
+
269
+	public function admin_footer_scripts()
270
+	{
271
+		// noop
272
+	}
273
+
274
+
275
+	/**
276
+	 * _set_transaction_status_array
277
+	 * sets list of transaction statuses
278
+	 *
279
+	 * @access private
280
+	 * @return void
281
+	 * @throws EE_Error
282
+	 * @throws InvalidArgumentException
283
+	 * @throws InvalidDataTypeException
284
+	 * @throws InvalidInterfaceException
285
+	 */
286
+	private function _set_transaction_status_array()
287
+	{
288
+		self::$_txn_status = EEM_Transaction::instance()->status_array(true);
289
+	}
290
+
291
+
292
+	/**
293
+	 * get_transaction_status_array
294
+	 * return the transaction status array for wp_list_table
295
+	 *
296
+	 * @access public
297
+	 * @return array
298
+	 */
299
+	public function get_transaction_status_array()
300
+	{
301
+		return self::$_txn_status;
302
+	}
303
+
304
+
305
+	/**
306
+	 *    get list of payment statuses
307
+	 *
308
+	 * @access private
309
+	 * @return void
310
+	 * @throws EE_Error
311
+	 * @throws InvalidArgumentException
312
+	 * @throws InvalidDataTypeException
313
+	 * @throws InvalidInterfaceException
314
+	 */
315
+	private function _get_payment_status_array()
316
+	{
317
+		self::$_pay_status                      = EEM_Payment::instance()->status_array(true);
318
+		$this->_template_args['payment_status'] = self::$_pay_status;
319
+	}
320
+
321
+
322
+	/**
323
+	 *    _add_screen_options_default
324
+	 *
325
+	 * @access protected
326
+	 * @return void
327
+	 * @throws InvalidArgumentException
328
+	 * @throws InvalidDataTypeException
329
+	 * @throws InvalidInterfaceException
330
+	 */
331
+	protected function _add_screen_options_default()
332
+	{
333
+		$this->_per_page_screen_option();
334
+	}
335
+
336
+
337
+	/**
338
+	 * load_scripts_styles
339
+	 *
340
+	 * @access public
341
+	 * @return void
342
+	 */
343
+	public function load_scripts_styles()
344
+	{
345
+		// enqueue style
346
+		wp_register_style(
347
+			'espresso_txn',
348
+			TXN_ASSETS_URL . 'espresso_transactions_admin.css',
349
+			[],
350
+			EVENT_ESPRESSO_VERSION
351
+		);
352
+		wp_enqueue_style('espresso_txn');
353
+		// scripts
354
+		wp_register_script(
355
+			'espresso_txn',
356
+			TXN_ASSETS_URL . 'espresso_transactions_admin.js',
357
+			[
358
+				'ee_admin_js',
359
+				'ee-datepicker',
360
+				'jquery-ui-datepicker',
361
+				'jquery-ui-draggable',
362
+				'ee-dialog',
363
+				'ee-accounting',
364
+				'ee-serialize-full-array',
365
+			],
366
+			EVENT_ESPRESSO_VERSION,
367
+			true
368
+		);
369
+		wp_enqueue_script('espresso_txn');
370
+	}
371
+
372
+
373
+	/**
374
+	 *    load_scripts_styles_view_transaction
375
+	 *
376
+	 * @access public
377
+	 * @return void
378
+	 */
379
+	public function load_scripts_styles_view_transaction()
380
+	{
381
+		// styles
382
+		wp_enqueue_style('espresso-ui-theme');
383
+	}
384
+
385
+
386
+	/**
387
+	 *    load_scripts_styles_default
388
+	 *
389
+	 * @access public
390
+	 * @return void
391
+	 */
392
+	public function load_scripts_styles_default()
393
+	{
394
+		// styles
395
+		wp_enqueue_style('espresso-ui-theme');
396
+	}
397
+
398
+
399
+	/**
400
+	 *    _set_list_table_views_default
401
+	 *
402
+	 * @access protected
403
+	 * @return void
404
+	 */
405
+	protected function _set_list_table_views_default()
406
+	{
407
+		$this->_views = [
408
+			'all'        => [
409
+				'slug'  => 'all',
410
+				'label' => esc_html__('View All Transactions', 'event_espresso'),
411
+				'count' => 0,
412
+			],
413
+			'abandoned'  => [
414
+				'slug'  => 'abandoned',
415
+				'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
416
+				'count' => 0,
417
+			],
418
+			'incomplete' => [
419
+				'slug'  => 'incomplete',
420
+				'label' => esc_html__('Incomplete Transactions', 'event_espresso'),
421
+				'count' => 0,
422
+			],
423
+		];
424
+		if (
425
+			/**
426
+			 * Filters whether a link to the "Failed Transactions" list table
427
+			 * appears on the Transactions Admin Page list table.
428
+			 * List display can be turned back on via the following:
429
+			 * add_filter(
430
+			 *     'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
431
+			 *     '__return_true'
432
+			 * );
433
+			 *
434
+			 * @param boolean                 $display_failed_txns_list
435
+			 * @param Transactions_Admin_Page $this
436
+			 * @since 4.9.70.p
437
+			 */
438
+			apply_filters(
439
+				'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
440
+				false,
441
+				$this
442
+			)
443
+		) {
444
+			$this->_views['failed'] = [
445
+				'slug'  => 'failed',
446
+				'label' => esc_html__('Failed Transactions', 'event_espresso'),
447
+				'count' => 0,
448
+			];
449
+		}
450
+	}
451
+
452
+
453
+	/**
454
+	 * _set_transaction_object
455
+	 * This sets the _transaction property for the transaction details screen
456
+	 *
457
+	 * @access private
458
+	 * @return void
459
+	 * @throws EE_Error
460
+	 * @throws InvalidArgumentException
461
+	 * @throws RuntimeException
462
+	 * @throws InvalidDataTypeException
463
+	 * @throws InvalidInterfaceException
464
+	 * @throws ReflectionException
465
+	 */
466
+	private function _set_transaction_object()
467
+	{
468
+		if ($this->_transaction instanceof EE_Transaction) {
469
+			return;
470
+		} //get out we've already set the object
471
+
472
+		$TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
473
+
474
+		// get transaction object
475
+		$this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
476
+		$this->_session     = $this->_transaction instanceof EE_Transaction
477
+			? $this->_transaction->session_data()
478
+			: null;
479
+		if ($this->_transaction instanceof EE_Transaction) {
480
+			$this->_transaction->verify_abandoned_transaction_status();
481
+		}
482
+
483
+		if (! $this->_transaction instanceof EE_Transaction) {
484
+			$error_msg = sprintf(
485
+				esc_html__(
486
+					'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
487
+					'event_espresso'
488
+				),
489
+				$TXN_ID
490
+			);
491
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
492
+		}
493
+	}
494
+
495
+
496
+	/**
497
+	 *    _transaction_legend_items
498
+	 *
499
+	 * @access protected
500
+	 * @return array
501
+	 * @throws EE_Error
502
+	 * @throws InvalidArgumentException
503
+	 * @throws ReflectionException
504
+	 * @throws InvalidDataTypeException
505
+	 * @throws InvalidInterfaceException
506
+	 */
507
+	protected function _transaction_legend_items()
508
+	{
509
+		EE_Registry::instance()->load_helper('MSG_Template');
510
+		$items = [];
511
+
512
+		if (
513
+			EE_Registry::instance()->CAP->current_user_can(
514
+				'ee_read_global_messages',
515
+				'view_filtered_messages'
516
+			)
517
+		) {
518
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
519
+			if (
520
+				is_array($related_for_icon)
521
+				&& isset($related_for_icon['css_class'], $related_for_icon['label'])
522
+			) {
523
+				$items['view_related_messages'] = [
524
+					'class' => $related_for_icon['css_class'],
525
+					'desc'  => $related_for_icon['label'],
526
+				];
527
+			}
528
+		}
529
+
530
+		$items = apply_filters(
531
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
532
+			array_merge(
533
+				$items,
534
+				[
535
+					'view_details'          => [
536
+						'class' => 'dashicons dashicons-cart',
537
+						'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
538
+					],
539
+					'view_invoice'          => [
540
+						'class' => 'dashicons dashicons-media-spreadsheet',
541
+						'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
542
+					],
543
+					'view_receipt'          => [
544
+						'class' => 'dashicons dashicons-media-default',
545
+						'desc'  => esc_html__('View Transaction Receipt', 'event_espresso'),
546
+					],
547
+					'view_registration'     => [
548
+						'class' => 'dashicons dashicons-clipboard',
549
+						'desc'  => esc_html__('View Registration Details', 'event_espresso'),
550
+					],
551
+					'payment_overview_link' => [
552
+						'class' => 'dashicons dashicons-money',
553
+						'desc'  => esc_html__('Make Payment on Frontend', 'event_espresso'),
554
+					],
555
+				]
556
+			)
557
+		);
558
+
559
+		if (
560
+			EEH_MSG_Template::is_mt_active('payment_reminder')
561
+			&& EE_Registry::instance()->CAP->current_user_can(
562
+				'ee_send_message',
563
+				'espresso_transactions_send_payment_reminder'
564
+			)
565
+		) {
566
+			$items['send_payment_reminder'] = [
567
+				'class' => 'dashicons dashicons-email-alt',
568
+				'desc'  => esc_html__('Send Payment Reminder', 'event_espresso'),
569
+			];
570
+		} else {
571
+			$items['blank*'] = [
572
+				'class' => '',
573
+				'desc'  => '',
574
+			];
575
+		}
576
+		$more_items = apply_filters(
577
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
578
+			[
579
+				'overpaid'   => [
580
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
581
+					'desc'  => EEH_Template::pretty_status(
582
+						EEM_Transaction::overpaid_status_code,
583
+						false,
584
+						'sentence'
585
+					),
586
+				],
587
+				'complete'   => [
588
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
589
+					'desc'  => EEH_Template::pretty_status(
590
+						EEM_Transaction::complete_status_code,
591
+						false,
592
+						'sentence'
593
+					),
594
+				],
595
+				'incomplete' => [
596
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
597
+					'desc'  => EEH_Template::pretty_status(
598
+						EEM_Transaction::incomplete_status_code,
599
+						false,
600
+						'sentence'
601
+					),
602
+				],
603
+				'abandoned'  => [
604
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
605
+					'desc'  => EEH_Template::pretty_status(
606
+						EEM_Transaction::abandoned_status_code,
607
+						false,
608
+						'sentence'
609
+					),
610
+				],
611
+				'failed'     => [
612
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
613
+					'desc'  => EEH_Template::pretty_status(
614
+						EEM_Transaction::failed_status_code,
615
+						false,
616
+						'sentence'
617
+					),
618
+				],
619
+			]
620
+		);
621
+
622
+		return array_merge($items, $more_items);
623
+	}
624
+
625
+
626
+	/**
627
+	 *    _transactions_overview_list_table
628
+	 *
629
+	 * @access protected
630
+	 * @return void
631
+	 * @throws DomainException
632
+	 * @throws EE_Error
633
+	 * @throws InvalidArgumentException
634
+	 * @throws InvalidDataTypeException
635
+	 * @throws InvalidInterfaceException
636
+	 * @throws ReflectionException
637
+	 */
638
+	protected function _transactions_overview_list_table()
639
+	{
640
+		$this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
641
+
642
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
643
+		$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
644
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event
645
+			? sprintf(
646
+				esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'),
647
+				'<h3>',
648
+				'<a href="'
649
+				. EE_Admin_Page::add_query_args_and_nonce(
650
+					['action' => 'edit', 'post' => $event->ID()],
651
+					EVENTS_ADMIN_URL
652
+				)
653
+				. '" title="'
654
+				. esc_attr__('Click to Edit event', 'event_espresso')
655
+				. '">' . $event->name() . '</a>',
656
+				'</h3>'
657
+			)
658
+			: '';
659
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_transaction_legend_items());
660
+		$this->display_admin_list_table_page_with_no_sidebar();
661
+	}
662
+
663
+
664
+	/**
665
+	 *    _transaction_details
666
+	 * generates HTML for the View Transaction Details Admin page
667
+	 *
668
+	 * @access protected
669
+	 * @return void
670
+	 * @throws DomainException
671
+	 * @throws EE_Error
672
+	 * @throws InvalidArgumentException
673
+	 * @throws InvalidDataTypeException
674
+	 * @throws InvalidInterfaceException
675
+	 * @throws RuntimeException
676
+	 * @throws ReflectionException
677
+	 */
678
+	protected function _transaction_details()
679
+	{
680
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
681
+
682
+		$this->_set_transaction_status_array();
683
+
684
+		$this->_template_args                      = [];
685
+		$this->_template_args['transactions_page'] = $this->_wp_page_slug;
686
+
687
+		$this->_set_transaction_object();
688
+
689
+		if (! $this->_transaction instanceof EE_Transaction) {
690
+			return;
691
+		}
692
+
693
+		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
694
+		$this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
695
+
696
+		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
697
+		$this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
698
+
699
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->status_ID() ];
700
+		$this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
701
+		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->status_ID();
702
+
703
+		$this->_template_args['grand_total'] = $this->_transaction->total();
704
+		$this->_template_args['total_paid']  = $this->_transaction->paid();
705
+
706
+		$amount_due                         = $this->_transaction->total() - $this->_transaction->paid();
707
+		$this->_template_args['amount_due'] = EEH_Template::format_currency(
708
+			$amount_due,
709
+			true
710
+		);
711
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
712
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign
713
+												  . $this->_template_args['amount_due'];
714
+		} else {
715
+			$this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign;
716
+		}
717
+		$this->_template_args['amount_due_class'] = '';
718
+
719
+		if ($this->_transaction->paid() === $this->_transaction->total()) {
720
+			// paid in full
721
+			$this->_template_args['amount_due'] = false;
722
+		} elseif ($this->_transaction->paid() > $this->_transaction->total()) {
723
+			// overpaid
724
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
725
+		} elseif ($this->_transaction->total() > (float) 0) {
726
+			if ($this->_transaction->paid() > (float) 0) {
727
+				// monies owing
728
+				$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
729
+			} elseif ($this->_transaction->paid() === (float) 0) {
730
+				// no payments made yet
731
+				$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
732
+			}
733
+		} elseif ($this->_transaction->total() === (float) 0) {
734
+			// free event
735
+			$this->_template_args['amount_due'] = false;
736
+		}
737
+
738
+		$payment_method = $this->_transaction->payment_method();
739
+
740
+		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
741
+			? $payment_method->admin_name()
742
+			: esc_html__('Unknown', 'event_espresso');
743
+
744
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
745
+		// link back to overview
746
+		$this->_template_args['txn_overview_url'] = $this->request->getServerParam(
747
+			'HTTP_REFERER',
748
+			TXN_ADMIN_URL
749
+		);
750
+
751
+
752
+		// next link
753
+		$next_txn                                 = $this->_transaction->next(
754
+			null,
755
+			[['STS_ID' => ['!=', EEM_Transaction::failed_status_code]]],
756
+			'TXN_ID'
757
+		);
758
+		$this->_template_args['next_transaction'] = $next_txn
759
+			? $this->_next_link(
760
+				EE_Admin_Page::add_query_args_and_nonce(
761
+					['action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']],
762
+					TXN_ADMIN_URL
763
+				),
764
+				'dashicons dashicons-arrow-right ee-icon-size-22'
765
+			)
766
+			: '';
767
+		// previous link
768
+		$previous_txn                                 = $this->_transaction->previous(
769
+			null,
770
+			[['STS_ID' => ['!=', EEM_Transaction::failed_status_code]]],
771
+			'TXN_ID'
772
+		);
773
+		$this->_template_args['previous_transaction'] = $previous_txn
774
+			? $this->_previous_link(
775
+				EE_Admin_Page::add_query_args_and_nonce(
776
+					['action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']],
777
+					TXN_ADMIN_URL
778
+				),
779
+				'dashicons dashicons-arrow-left ee-icon-size-22'
780
+			)
781
+			: '';
782
+
783
+		$EVT_ID        = $this->request->getRequestParam('EVT_ID', 0, 'int');
784
+		$event_name    = $this->request->getRequestParam('event_name');
785
+		$redirect_from = $this->request->getRequestParam('redirect_from', '', 'url');
786
+
787
+		// were we just redirected here after adding a new registration ???
788
+		if ($EVT_ID && $event_name && $redirect_from) {
789
+			if (
790
+				EE_Registry::instance()->CAP->current_user_can(
791
+					'ee_edit_registrations',
792
+					'espresso_registrations_new_registration',
793
+					$EVT_ID
794
+				)
795
+			) {
796
+				$this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
797
+				$this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
798
+					[
799
+						'page'     => 'espresso_registrations',
800
+						'action'   => 'new_registration',
801
+						'return'   => 'default',
802
+						'TXN_ID'   => $this->_transaction->ID(),
803
+						'event_id' => $EVT_ID,
804
+					],
805
+					REG_ADMIN_URL
806
+				);
807
+				$this->_admin_page_title .= '">';
808
+
809
+				$this->_admin_page_title .= sprintf(
810
+					esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
811
+					htmlentities(urldecode($event_name), ENT_QUOTES, 'UTF-8')
812
+				);
813
+				$this->_admin_page_title .= '</a>';
814
+			}
815
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
816
+		}
817
+		// grab messages at the last second
818
+		$this->_template_args['notices'] = EE_Error::get_notices();
819
+		// path to template
820
+		$template_path                             = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
821
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template(
822
+			$template_path,
823
+			$this->_template_args,
824
+			true
825
+		);
826
+
827
+		// the details template wrapper
828
+		$this->display_admin_page_with_sidebar();
829
+	}
830
+
831
+
832
+	/**
833
+	 *        _transaction_details_metaboxes
834
+	 *
835
+	 * @access protected
836
+	 * @return void
837
+	 * @throws EE_Error
838
+	 * @throws InvalidArgumentException
839
+	 * @throws InvalidDataTypeException
840
+	 * @throws InvalidInterfaceException
841
+	 * @throws RuntimeException
842
+	 * @throws ReflectionException
843
+	 */
844
+	protected function _transaction_details_metaboxes()
845
+	{
846
+
847
+		$this->_set_transaction_object();
848
+
849
+		if (! $this->_transaction instanceof EE_Transaction) {
850
+			return;
851
+		}
852
+		add_meta_box(
853
+			'edit-txn-details-mbox',
854
+			esc_html__('Transaction Details', 'event_espresso'),
855
+			[$this, 'txn_details_meta_box'],
856
+			$this->_wp_page_slug,
857
+			'normal',
858
+			'high'
859
+		);
860
+		add_meta_box(
861
+			'edit-txn-attendees-mbox',
862
+			esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
863
+			[$this, 'txn_attendees_meta_box'],
864
+			$this->_wp_page_slug,
865
+			'normal',
866
+			'high',
867
+			['TXN_ID' => $this->_transaction->ID()]
868
+		);
869
+		add_meta_box(
870
+			'edit-txn-registrant-mbox',
871
+			esc_html__('Primary Contact', 'event_espresso'),
872
+			[$this, 'txn_registrant_side_meta_box'],
873
+			$this->_wp_page_slug,
874
+			'side',
875
+			'high'
876
+		);
877
+		add_meta_box(
878
+			'edit-txn-billing-info-mbox',
879
+			esc_html__('Billing Information', 'event_espresso'),
880
+			[$this, 'txn_billing_info_side_meta_box'],
881
+			$this->_wp_page_slug,
882
+			'side',
883
+			'high'
884
+		);
885
+	}
886
+
887
+
888
+	/**
889
+	 * Callback for transaction actions metabox.
890
+	 *
891
+	 * @param EE_Transaction|null $transaction
892
+	 * @return string
893
+	 * @throws DomainException
894
+	 * @throws EE_Error
895
+	 * @throws InvalidArgumentException
896
+	 * @throws InvalidDataTypeException
897
+	 * @throws InvalidInterfaceException
898
+	 * @throws ReflectionException
899
+	 * @throws RuntimeException
900
+	 */
901
+	public function getActionButtons(EE_Transaction $transaction = null)
902
+	{
903
+		$content = '';
904
+		$actions = [];
905
+		if (! $transaction instanceof EE_Transaction) {
906
+			return $content;
907
+		}
908
+		/** @var EE_Registration $primary_registration */
909
+		$primary_registration = $transaction->primary_registration();
910
+		$attendee             = $primary_registration instanceof EE_Registration
911
+			? $primary_registration->attendee()
912
+			: null;
913
+
914
+		if (
915
+			$attendee instanceof EE_Attendee
916
+			&& EE_Registry::instance()->CAP->current_user_can(
917
+				'ee_send_message',
918
+				'espresso_transactions_send_payment_reminder'
919
+			)
920
+		) {
921
+			$actions['payment_reminder'] =
922
+				EEH_MSG_Template::is_mt_active('payment_reminder')
923
+				&& $this->_transaction->status_ID() !== EEM_Transaction::complete_status_code
924
+				&& $this->_transaction->status_ID() !== EEM_Transaction::overpaid_status_code
925
+					? EEH_Template::get_button_or_link(
926
+						EE_Admin_Page::add_query_args_and_nonce(
927
+							[
928
+							'action'      => 'send_payment_reminder',
929
+							'TXN_ID'      => $this->_transaction->ID(),
930
+							'redirect_to' => 'view_transaction',
931
+							],
932
+							TXN_ADMIN_URL
933
+						),
934
+						esc_html__(' Send Payment Reminder', 'event_espresso'),
935
+						'button secondary-button',
936
+						'dashicons dashicons-email-alt'
937
+					)
938
+					: '';
939
+		}
940
+
941
+		if (
942
+			EE_Registry::instance()->CAP->current_user_can(
943
+				'ee_edit_payments',
944
+				'espresso_transactions_recalculate_line_items'
945
+			)
946
+		) {
947
+			$actions['recalculate_line_items'] = EEH_Template::get_button_or_link(
948
+				EE_Admin_Page::add_query_args_and_nonce(
949
+					[
950
+						'action'      => 'espresso_recalculate_line_items',
951
+						'TXN_ID'      => $this->_transaction->ID(),
952
+						'redirect_to' => 'view_transaction',
953
+					],
954
+					TXN_ADMIN_URL
955
+				),
956
+				esc_html__(' Recalculate Taxes and Total', 'event_espresso'),
957
+				'button secondary-button',
958
+				'dashicons dashicons-update'
959
+			);
960
+		}
961
+
962
+		if (
963
+			$primary_registration instanceof EE_Registration
964
+			&& EEH_MSG_Template::is_mt_active('receipt')
965
+		) {
966
+			$actions['receipt'] = EEH_Template::get_button_or_link(
967
+				$primary_registration->receipt_url(),
968
+				esc_html__('View Receipt', 'event_espresso'),
969
+				'button secondary-button',
970
+				'dashicons dashicons-media-default'
971
+			);
972
+		}
973
+
974
+		if (
975
+			$primary_registration instanceof EE_Registration
976
+			&& EEH_MSG_Template::is_mt_active('invoice')
977
+		) {
978
+			$actions['invoice'] = EEH_Template::get_button_or_link(
979
+				$primary_registration->invoice_url(),
980
+				esc_html__('View Invoice', 'event_espresso'),
981
+				'button secondary-button',
982
+				'dashicons dashicons-media-spreadsheet'
983
+			);
984
+		}
985
+		$actions = array_filter(
986
+			apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction)
987
+		);
988
+		if ($actions) {
989
+			$content = '<ul>';
990
+			$content .= '<li>' . implode('</li><li>', $actions) . '</li>';
991
+			$content .= '</uL>';
992
+		}
993
+		return $content;
994
+	}
995
+
996
+
997
+	/**
998
+	 * txn_details_meta_box
999
+	 * generates HTML for the Transaction main meta box
1000
+	 *
1001
+	 * @return void
1002
+	 * @throws DomainException
1003
+	 * @throws EE_Error
1004
+	 * @throws InvalidArgumentException
1005
+	 * @throws InvalidDataTypeException
1006
+	 * @throws InvalidInterfaceException
1007
+	 * @throws RuntimeException
1008
+	 * @throws ReflectionException
1009
+	 */
1010
+	public function txn_details_meta_box()
1011
+	{
1012
+		$this->_set_transaction_object();
1013
+		$this->_template_args['TXN_ID']              = $this->_transaction->ID();
1014
+		$this->_template_args['attendee']            =
1015
+			$this->_transaction->primary_registration() instanceof EE_Registration
1016
+				? $this->_transaction->primary_registration()->attendee()
1017
+				: null;
1018
+		$this->_template_args['can_edit_payments']   = EE_Registry::instance()->CAP->current_user_can(
1019
+			'ee_edit_payments',
1020
+			'apply_payment_or_refund_from_registration_details'
1021
+		);
1022
+		$this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can(
1023
+			'ee_delete_payments',
1024
+			'delete_payment_from_registration_details'
1025
+		);
1026
+
1027
+		// get line table
1028
+		EEH_Autoloader::register_line_item_display_autoloaders();
1029
+		$Line_Item_Display                       = new EE_Line_Item_Display(
1030
+			'admin_table',
1031
+			'EE_Admin_Table_Line_Item_Display_Strategy'
1032
+		);
1033
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item(
1034
+			$this->_transaction->total_line_item()
1035
+		);
1036
+		$this->_template_args['REG_code']        =
1037
+			$this->_transaction->primary_registration() instanceof EE_Registration
1038
+				? $this->_transaction->primary_registration()->reg_code()
1039
+				: null;
1040
+		// process taxes
1041
+		$taxes                         = $this->_transaction->line_items([['LIN_type' => EEM_Line_Item::type_tax]]);
1042
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1043
+
1044
+		$this->_template_args['grand_total']     = EEH_Template::format_currency(
1045
+			$this->_transaction->total(),
1046
+			false,
1047
+			false
1048
+		);
1049
+		$this->_template_args['grand_raw_total'] = $this->_transaction->total();
1050
+		$this->_template_args['TXN_status']      = $this->_transaction->status_ID();
1051
+
1052
+		// process payment details
1053
+		$payments = $this->_transaction->payments();
1054
+		if (! empty($payments)) {
1055
+			$this->_template_args['payments']              = $payments;
1056
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1057
+		} else {
1058
+			$this->_template_args['payments']              = false;
1059
+			$this->_template_args['existing_reg_payments'] = [];
1060
+		}
1061
+
1062
+		$this->_template_args['edit_payment_url']   = add_query_arg(['action' => 'edit_payment'], TXN_ADMIN_URL);
1063
+		$this->_template_args['delete_payment_url'] = add_query_arg(
1064
+			['action' => 'espresso_delete_payment'],
1065
+			TXN_ADMIN_URL
1066
+		);
1067
+
1068
+		if (isset($txn_details['invoice_number'])) {
1069
+			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
1070
+			$this->_template_args['txn_details']['invoice_number']['label'] = esc_html__(
1071
+				'Invoice Number',
1072
+				'event_espresso'
1073
+			);
1074
+		}
1075
+
1076
+		$this->_template_args['txn_details']['registration_session']['value'] =
1077
+			$this->_transaction->primary_registration() instanceof EE_Registration
1078
+				? $this->_transaction->primary_registration()->session_ID()
1079
+				: null;
1080
+		$this->_template_args['txn_details']['registration_session']['label'] = esc_html__(
1081
+			'Registration Session',
1082
+			'event_espresso'
1083
+		);
1084
+
1085
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address'])
1086
+			? $this->_session['ip_address']
1087
+			: '';
1088
+		$this->_template_args['txn_details']['ip_address']['label'] = esc_html__(
1089
+			'Transaction placed from IP',
1090
+			'event_espresso'
1091
+		);
1092
+
1093
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent'])
1094
+			? $this->_session['user_agent']
1095
+			: '';
1096
+		$this->_template_args['txn_details']['user_agent']['label'] = esc_html__(
1097
+			'Registrant User Agent',
1098
+			'event_espresso'
1099
+		);
1100
+
1101
+		$reg_steps = '<ul>';
1102
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
1103
+			if ($reg_step_status === true) {
1104
+				$reg_steps .= '<li style="color:#70cc50">'
1105
+							  . sprintf(
1106
+								  esc_html__('%1$s : Completed', 'event_espresso'),
1107
+								  ucwords(str_replace('_', ' ', $reg_step))
1108
+							  )
1109
+							  . '</li>';
1110
+			} elseif ($reg_step_status !== false && is_numeric($reg_step_status)) {
1111
+				$reg_steps .= '<li style="color:#2EA2CC">'
1112
+							  . sprintf(
1113
+								  esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1114
+								  ucwords(str_replace('_', ' ', $reg_step)),
1115
+								  date(
1116
+									  get_option('date_format') . ' ' . get_option('time_format'),
1117
+									  $reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1118
+								  )
1119
+							  )
1120
+							  . '</li>';
1121
+			} else {
1122
+				$reg_steps .= '<li style="color:#E76700">'
1123
+							  . sprintf(
1124
+								  esc_html__('%1$s : Never Initiated', 'event_espresso'),
1125
+								  ucwords(str_replace('_', ' ', $reg_step))
1126
+							  )
1127
+							  . '</li>';
1128
+			}
1129
+		}
1130
+		$reg_steps                                                 .= '</ul>';
1131
+		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1132
+		$this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1133
+			'Registration Step Progress',
1134
+			'event_espresso'
1135
+		);
1136
+
1137
+
1138
+		$this->_get_registrations_to_apply_payment_to();
1139
+		$this->_get_payment_methods($payments);
1140
+		$this->_get_payment_status_array();
1141
+		$this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1142
+
1143
+		$this->_template_args['transaction_form_url']    = add_query_arg(
1144
+			[
1145
+				'action'  => 'edit_transaction',
1146
+				'process' => 'transaction',
1147
+			],
1148
+			TXN_ADMIN_URL
1149
+		);
1150
+		$this->_template_args['apply_payment_form_url']  = add_query_arg(
1151
+			[
1152
+				'page'   => 'espresso_transactions',
1153
+				'action' => 'espresso_apply_payment',
1154
+			],
1155
+			WP_AJAX_URL
1156
+		);
1157
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(
1158
+			[
1159
+				'page'   => 'espresso_transactions',
1160
+				'action' => 'espresso_delete_payment',
1161
+			],
1162
+			WP_AJAX_URL
1163
+		);
1164
+
1165
+		$this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction);
1166
+
1167
+		// 'espresso_delete_payment_nonce'
1168
+
1169
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1170
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1171
+	}
1172
+
1173
+
1174
+	/**
1175
+	 * _get_registration_payment_IDs
1176
+	 *    generates an array of Payment IDs and their corresponding Registration IDs
1177
+	 *
1178
+	 * @access protected
1179
+	 * @param EE_Payment[] $payments
1180
+	 * @return array
1181
+	 * @throws EE_Error
1182
+	 * @throws InvalidArgumentException
1183
+	 * @throws InvalidDataTypeException
1184
+	 * @throws InvalidInterfaceException
1185
+	 * @throws ReflectionException
1186
+	 */
1187
+	protected function _get_registration_payment_IDs($payments = [])
1188
+	{
1189
+		$existing_reg_payments = [];
1190
+		// get all reg payments for these payments
1191
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(
1192
+			[
1193
+				[
1194
+					'PAY_ID' => [
1195
+						'IN',
1196
+						array_keys($payments),
1197
+					],
1198
+				],
1199
+			]
1200
+		);
1201
+		if (! empty($reg_payments)) {
1202
+			foreach ($payments as $payment) {
1203
+				if (! $payment instanceof EE_Payment) {
1204
+					continue;
1205
+				} elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1206
+					$existing_reg_payments[ $payment->ID() ] = [];
1207
+				}
1208
+				foreach ($reg_payments as $reg_payment) {
1209
+					if (
1210
+						$reg_payment instanceof EE_Registration_Payment
1211
+						&& $reg_payment->payment_ID() === $payment->ID()
1212
+					) {
1213
+						$existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1214
+					}
1215
+				}
1216
+			}
1217
+		}
1218
+
1219
+		return $existing_reg_payments;
1220
+	}
1221
+
1222
+
1223
+	/**
1224
+	 * _get_registrations_to_apply_payment_to
1225
+	 *    generates HTML for displaying a series of checkboxes in the admin payment modal window
1226
+	 * which allows the admin to only apply the payment to the specific registrations
1227
+	 *
1228
+	 * @access protected
1229
+	 * @return void
1230
+	 * @throws EE_Error
1231
+	 * @throws InvalidArgumentException
1232
+	 * @throws InvalidDataTypeException
1233
+	 * @throws InvalidInterfaceException
1234
+	 * @throws ReflectionException
1235
+	 */
1236
+	protected function _get_registrations_to_apply_payment_to()
1237
+	{
1238
+		// we want any registration with an active status (ie: not deleted or cancelled)
1239
+		$query_params                      = [
1240
+			[
1241
+				'STS_ID' => [
1242
+					'IN',
1243
+					[
1244
+						EEM_Registration::status_id_approved,
1245
+						EEM_Registration::status_id_pending_payment,
1246
+						EEM_Registration::status_id_not_approved,
1247
+					],
1248
+				],
1249
+			],
1250
+		];
1251
+		$registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
1252
+			'',
1253
+			'txn-admin-apply-payment-to-registrations-dv',
1254
+			'',
1255
+			'clear: both; margin: 1.5em 0 0; display: none;'
1256
+		);
1257
+		$registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1258
+		$registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1259
+		$registrations_to_apply_payment_to .= EEH_HTML::thead(
1260
+			EEH_HTML::tr(
1261
+				EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1262
+				EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1263
+				EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1264
+				EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1265
+				EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1266
+				EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1267
+				EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1268
+			)
1269
+		);
1270
+		$registrations_to_apply_payment_to .= EEH_HTML::tbody();
1271
+		// get registrations for TXN
1272
+		$registrations         = $this->_transaction->registrations($query_params);
1273
+		$existing_reg_payments = $this->_template_args['existing_reg_payments'];
1274
+		foreach ($registrations as $registration) {
1275
+			if ($registration instanceof EE_Registration) {
1276
+				$attendee_name                     = $registration->attendee() instanceof EE_Attendee
1277
+					? $registration->attendee()->full_name()
1278
+					: esc_html__('Unknown Attendee', 'event_espresso');
1279
+				$owing                             = $registration->final_price() - $registration->paid();
1280
+				$taxable                           = $registration->ticket()->taxable()
1281
+					? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1282
+					: '';
1283
+				$checked                           = empty($existing_reg_payments)
1284
+													 || in_array($registration->ID(), $existing_reg_payments, true)
1285
+					? ' checked'
1286
+					: '';
1287
+				$disabled                          = $registration->final_price() > 0 ? '' : ' disabled';
1288
+				$registrations_to_apply_payment_to .= EEH_HTML::tr(
1289
+					EEH_HTML::td($registration->ID()) .
1290
+					EEH_HTML::td($attendee_name) .
1291
+					EEH_HTML::td(
1292
+						$registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1293
+					) .
1294
+					EEH_HTML::td($registration->event_name()) .
1295
+					EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1296
+					EEH_HTML::td(
1297
+						EEH_Template::format_currency($owing),
1298
+						'',
1299
+						'txn-admin-payment-owing-td jst-cntr'
1300
+					) .
1301
+					EEH_HTML::td(
1302
+						'<input type="checkbox" value="' . $registration->ID()
1303
+						. '" name="txn_admin_payment[registrations]"'
1304
+						. $checked . $disabled . '>',
1305
+						'',
1306
+						'jst-cntr'
1307
+					),
1308
+					'apply-payment-registration-row-' . $registration->ID()
1309
+				);
1310
+			}
1311
+		}
1312
+		$registrations_to_apply_payment_to                         .= EEH_HTML::tbodyx();
1313
+		$registrations_to_apply_payment_to                         .= EEH_HTML::tablex();
1314
+		$registrations_to_apply_payment_to                         .= EEH_HTML::divx();
1315
+		$registrations_to_apply_payment_to                         .= EEH_HTML::p(
1316
+			esc_html__(
1317
+				'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.',
1318
+				'event_espresso'
1319
+			),
1320
+			'',
1321
+			'clear description'
1322
+		);
1323
+		$registrations_to_apply_payment_to                         .= EEH_HTML::divx();
1324
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1325
+	}
1326
+
1327
+
1328
+	/**
1329
+	 * _get_reg_status_selection
1330
+	 *
1331
+	 * @return void
1332
+	 * @throws EE_Error
1333
+	 * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1334
+	 *         instead of events.
1335
+	 * @access protected
1336
+	 */
1337
+	protected function _get_reg_status_selection()
1338
+	{
1339
+		// first get all possible statuses
1340
+		$statuses = EEM_Registration::reg_status_array([], true);
1341
+		// let's add a "don't change" option.
1342
+		$status_array['NAN']                                 = esc_html__('Leave the Same', 'event_espresso');
1343
+		$status_array                                        = array_merge($status_array, $statuses);
1344
+		$this->_template_args['status_change_select']        = EEH_Form_Fields::select_input(
1345
+			'txn_reg_status_change[reg_status]',
1346
+			$status_array,
1347
+			'NAN',
1348
+			'id="txn-admin-payment-reg-status-inp"',
1349
+			'txn-reg-status-change-reg-status'
1350
+		);
1351
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input(
1352
+			'delete_txn_reg_status_change[reg_status]',
1353
+			$status_array,
1354
+			'NAN',
1355
+			'delete-txn-admin-payment-reg-status-inp',
1356
+			'delete-txn-reg-status-change-reg-status'
1357
+		);
1358
+	}
1359
+
1360
+
1361
+	/**
1362
+	 *    _get_payment_methods
1363
+	 * Gets all the payment methods available generally, or the ones that are already
1364
+	 * selected on these payments (in case their payment methods are no longer active).
1365
+	 * Has the side-effect of updating the template args' payment_methods item
1366
+	 *
1367
+	 * @access private
1368
+	 * @param EE_Payment[] to show on this page
1369
+	 * @return void
1370
+	 * @throws EE_Error
1371
+	 * @throws InvalidArgumentException
1372
+	 * @throws InvalidDataTypeException
1373
+	 * @throws InvalidInterfaceException
1374
+	 * @throws ReflectionException
1375
+	 */
1376
+	private function _get_payment_methods($payments = [])
1377
+	{
1378
+		$payment_methods_of_payments = [];
1379
+		foreach ($payments as $payment) {
1380
+			if ($payment instanceof EE_Payment) {
1381
+				$payment_methods_of_payments[] = $payment->ID();
1382
+			}
1383
+		}
1384
+		if ($payment_methods_of_payments) {
1385
+			$query_args = [
1386
+				[
1387
+					'OR*payment_method_for_payment' => [
1388
+						'PMD_ID'    => ['IN', $payment_methods_of_payments],
1389
+						'PMD_scope' => ['LIKE', '%' . EEM_Payment_Method::scope_admin . '%'],
1390
+					],
1391
+				],
1392
+			];
1393
+		} else {
1394
+			$query_args = [['PMD_scope' => ['LIKE', '%' . EEM_Payment_Method::scope_admin . '%']]];
1395
+		}
1396
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1397
+	}
1398
+
1399
+
1400
+	/**
1401
+	 * txn_attendees_meta_box
1402
+	 *    generates HTML for the Attendees Transaction main meta box
1403
+	 *
1404
+	 * @access public
1405
+	 * @param WP_Post $post
1406
+	 * @param array   $metabox
1407
+	 * @return void
1408
+	 * @throws DomainException
1409
+	 * @throws EE_Error
1410
+	 * @throws InvalidArgumentException
1411
+	 * @throws InvalidDataTypeException
1412
+	 * @throws InvalidInterfaceException
1413
+	 * @throws ReflectionException
1414
+	 */
1415
+	public function txn_attendees_meta_box($post, $metabox = ['args' => []])
1416
+	{
1417
+
1418
+		/** @noinspection NonSecureExtractUsageInspection */
1419
+		extract($metabox['args']);
1420
+		$this->_template_args['post']            = $post;
1421
+		$this->_template_args['event_attendees'] = [];
1422
+		// process items in cart
1423
+		$line_items = $this->_transaction->get_many_related(
1424
+			'Line_Item',
1425
+			[['LIN_type' => 'line-item']]
1426
+		);
1427
+		if (! empty($line_items)) {
1428
+			foreach ($line_items as $item) {
1429
+				if ($item instanceof EE_Line_Item) {
1430
+					switch ($item->OBJ_type()) {
1431
+						case 'Event':
1432
+							break;
1433
+						case 'Ticket':
1434
+							$ticket = $item->ticket();
1435
+							// right now we're only handling tickets here.
1436
+							// Cause its expected that only tickets will have attendees right?
1437
+							if (! $ticket instanceof EE_Ticket) {
1438
+								break;
1439
+							}
1440
+							try {
1441
+								$event_name = $ticket->get_event_name();
1442
+							} catch (Exception $e) {
1443
+								EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1444
+								$event_name = esc_html__('Unknown Event', 'event_espresso');
1445
+							}
1446
+							$event_name   .= ' - ' . $item->name();
1447
+							$ticket_price = EEH_Template::format_currency($item->unit_price());
1448
+							// now get all of the registrations for this transaction that use this ticket
1449
+							$registrations = $ticket->registrations(
1450
+								[['TXN_ID' => $this->_transaction->ID()]]
1451
+							);
1452
+							foreach ($registrations as $registration) {
1453
+								if (! $registration instanceof EE_Registration) {
1454
+									break;
1455
+								}
1456
+								$this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1457
+									= $registration->status_ID();
1458
+								$this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1459
+									= $registration->count();
1460
+								$this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1461
+									= $event_name;
1462
+								$this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1463
+									= $ticket_price;
1464
+								// attendee info
1465
+								$attendee = $registration->get_first_related('Attendee');
1466
+								if ($attendee instanceof EE_Attendee) {
1467
+									$this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1468
+										= $attendee->ID();
1469
+									$this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1470
+										= $attendee->full_name();
1471
+									$this->_template_args['event_attendees'][ $registration->ID() ]['email']
1472
+										= '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1473
+										  . esc_html__(
1474
+											  ' Event',
1475
+											  'event_espresso'
1476
+										  )
1477
+										  . '">' . $attendee->email() . '</a>';
1478
+									$this->_template_args['event_attendees'][ $registration->ID() ]['address']
1479
+										= EEH_Address::format($attendee, 'inline', false, false);
1480
+								} else {
1481
+									$this->_template_args['event_attendees'][ $registration->ID() ]['att_id']   = '';
1482
+									$this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1483
+									$this->_template_args['event_attendees'][ $registration->ID() ]['email']    = '';
1484
+									$this->_template_args['event_attendees'][ $registration->ID() ]['address']  = '';
1485
+								}
1486
+							}
1487
+							break;
1488
+					}
1489
+				}
1490
+			}
1491
+
1492
+			$this->_template_args['transaction_form_url'] = add_query_arg(
1493
+				[
1494
+					'action'  => 'edit_transaction',
1495
+					'process' => 'attendees',
1496
+				],
1497
+				TXN_ADMIN_URL
1498
+			);
1499
+			echo EEH_Template::display_template(
1500
+				TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1501
+				$this->_template_args,
1502
+				true
1503
+			);
1504
+		} else {
1505
+			printf(
1506
+				esc_html__(
1507
+					'%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1508
+					'event_espresso'
1509
+				),
1510
+				'<p class="important-notice">',
1511
+				'</p>'
1512
+			);
1513
+		}
1514
+	}
1515
+
1516
+
1517
+	/**
1518
+	 * txn_registrant_side_meta_box
1519
+	 * generates HTML for the Edit Transaction side meta box
1520
+	 *
1521
+	 * @access public
1522
+	 * @return void
1523
+	 * @throws DomainException
1524
+	 * @throws EE_Error
1525
+	 * @throws InvalidArgumentException
1526
+	 * @throws InvalidDataTypeException
1527
+	 * @throws InvalidInterfaceException
1528
+	 * @throws ReflectionException
1529
+	 */
1530
+	public function txn_registrant_side_meta_box()
1531
+	{
1532
+		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1533
+			? $this->_transaction->primary_registration()->get_first_related('Attendee')
1534
+			: null;
1535
+		if (! $primary_att instanceof EE_Attendee) {
1536
+			$this->_template_args['no_attendee_message'] = esc_html__(
1537
+				'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1538
+				'event_espresso'
1539
+			);
1540
+			$primary_att                           = EEM_Attendee::instance()->create_default_object();
1541
+		}
1542
+		$this->_template_args['ATT_ID']            = $primary_att->ID();
1543
+		$this->_template_args['prime_reg_fname']   = $primary_att->fname();
1544
+		$this->_template_args['prime_reg_lname']   = $primary_att->lname();
1545
+		$this->_template_args['prime_reg_email']   = $primary_att->email();
1546
+		$this->_template_args['prime_reg_phone']   = $primary_att->phone();
1547
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(
1548
+			[
1549
+				'action' => 'edit_attendee',
1550
+				'post'   => $primary_att->ID(),
1551
+			],
1552
+			REG_ADMIN_URL
1553
+		);
1554
+		// get formatted address for registrant
1555
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1556
+		echo EEH_Template::display_template(
1557
+			TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1558
+			$this->_template_args,
1559
+			true
1560
+		);
1561
+	}
1562
+
1563
+
1564
+	/**
1565
+	 * txn_billing_info_side_meta_box
1566
+	 *    generates HTML for the Edit Transaction side meta box
1567
+	 *
1568
+	 * @access public
1569
+	 * @return void
1570
+	 * @throws DomainException
1571
+	 * @throws EE_Error
1572
+	 * @throws ReflectionException
1573
+	 */
1574
+	public function txn_billing_info_side_meta_box()
1575
+	{
1576
+
1577
+		$this->_template_args['billing_form']     = $this->_transaction->billing_info();
1578
+		$this->_template_args['billing_form_url'] = add_query_arg(
1579
+			['action' => 'edit_transaction', 'process' => 'billing'],
1580
+			TXN_ADMIN_URL
1581
+		);
1582
+
1583
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1584
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1585
+	}
1586
+
1587
+
1588
+	/**
1589
+	 * apply_payments_or_refunds
1590
+	 *    registers a payment or refund made towards a transaction
1591
+	 *
1592
+	 * @access public
1593
+	 * @return void
1594
+	 * @throws EE_Error
1595
+	 * @throws InvalidArgumentException
1596
+	 * @throws ReflectionException
1597
+	 * @throws RuntimeException
1598
+	 * @throws InvalidDataTypeException
1599
+	 * @throws InvalidInterfaceException
1600
+	 */
1601
+	public function apply_payments_or_refunds()
1602
+	{
1603
+		$json_response_data = ['return_data' => false];
1604
+		$valid_data         = $this->_validate_payment_request_data();
1605
+		$has_access         = EE_Registry::instance()->CAP->current_user_can(
1606
+			'ee_edit_payments',
1607
+			'apply_payment_or_refund_from_registration_details'
1608
+		);
1609
+		if (! empty($valid_data) && $has_access) {
1610
+			$PAY_ID = $valid_data['PAY_ID'];
1611
+			// save  the new payment
1612
+			$payment = $this->_create_payment_from_request_data($valid_data);
1613
+			// get the TXN for this payment
1614
+			$transaction = $payment->transaction();
1615
+			// verify transaction
1616
+			if ($transaction instanceof EE_Transaction) {
1617
+				// calculate_total_payments_and_update_status
1618
+				$this->_process_transaction_payments($transaction);
1619
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1620
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1621
+				// apply payment to registrations (if applicable)
1622
+				if (! empty($REG_IDs)) {
1623
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1624
+					$this->_maybe_send_notifications();
1625
+					// now process status changes for the same registrations
1626
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1627
+				}
1628
+				$this->_maybe_send_notifications($payment);
1629
+				// prepare to render page
1630
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1631
+				do_action(
1632
+					'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording',
1633
+					$transaction,
1634
+					$payment
1635
+				);
1636
+			} else {
1637
+				EE_Error::add_error(
1638
+					esc_html__(
1639
+						'A valid Transaction for this payment could not be retrieved.',
1640
+						'event_espresso'
1641
+					),
1642
+					__FILE__,
1643
+					__FUNCTION__,
1644
+					__LINE__
1645
+				);
1646
+			}
1647
+		} elseif ($has_access) {
1648
+			EE_Error::add_error(
1649
+				esc_html__(
1650
+					'The payment form data could not be processed. Please try again.',
1651
+					'event_espresso'
1652
+				),
1653
+				__FILE__,
1654
+				__FUNCTION__,
1655
+				__LINE__
1656
+			);
1657
+		} else {
1658
+			EE_Error::add_error(
1659
+				esc_html__(
1660
+					'You do not have access to apply payments or refunds to a registration.',
1661
+					'event_espresso'
1662
+				),
1663
+				__FILE__,
1664
+				__FUNCTION__,
1665
+				__LINE__
1666
+			);
1667
+		}
1668
+		$notices              = EE_Error::get_notices(
1669
+			false,
1670
+			false,
1671
+			false
1672
+		);
1673
+		$this->_template_args = [
1674
+			'data'    => $json_response_data,
1675
+			'error'   => $notices['errors'],
1676
+			'success' => $notices['success'],
1677
+		];
1678
+		$this->_return_json();
1679
+	}
1680
+
1681
+
1682
+	/**
1683
+	 * _validate_payment_request_data
1684
+	 *
1685
+	 * @return array
1686
+	 * @throws EE_Error
1687
+	 * @throws InvalidArgumentException
1688
+	 * @throws InvalidDataTypeException
1689
+	 * @throws InvalidInterfaceException
1690
+	 */
1691
+	protected function _validate_payment_request_data()
1692
+	{
1693
+		if (! $this->request->requestParamIsSet('txn_admin_payment')) {
1694
+			return [];
1695
+		}
1696
+		$payment_form = $this->_generate_payment_form_section();
1697
+		try {
1698
+			if ($payment_form->was_submitted()) {
1699
+				$payment_form->receive_form_submission();
1700
+				if (! $payment_form->is_valid()) {
1701
+					$submission_error_messages = [];
1702
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1703
+						if ($validation_error instanceof EE_Validation_Error) {
1704
+							$form_input = $validation_error->get_form_section();
1705
+							$submission_error_messages[] = sprintf(
1706
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1707
+								$form_input instanceof EE_Form_Input_Base ? $form_input->html_label_text() : '',
1708
+								$validation_error->getMessage()
1709
+							);
1710
+						}
1711
+					}
1712
+					EE_Error::add_error(
1713
+						implode('<br />', $submission_error_messages),
1714
+						__FILE__,
1715
+						__FUNCTION__,
1716
+						__LINE__
1717
+					);
1718
+					return [];
1719
+				}
1720
+			}
1721
+		} catch (EE_Error $e) {
1722
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1723
+			return [];
1724
+		}
1725
+
1726
+		return $payment_form->valid_data();
1727
+	}
1728
+
1729
+
1730
+	/**
1731
+	 * _generate_payment_form_section
1732
+	 *
1733
+	 * @return EE_Form_Section_Proper
1734
+	 * @throws EE_Error
1735
+	 */
1736
+	protected function _generate_payment_form_section()
1737
+	{
1738
+		return new EE_Form_Section_Proper(
1739
+			[
1740
+				'name'        => 'txn_admin_payment',
1741
+				'subsections' => [
1742
+					'PAY_ID'          => new EE_Text_Input(
1743
+						[
1744
+							'default'               => 0,
1745
+							'required'              => false,
1746
+							'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1747
+							'validation_strategies' => [new EE_Int_Normalization()],
1748
+						]
1749
+					),
1750
+					'TXN_ID'          => new EE_Text_Input(
1751
+						[
1752
+							'default'               => 0,
1753
+							'required'              => true,
1754
+							'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1755
+							'validation_strategies' => [new EE_Int_Normalization()],
1756
+						]
1757
+					),
1758
+					'type'            => new EE_Text_Input(
1759
+						[
1760
+							'default'               => 1,
1761
+							'required'              => true,
1762
+							'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1763
+							'validation_strategies' => [new EE_Int_Normalization()],
1764
+						]
1765
+					),
1766
+					'amount'          => new EE_Text_Input(
1767
+						[
1768
+							'default'               => 0,
1769
+							'required'              => true,
1770
+							'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1771
+							'validation_strategies' => [new EE_Float_Normalization()],
1772
+						]
1773
+					),
1774
+					'status'          => new EE_Text_Input(
1775
+						[
1776
+							'default'         => EEM_Payment::status_id_approved,
1777
+							'required'        => true,
1778
+							'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1779
+						]
1780
+					),
1781
+					'PMD_ID'          => new EE_Text_Input(
1782
+						[
1783
+							'default'               => 2,
1784
+							'required'              => true,
1785
+							'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1786
+							'validation_strategies' => [new EE_Int_Normalization()],
1787
+						]
1788
+					),
1789
+					'date'            => new EE_Text_Input(
1790
+						[
1791
+							'default'         => time(),
1792
+							'required'        => true,
1793
+							'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1794
+						]
1795
+					),
1796
+					'txn_id_chq_nmbr' => new EE_Text_Input(
1797
+						[
1798
+							'default'               => '',
1799
+							'required'              => false,
1800
+							'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1801
+							'validation_strategies' => [
1802
+								new EE_Max_Length_Validation_Strategy(
1803
+									esc_html__('Input too long', 'event_espresso'),
1804
+									100
1805
+								),
1806
+							],
1807
+						]
1808
+					),
1809
+					'po_number'       => new EE_Text_Input(
1810
+						[
1811
+							'default'               => '',
1812
+							'required'              => false,
1813
+							'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1814
+							'validation_strategies' => [
1815
+								new EE_Max_Length_Validation_Strategy(
1816
+									esc_html__('Input too long', 'event_espresso'),
1817
+									100
1818
+								),
1819
+							],
1820
+						]
1821
+					),
1822
+					'accounting'      => new EE_Text_Input(
1823
+						[
1824
+							'default'               => '',
1825
+							'required'              => false,
1826
+							'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1827
+							'validation_strategies' => [
1828
+								new EE_Max_Length_Validation_Strategy(
1829
+									esc_html__('Input too long', 'event_espresso'),
1830
+									100
1831
+								),
1832
+							],
1833
+						]
1834
+					),
1835
+				],
1836
+			]
1837
+		);
1838
+	}
1839
+
1840
+
1841
+	/**
1842
+	 * _create_payment_from_request_data
1843
+	 *
1844
+	 * @param array $valid_data
1845
+	 * @return EE_Payment
1846
+	 * @throws EE_Error
1847
+	 * @throws InvalidArgumentException
1848
+	 * @throws InvalidDataTypeException
1849
+	 * @throws InvalidInterfaceException
1850
+	 * @throws ReflectionException
1851
+	 */
1852
+	protected function _create_payment_from_request_data($valid_data)
1853
+	{
1854
+		$PAY_ID = $valid_data['PAY_ID'];
1855
+		// get payment amount
1856
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1857
+		// payments have a type value of 1 and refunds have a type value of -1
1858
+		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1859
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1860
+		// for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1861
+		$date    = $valid_data['date']
1862
+			? preg_replace('/\s+/', ' ', $valid_data['date'])
1863
+			: date('Y-m-d g:i a', current_time('timestamp'));
1864
+		$payment = EE_Payment::new_instance(
1865
+			[
1866
+				'TXN_ID'              => $valid_data['TXN_ID'],
1867
+				'STS_ID'              => $valid_data['status'],
1868
+				'PAY_timestamp'       => $date,
1869
+				'PAY_source'          => EEM_Payment_Method::scope_admin,
1870
+				'PMD_ID'              => $valid_data['PMD_ID'],
1871
+				'PAY_amount'          => $amount,
1872
+				'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1873
+				'PAY_po_number'       => $valid_data['po_number'],
1874
+				'PAY_extra_accntng'   => $valid_data['accounting'],
1875
+				'PAY_details'         => $valid_data,
1876
+				'PAY_ID'              => $PAY_ID,
1877
+			],
1878
+			'',
1879
+			['Y-m-d', 'g:i a']
1880
+		);
1881
+
1882
+		if (! $payment->save()) {
1883
+			EE_Error::add_error(
1884
+				sprintf(
1885
+					esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1886
+					$payment->ID()
1887
+				),
1888
+				__FILE__,
1889
+				__FUNCTION__,
1890
+				__LINE__
1891
+			);
1892
+		}
1893
+
1894
+		return $payment;
1895
+	}
1896
+
1897
+
1898
+	/**
1899
+	 * _process_transaction_payments
1900
+	 *
1901
+	 * @param EE_Transaction $transaction
1902
+	 * @return void
1903
+	 * @throws EE_Error
1904
+	 * @throws InvalidArgumentException
1905
+	 * @throws ReflectionException
1906
+	 * @throws InvalidDataTypeException
1907
+	 * @throws InvalidInterfaceException
1908
+	 */
1909
+	protected function _process_transaction_payments(EE_Transaction $transaction)
1910
+	{
1911
+		/** @type EE_Transaction_Payments $transaction_payments */
1912
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1913
+		// update the transaction with this payment
1914
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1915
+			EE_Error::add_success(
1916
+				esc_html__(
1917
+					'The payment has been processed successfully.',
1918
+					'event_espresso'
1919
+				),
1920
+				__FILE__,
1921
+				__FUNCTION__,
1922
+				__LINE__
1923
+			);
1924
+		} else {
1925
+			EE_Error::add_error(
1926
+				esc_html__(
1927
+					'The payment was processed successfully but the amount paid for the transaction was not updated.',
1928
+					'event_espresso'
1929
+				),
1930
+				__FILE__,
1931
+				__FUNCTION__,
1932
+				__LINE__
1933
+			);
1934
+		}
1935
+	}
1936
+
1937
+
1938
+	/**
1939
+	 * _get_REG_IDs_to_apply_payment_to
1940
+	 * returns a list of registration IDs that the payment will apply to
1941
+	 *
1942
+	 * @param EE_Payment $payment
1943
+	 * @return array
1944
+	 * @throws EE_Error
1945
+	 * @throws InvalidArgumentException
1946
+	 * @throws InvalidDataTypeException
1947
+	 * @throws InvalidInterfaceException
1948
+	 * @throws ReflectionException
1949
+	 */
1950
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1951
+	{
1952
+		// grab array of IDs for specific registrations to apply changes to
1953
+		$REG_IDs = $this->request->getRequestParam('txn_admin_payment[registrations]', [], 'int', true);
1954
+		// nothing specified ? then get all reg IDs
1955
+		if (empty($REG_IDs)) {
1956
+			$registrations = $payment->transaction()->registrations();
1957
+			$REG_IDs       = ! empty($registrations)
1958
+				? array_keys($registrations)
1959
+				: $this->_get_existing_reg_payment_REG_IDs($payment);
1960
+		}
1961
+
1962
+		// ensure that REG_IDs are integers and NOT strings
1963
+		return array_map('intval', $REG_IDs);
1964
+	}
1965
+
1966
+
1967
+	/**
1968
+	 * @return array
1969
+	 */
1970
+	public function existing_reg_payment_REG_IDs()
1971
+	{
1972
+		return $this->_existing_reg_payment_REG_IDs;
1973
+	}
1974
+
1975
+
1976
+	/**
1977
+	 * @param array $existing_reg_payment_REG_IDs
1978
+	 */
1979
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1980
+	{
1981
+		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1982
+	}
1983
+
1984
+
1985
+	/**
1986
+	 * _get_existing_reg_payment_REG_IDs
1987
+	 * returns a list of registration IDs that the payment is currently related to
1988
+	 * as recorded in the database
1989
+	 *
1990
+	 * @param EE_Payment $payment
1991
+	 * @return array
1992
+	 * @throws EE_Error
1993
+	 * @throws InvalidArgumentException
1994
+	 * @throws InvalidDataTypeException
1995
+	 * @throws InvalidInterfaceException
1996
+	 * @throws ReflectionException
1997
+	 */
1998
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
1999
+	{
2000
+		if ($this->existing_reg_payment_REG_IDs() === null) {
2001
+			// let's get any existing reg payment records for this payment
2002
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
2003
+			// but we only want the REG IDs, so grab the array keys
2004
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs)
2005
+				? array_keys($existing_reg_payment_REG_IDs)
2006
+				: [];
2007
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
2008
+		}
2009
+
2010
+		return $this->existing_reg_payment_REG_IDs();
2011
+	}
2012
+
2013
+
2014
+	/**
2015
+	 * _remove_existing_registration_payments
2016
+	 * this calculates the difference between existing relations
2017
+	 * to the supplied payment and the new list registration IDs,
2018
+	 * removes any related registrations that no longer apply,
2019
+	 * and then updates the registration paid fields
2020
+	 *
2021
+	 * @param EE_Payment $payment
2022
+	 * @param int        $PAY_ID
2023
+	 * @return bool;
2024
+	 * @throws EE_Error
2025
+	 * @throws InvalidArgumentException
2026
+	 * @throws ReflectionException
2027
+	 * @throws InvalidDataTypeException
2028
+	 * @throws InvalidInterfaceException
2029
+	 */
2030
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
2031
+	{
2032
+		// newly created payments will have nothing recorded for $PAY_ID
2033
+		if (absint($PAY_ID) === 0) {
2034
+			return false;
2035
+		}
2036
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2037
+		if (empty($existing_reg_payment_REG_IDs)) {
2038
+			return false;
2039
+		}
2040
+		/** @type EE_Transaction_Payments $transaction_payments */
2041
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2042
+
2043
+		return $transaction_payments->delete_registration_payments_and_update_registrations(
2044
+			$payment,
2045
+			[
2046
+				[
2047
+					'PAY_ID' => $payment->ID(),
2048
+					'REG_ID' => ['IN', $existing_reg_payment_REG_IDs],
2049
+				],
2050
+			]
2051
+		);
2052
+	}
2053
+
2054
+
2055
+	/**
2056
+	 * _update_registration_payments
2057
+	 * this applies the payments to the selected registrations
2058
+	 * but only if they have not already been paid for
2059
+	 *
2060
+	 * @param EE_Transaction $transaction
2061
+	 * @param EE_Payment     $payment
2062
+	 * @param array          $REG_IDs
2063
+	 * @return void
2064
+	 * @throws EE_Error
2065
+	 * @throws InvalidArgumentException
2066
+	 * @throws ReflectionException
2067
+	 * @throws RuntimeException
2068
+	 * @throws InvalidDataTypeException
2069
+	 * @throws InvalidInterfaceException
2070
+	 */
2071
+	protected function _update_registration_payments(
2072
+		EE_Transaction $transaction,
2073
+		EE_Payment $payment,
2074
+		$REG_IDs = []
2075
+	) {
2076
+		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
2077
+		// so let's do that using our set of REG_IDs from the form
2078
+		$registration_query_where_params = [
2079
+			'REG_ID' => ['IN', $REG_IDs],
2080
+		];
2081
+		// but add in some conditions regarding payment,
2082
+		// so that we don't apply payments to registrations that are free or have already been paid for
2083
+		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2084
+		if (! $payment->is_a_refund()) {
2085
+			$registration_query_where_params['REG_final_price']  = ['!=', 0];
2086
+			$registration_query_where_params['REG_final_price*'] = ['!=', 'REG_paid', true];
2087
+		}
2088
+		$registrations = $transaction->registrations([$registration_query_where_params]);
2089
+		if (! empty($registrations)) {
2090
+			/** @type EE_Payment_Processor $payment_processor */
2091
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2092
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
2093
+		}
2094
+	}
2095
+
2096
+
2097
+	/**
2098
+	 * _process_registration_status_change
2099
+	 * This processes requested registration status changes for all the registrations
2100
+	 * on a given transaction and (optionally) sends out notifications for the changes.
2101
+	 *
2102
+	 * @param EE_Transaction $transaction
2103
+	 * @param array          $REG_IDs
2104
+	 * @return bool
2105
+	 * @throws EE_Error
2106
+	 * @throws InvalidArgumentException
2107
+	 * @throws ReflectionException
2108
+	 * @throws InvalidDataTypeException
2109
+	 * @throws InvalidInterfaceException
2110
+	 */
2111
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = [])
2112
+	{
2113
+		// first if there is no change in status then we get out.
2114
+		$reg_status = $this->request->getRequestParam('txn_reg_status_change[reg_status]', 'NAN');
2115
+		if ($reg_status === 'NAN') {
2116
+			// no error message, no change requested, just nothing to do man.
2117
+			return false;
2118
+		}
2119
+		/** @type EE_Transaction_Processor $transaction_processor */
2120
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
2121
+
2122
+		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
2123
+		return $transaction_processor->manually_update_registration_statuses(
2124
+			$transaction,
2125
+			$reg_status,
2126
+			[['REG_ID' => ['IN', $REG_IDs]]]
2127
+		);
2128
+	}
2129
+
2130
+
2131
+	/**
2132
+	 * _build_payment_json_response
2133
+	 *
2134
+	 * @access public
2135
+	 * @param EE_Payment  $payment
2136
+	 * @param array       $REG_IDs
2137
+	 * @param bool | null $delete_txn_reg_status_change
2138
+	 * @return array
2139
+	 * @throws EE_Error
2140
+	 * @throws InvalidArgumentException
2141
+	 * @throws InvalidDataTypeException
2142
+	 * @throws InvalidInterfaceException
2143
+	 * @throws ReflectionException
2144
+	 */
2145
+	protected function _build_payment_json_response(
2146
+		EE_Payment $payment,
2147
+		$REG_IDs = [],
2148
+		$delete_txn_reg_status_change = null
2149
+	) {
2150
+		// was the payment deleted ?
2151
+		if (is_bool($delete_txn_reg_status_change)) {
2152
+			return [
2153
+				'PAY_ID'                       => $payment->ID(),
2154
+				'amount'                       => $payment->amount(),
2155
+				'total_paid'                   => $payment->transaction()->paid(),
2156
+				'txn_status'                   => $payment->transaction()->status_ID(),
2157
+				'pay_status'                   => $payment->STS_ID(),
2158
+				'registrations'                => $this->_registration_payment_data_array($REG_IDs),
2159
+				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
2160
+			];
2161
+		}
2162
+
2163
+		$this->_get_payment_status_array();
2164
+		return [
2165
+			'amount'           => $payment->amount(),
2166
+			'total_paid'       => $payment->transaction()->paid(),
2167
+			'txn_status'       => $payment->transaction()->status_ID(),
2168
+			'pay_status'       => $payment->STS_ID(),
2169
+			'PAY_ID'           => $payment->ID(),
2170
+			'STS_ID'           => $payment->STS_ID(),
2171
+			'status'           => self::$_pay_status[ $payment->STS_ID() ],
2172
+			'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2173
+			'method'           => strtoupper($payment->source()),
2174
+			'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
2175
+			'gateway'          => $payment->payment_method()
2176
+				? $payment->payment_method()->admin_name()
2177
+				: esc_html__('Unknown', 'event_espresso'),
2178
+			'gateway_response' => $payment->gateway_response(),
2179
+			'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
2180
+			'po_number'        => $payment->po_number(),
2181
+			'extra_accntng'    => $payment->extra_accntng(),
2182
+			'registrations'    => $this->_registration_payment_data_array($REG_IDs),
2183
+		];
2184
+	}
2185
+
2186
+
2187
+	/**
2188
+	 * delete_payment
2189
+	 *    delete a payment or refund made towards a transaction
2190
+	 *
2191
+	 * @access public
2192
+	 * @return void
2193
+	 * @throws EE_Error
2194
+	 * @throws InvalidArgumentException
2195
+	 * @throws ReflectionException
2196
+	 * @throws InvalidDataTypeException
2197
+	 * @throws InvalidInterfaceException
2198
+	 */
2199
+	public function delete_payment()
2200
+	{
2201
+		$json_response_data = ['return_data' => false];
2202
+		$PAY_ID = $this->request->getRequestParam('delete_txn_admin_payment[PAY_ID]', 0, 'int');
2203
+
2204
+		$can_delete         = EE_Registry::instance()->CAP->current_user_can(
2205
+			'ee_delete_payments',
2206
+			'delete_payment_from_registration_details'
2207
+		);
2208
+		if ($PAY_ID && $can_delete) {
2209
+			$delete_txn_reg_status_change = $this->request->getRequestParam(
2210
+				'delete_txn_reg_status_change',
2211
+				false,
2212
+				'bool'
2213
+			);
2214
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
2215
+			if ($payment instanceof EE_Payment) {
2216
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2217
+				/** @type EE_Transaction_Payments $transaction_payments */
2218
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2219
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
2220
+					$json_response_data['return_data'] = $this->_build_payment_json_response(
2221
+						$payment,
2222
+						$REG_IDs,
2223
+						$delete_txn_reg_status_change
2224
+					);
2225
+					if ($delete_txn_reg_status_change) {
2226
+						// MAKE sure we also add the delete_txn_req_status_change to the
2227
+						// request data because that's how messages will be looking for it.
2228
+						$this->request->setRequestParam('txn_reg_status_change', $delete_txn_reg_status_change);
2229
+						$this->_maybe_send_notifications();
2230
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
2231
+					}
2232
+				}
2233
+			} else {
2234
+				EE_Error::add_error(
2235
+					esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
2236
+					__FILE__,
2237
+					__FUNCTION__,
2238
+					__LINE__
2239
+				);
2240
+			}
2241
+		} elseif ($can_delete) {
2242
+			EE_Error::add_error(
2243
+				esc_html__(
2244
+					'A valid Payment ID was not received, therefore payment form data could not be loaded.',
2245
+					'event_espresso'
2246
+				),
2247
+				__FILE__,
2248
+				__FUNCTION__,
2249
+				__LINE__
2250
+			);
2251
+		} else {
2252
+			EE_Error::add_error(
2253
+				esc_html__(
2254
+					'You do not have access to delete a payment.',
2255
+					'event_espresso'
2256
+				),
2257
+				__FILE__,
2258
+				__FUNCTION__,
2259
+				__LINE__
2260
+			);
2261
+		}
2262
+		$notices              = EE_Error::get_notices(false, false, false);
2263
+		$this->_template_args = [
2264
+			'data'      => $json_response_data,
2265
+			'success'   => $notices['success'],
2266
+			'error'     => $notices['errors'],
2267
+			'attention' => $notices['attention'],
2268
+		];
2269
+		$this->_return_json();
2270
+	}
2271
+
2272
+
2273
+	/**
2274
+	 * _registration_payment_data_array
2275
+	 * adds info for 'owing' and 'paid' for each registration to the json response
2276
+	 *
2277
+	 * @access protected
2278
+	 * @param array $REG_IDs
2279
+	 * @return array
2280
+	 * @throws EE_Error
2281
+	 * @throws InvalidArgumentException
2282
+	 * @throws InvalidDataTypeException
2283
+	 * @throws InvalidInterfaceException
2284
+	 * @throws ReflectionException
2285
+	 */
2286
+	protected function _registration_payment_data_array($REG_IDs)
2287
+	{
2288
+		$registration_payment_data = [];
2289
+		// if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2290
+		if (! empty($REG_IDs)) {
2291
+			$registrations = EEM_Registration::instance()->get_all([['REG_ID' => ['IN', $REG_IDs]]]);
2292
+			foreach ($registrations as $registration) {
2293
+				if ($registration instanceof EE_Registration) {
2294
+					$registration_payment_data[ $registration->ID() ] = [
2295
+						'paid'  => $registration->pretty_paid(),
2296
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2297
+					];
2298
+				}
2299
+			}
2300
+		}
2301
+
2302
+		return $registration_payment_data;
2303
+	}
2304
+
2305
+
2306
+	/**
2307
+	 * _maybe_send_notifications
2308
+	 * determines whether or not the admin has indicated that notifications should be sent.
2309
+	 * If so, will toggle a filter switch for delivering registration notices.
2310
+	 * If passed an EE_Payment object, then it will trigger payment notifications instead.
2311
+	 *
2312
+	 * @access protected
2313
+	 * @param EE_Payment | null $payment
2314
+	 */
2315
+	protected function _maybe_send_notifications($payment = null)
2316
+	{
2317
+		switch ($payment instanceof EE_Payment) {
2318
+			// payment notifications
2319
+			case true:
2320
+				if ($this->request->getRequestParam('txn_payments[send_notifications]', false, 'bool')) {
2321
+					$this->_process_payment_notification($payment);
2322
+				}
2323
+				break;
2324
+			// registration notifications
2325
+			case false:
2326
+				if ($this->request->getRequestParam('txn_reg_status_change[send_notifications]', false, 'bool')) {
2327
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
2328
+				}
2329
+				break;
2330
+		}
2331
+	}
2332
+
2333
+
2334
+	/**
2335
+	 * _send_payment_reminder
2336
+	 *    generates HTML for the View Transaction Details Admin page
2337
+	 *
2338
+	 * @access protected
2339
+	 * @return void
2340
+	 * @throws EE_Error
2341
+	 * @throws InvalidArgumentException
2342
+	 * @throws InvalidDataTypeException
2343
+	 * @throws InvalidInterfaceException
2344
+	 */
2345
+	protected function _send_payment_reminder()
2346
+	{
2347
+		$TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
2348
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2349
+		$redirect_to = $this->request->getRequestParam('redirect_to');
2350
+		$query_args  = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID,] : [];
2351
+		do_action(
2352
+			'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2353
+			$transaction
2354
+		);
2355
+		$this->_redirect_after_action(
2356
+			false,
2357
+			esc_html__('payment reminder', 'event_espresso'),
2358
+			esc_html__('sent', 'event_espresso'),
2359
+			$query_args,
2360
+			true
2361
+		);
2362
+	}
2363
+
2364
+
2365
+	/**
2366
+	 *  get_transactions
2367
+	 *    get transactions for given parameters (used by list table)
2368
+	 *
2369
+	 * @param int     $per_page how many transactions displayed per page
2370
+	 * @param boolean $count   return the count or objects
2371
+	 * @param string  $view
2372
+	 * @return EE_Transaction[]|int int = count || array of transaction objects
2373
+	 * @throws EE_Error
2374
+	 * @throws InvalidArgumentException
2375
+	 * @throws InvalidDataTypeException
2376
+	 * @throws InvalidInterfaceException
2377
+	 */
2378
+	public function get_transactions($per_page, $count = false, $view = '')
2379
+	{
2380
+		$start_date = wp_strip_all_tags(
2381
+			$this->request->getRequestParam('txn-filter-start-date', date('m/d/Y', strtotime('-10 year')))
2382
+		);
2383
+		$end_date = wp_strip_all_tags(
2384
+			$this->request->getRequestParam('txn-filter-end-date', date('m/d/Y'))
2385
+		);
2386
+
2387
+		// make sure our timestamps start and end right at the boundaries for each day
2388
+		$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2389
+		$end_date   = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2390
+
2391
+
2392
+		// convert to timestamps
2393
+		$start_date = strtotime($start_date);
2394
+		$end_date   = strtotime($end_date);
2395
+
2396
+		// makes sure start date is the lowest value and vice versa
2397
+		$start_date = min($start_date, $end_date);
2398
+		$end_date   = max($start_date, $end_date);
2399
+
2400
+		// convert to correct format for query
2401
+		$start_date = EEM_Transaction::instance()->convert_datetime_for_query(
2402
+			'TXN_timestamp',
2403
+			date('Y-m-d H:i:s', $start_date),
2404
+			'Y-m-d H:i:s'
2405
+		);
2406
+		$end_date   = EEM_Transaction::instance()->convert_datetime_for_query(
2407
+			'TXN_timestamp',
2408
+			date('Y-m-d H:i:s', $end_date),
2409
+			'Y-m-d H:i:s'
2410
+		);
2411
+
2412
+
2413
+		// set orderby
2414
+		$orderby = $this->request->getRequestParam('orderby');
2415
+
2416
+		switch ($orderby) {
2417
+			case 'TXN_ID':
2418
+				break;
2419
+			case 'ATT_fname':
2420
+				$orderby = 'Registration.Attendee.ATT_fname';
2421
+				break;
2422
+			case 'event_name':
2423
+				$orderby = 'Registration.Event.EVT_name';
2424
+				break;
2425
+			default: // 'TXN_timestamp'
2426
+				$orderby = 'TXN_timestamp';
2427
+		}
2428
+
2429
+		$sort         = $this->request->getRequestParam('order', 'DESC');
2430
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
2431
+
2432
+		$per_page = absint($per_page) ? $per_page : 10;
2433
+		$per_page = $this->request->getRequestParam('perpage', $per_page, 'int');
2434
+
2435
+		$offset = ($current_page - 1) * $per_page;
2436
+		$limit  = [$offset, $per_page];
2437
+
2438
+		$_where = [
2439
+			'TXN_timestamp'          => ['BETWEEN', [$start_date, $end_date]],
2440
+			'Registration.REG_count' => 1,
2441
+		];
2442
+
2443
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
2444
+		if ($EVT_ID) {
2445
+			$_where['Registration.EVT_ID'] = $EVT_ID;
2446
+		}
2447
+
2448
+		$search_term = $this->request->getRequestParam('s');
2449
+		if ($search_term) {
2450
+			$search_term = '%' . $search_term . '%';
2451
+			$_where['OR']  = [
2452
+				'Registration.Event.EVT_name'         => ['LIKE', $search_term],
2453
+				'Registration.Event.EVT_desc'         => ['LIKE', $search_term],
2454
+				'Registration.Event.EVT_short_desc'   => ['LIKE', $search_term],
2455
+				'Registration.Attendee.ATT_full_name' => ['LIKE', $search_term],
2456
+				'Registration.Attendee.ATT_fname'     => ['LIKE', $search_term],
2457
+				'Registration.Attendee.ATT_lname'     => ['LIKE', $search_term],
2458
+				'Registration.Attendee.ATT_short_bio' => ['LIKE', $search_term],
2459
+				'Registration.Attendee.ATT_email'     => ['LIKE', $search_term],
2460
+				'Registration.Attendee.ATT_address'   => ['LIKE', $search_term],
2461
+				'Registration.Attendee.ATT_address2'  => ['LIKE', $search_term],
2462
+				'Registration.Attendee.ATT_city'      => ['LIKE', $search_term],
2463
+				'Registration.REG_final_price'        => ['LIKE', $search_term],
2464
+				'Registration.REG_code'               => ['LIKE', $search_term],
2465
+				'Registration.REG_count'              => ['LIKE', $search_term],
2466
+				'Registration.REG_group_size'         => ['LIKE', $search_term],
2467
+				'Registration.Ticket.TKT_name'        => ['LIKE', $search_term],
2468
+				'Registration.Ticket.TKT_description' => ['LIKE', $search_term],
2469
+				'Payment.PAY_source'                  => ['LIKE', $search_term],
2470
+				'Payment.Payment_Method.PMD_name'     => ['LIKE', $search_term],
2471
+				'TXN_session_data'                    => ['LIKE', $search_term],
2472
+				'Payment.PAY_txn_id_chq_nmbr'         => ['LIKE', $search_term],
2473
+			];
2474
+		}
2475
+
2476
+		$status = $this->request->getRequestParam('status');
2477
+		// failed transactions
2478
+		$failed     = (! empty($status) && $status === 'failed' && ! $count) || ($count && $view === 'failed');
2479
+		$abandoned  = (! empty($status) && $status === 'abandoned' && ! $count) || ($count && $view === 'abandoned');
2480
+		$incomplete = (! empty($status) && $status === 'incomplete' && ! $count) || ($count && $view === 'incomplete');
2481
+
2482
+		if ($failed) {
2483
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
2484
+		} elseif ($abandoned) {
2485
+			$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
2486
+		} elseif ($incomplete) {
2487
+			$_where['STS_ID'] = EEM_Transaction::incomplete_status_code;
2488
+		} else {
2489
+			$_where['STS_ID']  = ['!=', EEM_Transaction::failed_status_code];
2490
+			$_where['STS_ID*'] = ['!=', EEM_Transaction::abandoned_status_code];
2491
+		}
2492
+
2493
+		$query_params = apply_filters(
2494
+			'FHEE__Transactions_Admin_Page___get_transactions_query_params',
2495
+			[
2496
+				$_where,
2497
+				'order_by'                 => [$orderby => $sort],
2498
+				'limit'                    => $limit,
2499
+				'default_where_conditions' => EEM_Base::default_where_conditions_this_only,
2500
+			],
2501
+			$this->request->requestParams(),
2502
+			$view,
2503
+			$count
2504
+		);
2505
+
2506
+		return $count
2507
+			? EEM_Transaction::instance()->count([$query_params[0]], 'TXN_ID', true)
2508
+			: EEM_Transaction::instance()->get_all($query_params);
2509
+	}
2510
+
2511
+
2512
+	/**
2513
+	 * @throws EE_Error
2514
+	 * @throws InvalidArgumentException
2515
+	 * @throws InvalidDataTypeException
2516
+	 * @throws InvalidInterfaceException
2517
+	 * @throws ReflectionException
2518
+	 * @throws RuntimeException
2519
+	 * @since 4.9.79.p
2520
+	 */
2521
+	public function recalculateLineItems()
2522
+	{
2523
+		$TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
2524
+		/** @var EE_Transaction $transaction */
2525
+		$transaction     = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2526
+		$success         = $transaction->recalculateLineItems();
2527
+		$redirect_to = $this->request->getRequestParam('redirect_to');
2528
+		$query_args = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID,] : [];
2529
+		$this->_redirect_after_action(
2530
+			$success,
2531
+			esc_html__('Transaction taxes and totals', 'event_espresso'),
2532
+			esc_html__('recalculated', 'event_espresso'),
2533
+			$query_args,
2534
+			true
2535
+		);
2536
+	}
2537 2537
 }
Please login to merge, or discard this patch.
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
             'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247 247
             'event_espresso'
248 248
         );
249
-        EE_Registry::$i18n_js_strings['error_occurred']          = esc_html__(
249
+        EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__(
250 250
             'An error occurred! Please refresh the page and try again.',
251 251
             'event_espresso'
252 252
         );
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         // enqueue style
346 346
         wp_register_style(
347 347
             'espresso_txn',
348
-            TXN_ASSETS_URL . 'espresso_transactions_admin.css',
348
+            TXN_ASSETS_URL.'espresso_transactions_admin.css',
349 349
             [],
350 350
             EVENT_ESPRESSO_VERSION
351 351
         );
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
         // scripts
354 354
         wp_register_script(
355 355
             'espresso_txn',
356
-            TXN_ASSETS_URL . 'espresso_transactions_admin.js',
356
+            TXN_ASSETS_URL.'espresso_transactions_admin.js',
357 357
             [
358 358
                 'ee_admin_js',
359 359
                 'ee-datepicker',
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
             $this->_transaction->verify_abandoned_transaction_status();
481 481
         }
482 482
 
483
-        if (! $this->_transaction instanceof EE_Transaction) {
483
+        if ( ! $this->_transaction instanceof EE_Transaction) {
484 484
             $error_msg = sprintf(
485 485
                 esc_html__(
486 486
                     'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
             'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
578 578
             [
579 579
                 'overpaid'   => [
580
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
580
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code,
581 581
                     'desc'  => EEH_Template::pretty_status(
582 582
                         EEM_Transaction::overpaid_status_code,
583 583
                         false,
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
                     ),
586 586
                 ],
587 587
                 'complete'   => [
588
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
588
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code,
589 589
                     'desc'  => EEH_Template::pretty_status(
590 590
                         EEM_Transaction::complete_status_code,
591 591
                         false,
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
                     ),
594 594
                 ],
595 595
                 'incomplete' => [
596
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
596
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code,
597 597
                     'desc'  => EEH_Template::pretty_status(
598 598
                         EEM_Transaction::incomplete_status_code,
599 599
                         false,
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
                     ),
602 602
                 ],
603 603
                 'abandoned'  => [
604
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
604
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code,
605 605
                     'desc'  => EEH_Template::pretty_status(
606 606
                         EEM_Transaction::abandoned_status_code,
607 607
                         false,
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
                     ),
610 610
                 ],
611 611
                 'failed'     => [
612
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
612
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code,
613 613
                     'desc'  => EEH_Template::pretty_status(
614 614
                         EEM_Transaction::failed_status_code,
615 615
                         false,
@@ -652,11 +652,11 @@  discard block
 block discarded – undo
652 652
                 )
653 653
                 . '" title="'
654 654
                 . esc_attr__('Click to Edit event', 'event_espresso')
655
-                . '">' . $event->name() . '</a>',
655
+                . '">'.$event->name().'</a>',
656 656
                 '</h3>'
657 657
             )
658 658
             : '';
659
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_transaction_legend_items());
659
+        $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
660 660
         $this->display_admin_list_table_page_with_no_sidebar();
661 661
     }
662 662
 
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 
687 687
         $this->_set_transaction_object();
688 688
 
689
-        if (! $this->_transaction instanceof EE_Transaction) {
689
+        if ( ! $this->_transaction instanceof EE_Transaction) {
690 690
             return;
691 691
         }
692 692
 
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
         $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
697 697
         $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
698 698
 
699
-        $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->status_ID() ];
699
+        $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->status_ID()];
700 700
         $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
701
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->status_ID();
701
+        $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->status_ID();
702 702
 
703 703
         $this->_template_args['grand_total'] = $this->_transaction->total();
704 704
         $this->_template_args['total_paid']  = $this->_transaction->paid();
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 
751 751
 
752 752
         // next link
753
-        $next_txn                                 = $this->_transaction->next(
753
+        $next_txn = $this->_transaction->next(
754 754
             null,
755 755
             [['STS_ID' => ['!=', EEM_Transaction::failed_status_code]]],
756 756
             'TXN_ID'
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
             )
766 766
             : '';
767 767
         // previous link
768
-        $previous_txn                                 = $this->_transaction->previous(
768
+        $previous_txn = $this->_transaction->previous(
769 769
             null,
770 770
             [['STS_ID' => ['!=', EEM_Transaction::failed_status_code]]],
771 771
             'TXN_ID'
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
         // grab messages at the last second
818 818
         $this->_template_args['notices'] = EE_Error::get_notices();
819 819
         // path to template
820
-        $template_path                             = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
820
+        $template_path                             = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php';
821 821
         $this->_template_args['admin_page_header'] = EEH_Template::display_template(
822 822
             $template_path,
823 823
             $this->_template_args,
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 
847 847
         $this->_set_transaction_object();
848 848
 
849
-        if (! $this->_transaction instanceof EE_Transaction) {
849
+        if ( ! $this->_transaction instanceof EE_Transaction) {
850 850
             return;
851 851
         }
852 852
         add_meta_box(
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
     {
903 903
         $content = '';
904 904
         $actions = [];
905
-        if (! $transaction instanceof EE_Transaction) {
905
+        if ( ! $transaction instanceof EE_Transaction) {
906 906
             return $content;
907 907
         }
908 908
         /** @var EE_Registration $primary_registration */
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
         );
988 988
         if ($actions) {
989 989
             $content = '<ul>';
990
-            $content .= '<li>' . implode('</li><li>', $actions) . '</li>';
990
+            $content .= '<li>'.implode('</li><li>', $actions).'</li>';
991 991
             $content .= '</uL>';
992 992
         }
993 993
         return $content;
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
             $this->_transaction->primary_registration() instanceof EE_Registration
1016 1016
                 ? $this->_transaction->primary_registration()->attendee()
1017 1017
                 : null;
1018
-        $this->_template_args['can_edit_payments']   = EE_Registry::instance()->CAP->current_user_can(
1018
+        $this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can(
1019 1019
             'ee_edit_payments',
1020 1020
             'apply_payment_or_refund_from_registration_details'
1021 1021
         );
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 
1027 1027
         // get line table
1028 1028
         EEH_Autoloader::register_line_item_display_autoloaders();
1029
-        $Line_Item_Display                       = new EE_Line_Item_Display(
1029
+        $Line_Item_Display = new EE_Line_Item_Display(
1030 1030
             'admin_table',
1031 1031
             'EE_Admin_Table_Line_Item_Display_Strategy'
1032 1032
         );
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
         $taxes                         = $this->_transaction->line_items([['LIN_type' => EEM_Line_Item::type_tax]]);
1042 1042
         $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1043 1043
 
1044
-        $this->_template_args['grand_total']     = EEH_Template::format_currency(
1044
+        $this->_template_args['grand_total'] = EEH_Template::format_currency(
1045 1045
             $this->_transaction->total(),
1046 1046
             false,
1047 1047
             false
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 
1052 1052
         // process payment details
1053 1053
         $payments = $this->_transaction->payments();
1054
-        if (! empty($payments)) {
1054
+        if ( ! empty($payments)) {
1055 1055
             $this->_template_args['payments']              = $payments;
1056 1056
             $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1057 1057
         } else {
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
                                   esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1114 1114
                                   ucwords(str_replace('_', ' ', $reg_step)),
1115 1115
                                   date(
1116
-                                      get_option('date_format') . ' ' . get_option('time_format'),
1116
+                                      get_option('date_format').' '.get_option('time_format'),
1117 1117
                                       $reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1118 1118
                                   )
1119 1119
                               )
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
                               . '</li>';
1128 1128
             }
1129 1129
         }
1130
-        $reg_steps                                                 .= '</ul>';
1130
+        $reg_steps .= '</ul>';
1131 1131
         $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1132 1132
         $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1133 1133
             'Registration Step Progress',
@@ -1140,14 +1140,14 @@  discard block
 block discarded – undo
1140 1140
         $this->_get_payment_status_array();
1141 1141
         $this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1142 1142
 
1143
-        $this->_template_args['transaction_form_url']    = add_query_arg(
1143
+        $this->_template_args['transaction_form_url'] = add_query_arg(
1144 1144
             [
1145 1145
                 'action'  => 'edit_transaction',
1146 1146
                 'process' => 'transaction',
1147 1147
             ],
1148 1148
             TXN_ADMIN_URL
1149 1149
         );
1150
-        $this->_template_args['apply_payment_form_url']  = add_query_arg(
1150
+        $this->_template_args['apply_payment_form_url'] = add_query_arg(
1151 1151
             [
1152 1152
                 'page'   => 'espresso_transactions',
1153 1153
                 'action' => 'espresso_apply_payment',
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 
1167 1167
         // 'espresso_delete_payment_nonce'
1168 1168
 
1169
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1169
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php';
1170 1170
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
1171 1171
     }
1172 1172
 
@@ -1198,19 +1198,19 @@  discard block
 block discarded – undo
1198 1198
                 ],
1199 1199
             ]
1200 1200
         );
1201
-        if (! empty($reg_payments)) {
1201
+        if ( ! empty($reg_payments)) {
1202 1202
             foreach ($payments as $payment) {
1203
-                if (! $payment instanceof EE_Payment) {
1203
+                if ( ! $payment instanceof EE_Payment) {
1204 1204
                     continue;
1205
-                } elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1206
-                    $existing_reg_payments[ $payment->ID() ] = [];
1205
+                } elseif ( ! isset($existing_reg_payments[$payment->ID()])) {
1206
+                    $existing_reg_payments[$payment->ID()] = [];
1207 1207
                 }
1208 1208
                 foreach ($reg_payments as $reg_payment) {
1209 1209
                     if (
1210 1210
                         $reg_payment instanceof EE_Registration_Payment
1211 1211
                         && $reg_payment->payment_ID() === $payment->ID()
1212 1212
                     ) {
1213
-                        $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1213
+                        $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
1214 1214
                     }
1215 1215
                 }
1216 1216
             }
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
     protected function _get_registrations_to_apply_payment_to()
1237 1237
     {
1238 1238
         // we want any registration with an active status (ie: not deleted or cancelled)
1239
-        $query_params                      = [
1239
+        $query_params = [
1240 1240
             [
1241 1241
                 'STS_ID' => [
1242 1242
                     'IN',
@@ -1248,22 +1248,22 @@  discard block
 block discarded – undo
1248 1248
                 ],
1249 1249
             ],
1250 1250
         ];
1251
-        $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
1251
+        $registrations_to_apply_payment_to = EEH_HTML::br().EEH_HTML::div(
1252 1252
             '',
1253 1253
             'txn-admin-apply-payment-to-registrations-dv',
1254 1254
             '',
1255 1255
             'clear: both; margin: 1.5em 0 0; display: none;'
1256 1256
         );
1257
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1257
+        $registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1258 1258
         $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1259 1259
         $registrations_to_apply_payment_to .= EEH_HTML::thead(
1260 1260
             EEH_HTML::tr(
1261
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1262
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1263
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1264
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1265
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1266
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1261
+                EEH_HTML::th(esc_html__('ID', 'event_espresso')).
1262
+                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')).
1263
+                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')).
1264
+                EEH_HTML::th(esc_html__('Event', 'event_espresso')).
1265
+                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr').
1266
+                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr').
1267 1267
                 EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1268 1268
             )
1269 1269
         );
@@ -1278,34 +1278,34 @@  discard block
 block discarded – undo
1278 1278
                     : esc_html__('Unknown Attendee', 'event_espresso');
1279 1279
                 $owing                             = $registration->final_price() - $registration->paid();
1280 1280
                 $taxable                           = $registration->ticket()->taxable()
1281
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1281
+                    ? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>'
1282 1282
                     : '';
1283 1283
                 $checked                           = empty($existing_reg_payments)
1284 1284
                                                      || in_array($registration->ID(), $existing_reg_payments, true)
1285 1285
                     ? ' checked'
1286 1286
                     : '';
1287
-                $disabled                          = $registration->final_price() > 0 ? '' : ' disabled';
1287
+                $disabled = $registration->final_price() > 0 ? '' : ' disabled';
1288 1288
                 $registrations_to_apply_payment_to .= EEH_HTML::tr(
1289
-                    EEH_HTML::td($registration->ID()) .
1290
-                    EEH_HTML::td($attendee_name) .
1289
+                    EEH_HTML::td($registration->ID()).
1290
+                    EEH_HTML::td($attendee_name).
1291 1291
                     EEH_HTML::td(
1292
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1293
-                    ) .
1294
-                    EEH_HTML::td($registration->event_name()) .
1295
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1292
+                        $registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable
1293
+                    ).
1294
+                    EEH_HTML::td($registration->event_name()).
1295
+                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr').
1296 1296
                     EEH_HTML::td(
1297 1297
                         EEH_Template::format_currency($owing),
1298 1298
                         '',
1299 1299
                         'txn-admin-payment-owing-td jst-cntr'
1300
-                    ) .
1300
+                    ).
1301 1301
                     EEH_HTML::td(
1302
-                        '<input type="checkbox" value="' . $registration->ID()
1302
+                        '<input type="checkbox" value="'.$registration->ID()
1303 1303
                         . '" name="txn_admin_payment[registrations]"'
1304
-                        . $checked . $disabled . '>',
1304
+                        . $checked.$disabled.'>',
1305 1305
                         '',
1306 1306
                         'jst-cntr'
1307 1307
                     ),
1308
-                    'apply-payment-registration-row-' . $registration->ID()
1308
+                    'apply-payment-registration-row-'.$registration->ID()
1309 1309
                 );
1310 1310
             }
1311 1311
         }
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
             '',
1321 1321
             'clear description'
1322 1322
         );
1323
-        $registrations_to_apply_payment_to                         .= EEH_HTML::divx();
1323
+        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1324 1324
         $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1325 1325
     }
1326 1326
 
@@ -1386,12 +1386,12 @@  discard block
 block discarded – undo
1386 1386
                 [
1387 1387
                     'OR*payment_method_for_payment' => [
1388 1388
                         'PMD_ID'    => ['IN', $payment_methods_of_payments],
1389
-                        'PMD_scope' => ['LIKE', '%' . EEM_Payment_Method::scope_admin . '%'],
1389
+                        'PMD_scope' => ['LIKE', '%'.EEM_Payment_Method::scope_admin.'%'],
1390 1390
                     ],
1391 1391
                 ],
1392 1392
             ];
1393 1393
         } else {
1394
-            $query_args = [['PMD_scope' => ['LIKE', '%' . EEM_Payment_Method::scope_admin . '%']]];
1394
+            $query_args = [['PMD_scope' => ['LIKE', '%'.EEM_Payment_Method::scope_admin.'%']]];
1395 1395
         }
1396 1396
         $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1397 1397
     }
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
             'Line_Item',
1425 1425
             [['LIN_type' => 'line-item']]
1426 1426
         );
1427
-        if (! empty($line_items)) {
1427
+        if ( ! empty($line_items)) {
1428 1428
             foreach ($line_items as $item) {
1429 1429
                 if ($item instanceof EE_Line_Item) {
1430 1430
                     switch ($item->OBJ_type()) {
@@ -1434,7 +1434,7 @@  discard block
 block discarded – undo
1434 1434
                             $ticket = $item->ticket();
1435 1435
                             // right now we're only handling tickets here.
1436 1436
                             // Cause its expected that only tickets will have attendees right?
1437
-                            if (! $ticket instanceof EE_Ticket) {
1437
+                            if ( ! $ticket instanceof EE_Ticket) {
1438 1438
                                 break;
1439 1439
                             }
1440 1440
                             try {
@@ -1443,45 +1443,45 @@  discard block
 block discarded – undo
1443 1443
                                 EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1444 1444
                                 $event_name = esc_html__('Unknown Event', 'event_espresso');
1445 1445
                             }
1446
-                            $event_name   .= ' - ' . $item->name();
1446
+                            $event_name   .= ' - '.$item->name();
1447 1447
                             $ticket_price = EEH_Template::format_currency($item->unit_price());
1448 1448
                             // now get all of the registrations for this transaction that use this ticket
1449 1449
                             $registrations = $ticket->registrations(
1450 1450
                                 [['TXN_ID' => $this->_transaction->ID()]]
1451 1451
                             );
1452 1452
                             foreach ($registrations as $registration) {
1453
-                                if (! $registration instanceof EE_Registration) {
1453
+                                if ( ! $registration instanceof EE_Registration) {
1454 1454
                                     break;
1455 1455
                                 }
1456
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1456
+                                $this->_template_args['event_attendees'][$registration->ID()]['STS_ID']
1457 1457
                                     = $registration->status_ID();
1458
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1458
+                                $this->_template_args['event_attendees'][$registration->ID()]['att_num']
1459 1459
                                     = $registration->count();
1460
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1460
+                                $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name']
1461 1461
                                     = $event_name;
1462
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1462
+                                $this->_template_args['event_attendees'][$registration->ID()]['ticket_price']
1463 1463
                                     = $ticket_price;
1464 1464
                                 // attendee info
1465 1465
                                 $attendee = $registration->get_first_related('Attendee');
1466 1466
                                 if ($attendee instanceof EE_Attendee) {
1467
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1467
+                                    $this->_template_args['event_attendees'][$registration->ID()]['att_id']
1468 1468
                                         = $attendee->ID();
1469
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1469
+                                    $this->_template_args['event_attendees'][$registration->ID()]['attendee']
1470 1470
                                         = $attendee->full_name();
1471
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']
1472
-                                        = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1471
+                                    $this->_template_args['event_attendees'][$registration->ID()]['email']
1472
+                                        = '<a href="mailto:'.$attendee->email().'?subject='.$event_name
1473 1473
                                           . esc_html__(
1474 1474
                                               ' Event',
1475 1475
                                               'event_espresso'
1476 1476
                                           )
1477
-                                          . '">' . $attendee->email() . '</a>';
1478
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']
1477
+                                          . '">'.$attendee->email().'</a>';
1478
+                                    $this->_template_args['event_attendees'][$registration->ID()]['address']
1479 1479
                                         = EEH_Address::format($attendee, 'inline', false, false);
1480 1480
                                 } else {
1481
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']   = '';
1482
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1483
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']    = '';
1484
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']  = '';
1481
+                                    $this->_template_args['event_attendees'][$registration->ID()]['att_id']   = '';
1482
+                                    $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = '';
1483
+                                    $this->_template_args['event_attendees'][$registration->ID()]['email']    = '';
1484
+                                    $this->_template_args['event_attendees'][$registration->ID()]['address']  = '';
1485 1485
                                 }
1486 1486
                             }
1487 1487
                             break;
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
                 TXN_ADMIN_URL
1498 1498
             );
1499 1499
             echo EEH_Template::display_template(
1500
-                TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1500
+                TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php',
1501 1501
                 $this->_template_args,
1502 1502
                 true
1503 1503
             );
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
         $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1533 1533
             ? $this->_transaction->primary_registration()->get_first_related('Attendee')
1534 1534
             : null;
1535
-        if (! $primary_att instanceof EE_Attendee) {
1535
+        if ( ! $primary_att instanceof EE_Attendee) {
1536 1536
             $this->_template_args['no_attendee_message'] = esc_html__(
1537 1537
                 'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1538 1538
                 'event_espresso'
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
         // get formatted address for registrant
1555 1555
         $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1556 1556
         echo EEH_Template::display_template(
1557
-            TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1557
+            TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php',
1558 1558
             $this->_template_args,
1559 1559
             true
1560 1560
         );
@@ -1580,7 +1580,7 @@  discard block
 block discarded – undo
1580 1580
             TXN_ADMIN_URL
1581 1581
         );
1582 1582
 
1583
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1583
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php';
1584 1584
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
1585 1585
     }
1586 1586
 
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
             'ee_edit_payments',
1607 1607
             'apply_payment_or_refund_from_registration_details'
1608 1608
         );
1609
-        if (! empty($valid_data) && $has_access) {
1609
+        if ( ! empty($valid_data) && $has_access) {
1610 1610
             $PAY_ID = $valid_data['PAY_ID'];
1611 1611
             // save  the new payment
1612 1612
             $payment = $this->_create_payment_from_request_data($valid_data);
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
                 $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1620 1620
                 $this->_remove_existing_registration_payments($payment, $PAY_ID);
1621 1621
                 // apply payment to registrations (if applicable)
1622
-                if (! empty($REG_IDs)) {
1622
+                if ( ! empty($REG_IDs)) {
1623 1623
                     $this->_update_registration_payments($transaction, $payment, $REG_IDs);
1624 1624
                     $this->_maybe_send_notifications();
1625 1625
                     // now process status changes for the same registrations
@@ -1665,7 +1665,7 @@  discard block
 block discarded – undo
1665 1665
                 __LINE__
1666 1666
             );
1667 1667
         }
1668
-        $notices              = EE_Error::get_notices(
1668
+        $notices = EE_Error::get_notices(
1669 1669
             false,
1670 1670
             false,
1671 1671
             false
@@ -1690,14 +1690,14 @@  discard block
 block discarded – undo
1690 1690
      */
1691 1691
     protected function _validate_payment_request_data()
1692 1692
     {
1693
-        if (! $this->request->requestParamIsSet('txn_admin_payment')) {
1693
+        if ( ! $this->request->requestParamIsSet('txn_admin_payment')) {
1694 1694
             return [];
1695 1695
         }
1696 1696
         $payment_form = $this->_generate_payment_form_section();
1697 1697
         try {
1698 1698
             if ($payment_form->was_submitted()) {
1699 1699
                 $payment_form->receive_form_submission();
1700
-                if (! $payment_form->is_valid()) {
1700
+                if ( ! $payment_form->is_valid()) {
1701 1701
                     $submission_error_messages = [];
1702 1702
                     foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1703 1703
                         if ($validation_error instanceof EE_Validation_Error) {
@@ -1879,7 +1879,7 @@  discard block
 block discarded – undo
1879 1879
             ['Y-m-d', 'g:i a']
1880 1880
         );
1881 1881
 
1882
-        if (! $payment->save()) {
1882
+        if ( ! $payment->save()) {
1883 1883
             EE_Error::add_error(
1884 1884
                 sprintf(
1885 1885
                     esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
@@ -2081,12 +2081,12 @@  discard block
 block discarded – undo
2081 2081
         // but add in some conditions regarding payment,
2082 2082
         // so that we don't apply payments to registrations that are free or have already been paid for
2083 2083
         // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2084
-        if (! $payment->is_a_refund()) {
2084
+        if ( ! $payment->is_a_refund()) {
2085 2085
             $registration_query_where_params['REG_final_price']  = ['!=', 0];
2086 2086
             $registration_query_where_params['REG_final_price*'] = ['!=', 'REG_paid', true];
2087 2087
         }
2088 2088
         $registrations = $transaction->registrations([$registration_query_where_params]);
2089
-        if (! empty($registrations)) {
2089
+        if ( ! empty($registrations)) {
2090 2090
             /** @type EE_Payment_Processor $payment_processor */
2091 2091
             $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2092 2092
             $payment_processor->process_registration_payments($transaction, $payment, $registrations);
@@ -2168,7 +2168,7 @@  discard block
 block discarded – undo
2168 2168
             'pay_status'       => $payment->STS_ID(),
2169 2169
             'PAY_ID'           => $payment->ID(),
2170 2170
             'STS_ID'           => $payment->STS_ID(),
2171
-            'status'           => self::$_pay_status[ $payment->STS_ID() ],
2171
+            'status'           => self::$_pay_status[$payment->STS_ID()],
2172 2172
             'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2173 2173
             'method'           => strtoupper($payment->source()),
2174 2174
             'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
@@ -2287,11 +2287,11 @@  discard block
 block discarded – undo
2287 2287
     {
2288 2288
         $registration_payment_data = [];
2289 2289
         // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2290
-        if (! empty($REG_IDs)) {
2290
+        if ( ! empty($REG_IDs)) {
2291 2291
             $registrations = EEM_Registration::instance()->get_all([['REG_ID' => ['IN', $REG_IDs]]]);
2292 2292
             foreach ($registrations as $registration) {
2293 2293
                 if ($registration instanceof EE_Registration) {
2294
-                    $registration_payment_data[ $registration->ID() ] = [
2294
+                    $registration_payment_data[$registration->ID()] = [
2295 2295
                         'paid'  => $registration->pretty_paid(),
2296 2296
                         'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2297 2297
                     ];
@@ -2347,7 +2347,7 @@  discard block
 block discarded – undo
2347 2347
         $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int');
2348 2348
         $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2349 2349
         $redirect_to = $this->request->getRequestParam('redirect_to');
2350
-        $query_args  = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID,] : [];
2350
+        $query_args  = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID, ] : [];
2351 2351
         do_action(
2352 2352
             'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2353 2353
             $transaction
@@ -2385,8 +2385,8 @@  discard block
 block discarded – undo
2385 2385
         );
2386 2386
 
2387 2387
         // make sure our timestamps start and end right at the boundaries for each day
2388
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2389
-        $end_date   = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2388
+        $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
2389
+        $end_date   = date('Y-m-d', strtotime($end_date)).' 23:59:59';
2390 2390
 
2391 2391
 
2392 2392
         // convert to timestamps
@@ -2403,7 +2403,7 @@  discard block
 block discarded – undo
2403 2403
             date('Y-m-d H:i:s', $start_date),
2404 2404
             'Y-m-d H:i:s'
2405 2405
         );
2406
-        $end_date   = EEM_Transaction::instance()->convert_datetime_for_query(
2406
+        $end_date = EEM_Transaction::instance()->convert_datetime_for_query(
2407 2407
             'TXN_timestamp',
2408 2408
             date('Y-m-d H:i:s', $end_date),
2409 2409
             'Y-m-d H:i:s'
@@ -2447,8 +2447,8 @@  discard block
 block discarded – undo
2447 2447
 
2448 2448
         $search_term = $this->request->getRequestParam('s');
2449 2449
         if ($search_term) {
2450
-            $search_term = '%' . $search_term . '%';
2451
-            $_where['OR']  = [
2450
+            $search_term = '%'.$search_term.'%';
2451
+            $_where['OR'] = [
2452 2452
                 'Registration.Event.EVT_name'         => ['LIKE', $search_term],
2453 2453
                 'Registration.Event.EVT_desc'         => ['LIKE', $search_term],
2454 2454
                 'Registration.Event.EVT_short_desc'   => ['LIKE', $search_term],
@@ -2475,9 +2475,9 @@  discard block
 block discarded – undo
2475 2475
 
2476 2476
         $status = $this->request->getRequestParam('status');
2477 2477
         // failed transactions
2478
-        $failed     = (! empty($status) && $status === 'failed' && ! $count) || ($count && $view === 'failed');
2479
-        $abandoned  = (! empty($status) && $status === 'abandoned' && ! $count) || ($count && $view === 'abandoned');
2480
-        $incomplete = (! empty($status) && $status === 'incomplete' && ! $count) || ($count && $view === 'incomplete');
2478
+        $failed     = ( ! empty($status) && $status === 'failed' && ! $count) || ($count && $view === 'failed');
2479
+        $abandoned  = ( ! empty($status) && $status === 'abandoned' && ! $count) || ($count && $view === 'abandoned');
2480
+        $incomplete = ( ! empty($status) && $status === 'incomplete' && ! $count) || ($count && $view === 'incomplete');
2481 2481
 
2482 2482
         if ($failed) {
2483 2483
             $_where['STS_ID'] = EEM_Transaction::failed_status_code;
@@ -2525,7 +2525,7 @@  discard block
 block discarded – undo
2525 2525
         $transaction     = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2526 2526
         $success         = $transaction->recalculateLineItems();
2527 2527
         $redirect_to = $this->request->getRequestParam('redirect_to');
2528
-        $query_args = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID,] : [];
2528
+        $query_args = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID, ] : [];
2529 2529
         $this->_redirect_after_action(
2530 2530
             $success,
2531 2531
             esc_html__('Transaction taxes and totals', 'event_espresso'),
Please login to merge, or discard this patch.
admin_pages/maintenance/templates/ee_migration_page.template.php 1 patch
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -36,55 +36,55 @@  discard block
 block discarded – undo
36 36
             <h3 class="espresso-header">
37 37
                 <span class="dashicons dashicons-flag ee-icon-size-22"></span>
38 38
                 <?php
39
-                echo esc_html(
40
-                    apply_filters(
41
-                        'FHEE__ee_migration_page__header',
42
-                        sprintf(
43
-                            __("Your Event Espresso data needs to be updated.", "event_espresso"),
44
-                            $current_db_state,
45
-                            $next_db_state
46
-                        ),
47
-                        $current_db_state,
48
-                        $next_db_state
49
-                    )
50
-                );
51
-                ?>
39
+				echo esc_html(
40
+					apply_filters(
41
+						'FHEE__ee_migration_page__header',
42
+						sprintf(
43
+							__("Your Event Espresso data needs to be updated.", "event_espresso"),
44
+							$current_db_state,
45
+							$next_db_state
46
+						),
47
+						$current_db_state,
48
+						$next_db_state
49
+					)
50
+				);
51
+				?>
52 52
             </h3>
53 53
         <?php } elseif ($show_most_recent_migration) { ?>
54 54
             <h3 class="espresso-header">
55 55
                 <span class="dashicons dashicons-awards ee-icon-size-22"></span>
56 56
                 <?php echo esc_html(
57
-                    apply_filters(
58
-                        'FHEE__ee_migration_page__done_migration_header',
59
-                        sprintf(
60
-                            __(
61
-                                'Congratulations! Your database is "up-to-date" and you are ready to begin using %s',
62
-                                "event_espresso"
63
-                            ),
64
-                            $ultimate_db_state
65
-                        )
66
-                    )
67
-                ); ?>
57
+					apply_filters(
58
+						'FHEE__ee_migration_page__done_migration_header',
59
+						sprintf(
60
+							__(
61
+								'Congratulations! Your database is "up-to-date" and you are ready to begin using %s',
62
+								"event_espresso"
63
+							),
64
+							$ultimate_db_state
65
+						)
66
+					)
67
+				); ?>
68 68
             </h3>
69 69
             <p>
70 70
                 <?php echo esc_html(
71
-                    apply_filters(
72
-                        'FHEE__ee_migration_page__p_after_done_migration_header',
73
-                        sprintf(
74
-                            __(
75
-                                "Time to find out about all the great new features %s has to offer.",
76
-                                "event_espresso"
77
-                            ),
78
-                            $ultimate_db_state
79
-                        )
80
-                    )
81
-                ); ?> &nbsp;
71
+					apply_filters(
72
+						'FHEE__ee_migration_page__p_after_done_migration_header',
73
+						sprintf(
74
+							__(
75
+								"Time to find out about all the great new features %s has to offer.",
76
+								"event_espresso"
77
+							),
78
+							$ultimate_db_state
79
+						)
80
+					)
81
+				); ?> &nbsp;
82 82
                 <b>
83 83
                     <a class="button-primary"
84 84
                        id='get-started-after-migrate'
85 85
                        href="<?php
86
-                        echo esc_url_raw(add_query_arg(['page' => 'espresso_about'], admin_url('admin.php')));
87
-                        ?>"
86
+						echo esc_url_raw(add_query_arg(['page' => 'espresso_about'], admin_url('admin.php')));
87
+						?>"
88 88
                     >
89 89
                         <?php esc_html_e("Let's Get Started", "event_espresso"); ?>&nbsp;
90 90
                         <span class="dashicons dashicons-arrow-right ee-icon-size-22" style="margin:0;"></span>
@@ -95,46 +95,46 @@  discard block
 block discarded – undo
95 95
 
96 96
 
97 97
         <?php
98
-        if ($show_backup_db_text) {
99
-            echo wp_kses($migration_options_html, AllowedTags::getAllowedTags());
100
-        } ?>
98
+		if ($show_backup_db_text) {
99
+			echo wp_kses($migration_options_html, AllowedTags::getAllowedTags());
100
+		} ?>
101 101
 
102 102
         <?php
103
-        if ($show_most_recent_migration) {
104
-            if ($most_recent_migration instanceof EE_Data_Migration_Script_Base) {
105
-                if ($most_recent_migration->can_continue()) {
106
-                    // tell the user they should continue their migration because it appears to be unfinished... well, assuming there were no errors ?>
103
+		if ($show_most_recent_migration) {
104
+			if ($most_recent_migration instanceof EE_Data_Migration_Script_Base) {
105
+				if ($most_recent_migration->can_continue()) {
106
+					// tell the user they should continue their migration because it appears to be unfinished... well, assuming there were no errors ?>
107 107
                     <h3 class="espresso-header">
108 108
                         <span class="dashicons dashicons-star-half ee-icon-size-22"></span>
109 109
                         <?php printf(
110
-                            esc_html__(
111
-                                "It appears that your previous Database Update (%s) is incomplete, and should be resumed",
112
-                                "event_espresso"
113
-                            ),
114
-                            $most_recent_migration->pretty_name()
115
-                        ); ?>
110
+							esc_html__(
111
+								"It appears that your previous Database Update (%s) is incomplete, and should be resumed",
112
+								"event_espresso"
113
+							),
114
+							$most_recent_migration->pretty_name()
115
+						); ?>
116 116
                     </h3>
117 117
                     <?php
118
-                } elseif ($most_recent_migration->is_broken()) {
119
-                    // tell the user the migration failed, and they should notify EE?>
118
+				} elseif ($most_recent_migration->is_broken()) {
119
+					// tell the user the migration failed, and they should notify EE?>
120 120
                     <h3 class="espresso-header">
121 121
                         <span class="dashicons dashicons-no ee-icon-size-22"></span>
122 122
                         <?php echo esc_html($most_recent_migration->get_feedback_message()) ?>
123 123
                     </h3>
124 124
                     <?php
125
-                }
126
-                // display errors or not of the most recent migration ran
127
-                if ($most_recent_migration->get_errors()) {
128
-                    ?>
125
+				}
126
+				// display errors or not of the most recent migration ran
127
+				if ($most_recent_migration->get_errors()) {
128
+					?>
129 129
                     <div class="ee-attention">
130 130
                         <strong>
131 131
                             <?php printf(
132
-                                esc_html__(
133
-                                    "Warnings occurred during your last Database Update (%s):",
134
-                                    'event_espresso'
135
-                                ),
136
-                                $most_recent_migration->pretty_name()
137
-                            ); ?>
132
+								esc_html__(
133
+									"Warnings occurred during your last Database Update (%s):",
134
+									'event_espresso'
135
+								),
136
+								$most_recent_migration->pretty_name()
137
+							); ?>
138 138
                         </strong>
139 139
                         <a id="show-hide-migration-warnings" class="display-the-hidden">
140 140
                             <?php esc_html_e("Show Warnings", 'event_espresso'); ?>
@@ -146,32 +146,32 @@  discard block
 block discarded – undo
146 146
                         </ul>
147 147
                     </div>
148 148
                     <?php
149
-                } else {
150
-                    // there were no errors during the last migration, just say so?>
149
+				} else {
150
+					// there were no errors during the last migration, just say so?>
151 151
                     <h2>
152 152
                         <?php printf(
153
-                            esc_html__(
154
-                                "The last Database Update (%s) ran successfully without errors.",
155
-                                "event_espresso"
156
-                            ),
157
-                            $most_recent_migration->pretty_name()
158
-                        ); ?>
153
+							esc_html__(
154
+								"The last Database Update (%s) ran successfully without errors.",
155
+								"event_espresso"
156
+							),
157
+							$most_recent_migration->pretty_name()
158
+						); ?>
159 159
                     </h2>
160 160
                     <?php
161
-                }
162
-            }
163
-        }
164
-        // end of: if ( $show_most_recent_migration )
165
-        ?>
161
+				}
162
+			}
163
+		}
164
+		// end of: if ( $show_most_recent_migration )
165
+		?>
166 166
 
167 167
     </div>
168 168
     <!--end of #migration-prep-->
169 169
 
170 170
     <?php
171
-    if ($show_migration_progress) { ?>
171
+	if ($show_migration_progress) { ?>
172 172
         <div id='migration-monitor' <?php echo ($show_backup_db_text ? "style='display:none'" : ''); ?>>
173 173
             <?php
174
-            if ($show_backup_db_text) { ?>
174
+			if ($show_backup_db_text) { ?>
175 175
                 <p>
176 176
                     <a class="toggle-migration-monitor small-text" style="cursor: pointer;">
177 177
                         <span class="dashicons dashicons-arrow-left-alt2" style="top:0;"></span>
@@ -181,19 +181,19 @@  discard block
 block discarded – undo
181 181
 
182 182
                 </p>
183 183
                 <?php
184
-            } ?>
184
+			} ?>
185 185
             <div id='progress-area'>
186 186
                 <h3 class="espresso-header">
187 187
                     <?php
188
-                    echo sprintf(
189
-                        _n(
190
-                            "The following task needs to be performed:",
191
-                            "The following %s tasks need to be performed:",
192
-                            count($script_names),
193
-                            "event_espresso"
194
-                        ),
195
-                        count($script_names)
196
-                    ); ?>
188
+					echo sprintf(
189
+						_n(
190
+							"The following task needs to be performed:",
191
+							"The following %s tasks need to be performed:",
192
+							count($script_names),
193
+							"event_espresso"
194
+						),
195
+						count($script_names)
196
+					); ?>
197 197
                 </h3>
198 198
                 <ul style="list-style: inside;">
199 199
                     <?php foreach ($script_names as $script_name) { ?>
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
                 <?php if (count($script_names) > 1) { ?>
205 205
                     <p>
206 206
                         <?php esc_html_e(
207
-                            "Please note: after each task is completed you will need to continue the Database Update, or report an error to Event Espresso.",
208
-                            "event_espresso"
209
-                        ); ?>
207
+							"Please note: after each task is completed you will need to continue the Database Update, or report an error to Event Espresso.",
208
+							"event_espresso"
209
+						); ?>
210 210
                     </p>
211 211
                 <?php } ?>
212 212
 
@@ -217,19 +217,19 @@  discard block
 block discarded – undo
217 217
                         </span>
218 218
                         <br />
219 219
                         <?php esc_html_e(
220
-                            "Depending on the number of events and the complexity of the information in your database, this could take a few minutes.",
221
-                            "event_espresso"
222
-                        ); ?>
220
+							"Depending on the number of events and the complexity of the information in your database, this could take a few minutes.",
221
+							"event_espresso"
222
+						); ?>
223 223
                     </p>
224 224
                     <p>
225 225
                         <?php printf(
226
-                            esc_html__(
227
-                                "%sPlease be patient and do NOT navigate away from this page once the migration has begun%s. If any issues arise due to existing malformed data, an itemized report will be made available to you after the migration has completed.",
228
-                                "event_espresso"
229
-                            ),
230
-                            '<strong>',
231
-                            '</strong>'
232
-                        ); ?>
226
+							esc_html__(
227
+								"%sPlease be patient and do NOT navigate away from this page once the migration has begun%s. If any issues arise due to existing malformed data, an itemized report will be made available to you after the migration has completed.",
228
+								"event_espresso"
229
+							),
230
+							'<strong>',
231
+							'</strong>'
232
+						); ?>
233 233
                     </p>
234 234
                     <p>
235 235
                         <?php esc_html_e("Click the button below to begin the migration process.", "event_espresso") ?>
@@ -245,8 +245,8 @@  discard block
 block discarded – undo
245 245
 
246 246
                 <button id='start-migration' class='button-primary'>
247 247
                     <?php echo ($show_continue_current_migration_script
248
-                        ? esc_html__("Continue Database Update", "event_espresso")
249
-                        : esc_html__("Begin Database Update", "event_espresso")); ?>
248
+						? esc_html__("Continue Database Update", "event_espresso")
249
+						: esc_html__("Begin Database Update", "event_espresso")); ?>
250 250
                 </button>
251 251
                 <br class="clear" />
252 252
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
         </div>
263 263
 
264 264
         <?php
265
-    }
266
-    if ($show_maintenance_switch) {
267
-        ?>
265
+	}
266
+	if ($show_maintenance_switch) {
267
+		?>
268 268
         <h2>
269 269
             <span class="dashicons dashicons-admin-tools"></span>
270 270
             <?php esc_html_e('Set Event Espresso Maintenance Mode', 'event_espresso'); ?>
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
                                    type='radio'
280 280
                                    value="0"
281 281
                                 <?php echo ($mMode_level === EE_Maintenance_Mode::level_0_not_in_maintenance
282
-                                    ? 'checked'
283
-                                    : '');
284
-                                ?>
282
+									? 'checked'
283
+									: '');
284
+								?>
285 285
                             />
286 286
                         </td>
287 287
                         <th align="left">
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
                             </label>
291 291
                             <p class='description' style="font-weight: normal;">
292 292
                                 <?php esc_html_e(
293
-                                    "This is the normal operating mode for Event Espresso and allows all functionality to be viewed by all site visitors.",
294
-                                    "event_espresso"
295
-                                ); ?>
293
+									"This is the normal operating mode for Event Espresso and allows all functionality to be viewed by all site visitors.",
294
+									"event_espresso"
295
+								); ?>
296 296
                             </p>
297 297
                         </th>
298 298
                     </tr>
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
                                    type='radio'
304 304
                                    value="1"
305 305
                                 <?php echo ($mMode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance
306
-                                    ? 'checked'
307
-                                    : '');
308
-                                ?>
306
+									? 'checked'
307
+									: '');
308
+								?>
309 309
                             />
310 310
                         </td>
311 311
                         <th align="left">
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
                             </label>
315 315
                             <p class='description' style="font-weight: normal;">
316 316
                                 <?php esc_html_e(
317
-                                    "This disables Event Espresso frontend functionality for all site visitors that are not administrators, and allows you to configure and/or test things on the frontend of your website before others can see.",
318
-                                    "event_espresso"
319
-                                ); ?>
317
+									"This disables Event Espresso frontend functionality for all site visitors that are not administrators, and allows you to configure and/or test things on the frontend of your website before others can see.",
318
+									"event_espresso"
319
+								); ?>
320 320
                             </p>
321 321
                         </th>
322 322
                     </tr>
@@ -330,6 +330,6 @@  discard block
 block discarded – undo
330 330
             </p>
331 331
         </form>
332 332
         <?php
333
-    } ?>
333
+	} ?>
334 334
 
335 335
 </div>
Please login to merge, or discard this patch.