Completed
Branch more-edtr-ui-fixes (2c574f)
by
unknown
35:48 queued 28:48
created
admin_pages/general_settings/OrganizationSettings.php 1 patch
Indentation   +508 added lines, -508 removed lines patch added patch discarded remove patch
@@ -43,534 +43,534 @@
 block discarded – undo
43 43
  */
44 44
 class OrganizationSettings extends FormHandler
45 45
 {
46
-    /**
47
-     * @var EE_Organization_Config
48
-     */
49
-    protected $organization_config;
46
+	/**
47
+	 * @var EE_Organization_Config
48
+	 */
49
+	protected $organization_config;
50 50
 
51
-    /**
52
-     * @var EE_Core_Config
53
-     */
54
-    protected $core_config;
51
+	/**
52
+	 * @var EE_Core_Config
53
+	 */
54
+	protected $core_config;
55 55
 
56 56
 
57
-    /**
58
-     * @var EE_Network_Core_Config
59
-     */
60
-    protected $network_core_config;
57
+	/**
58
+	 * @var EE_Network_Core_Config
59
+	 */
60
+	protected $network_core_config;
61 61
 
62
-    /**
63
-     * @var CountrySubRegionDao $countrySubRegionDao
64
-     */
65
-    protected $countrySubRegionDao;
62
+	/**
63
+	 * @var CountrySubRegionDao $countrySubRegionDao
64
+	 */
65
+	protected $countrySubRegionDao;
66 66
 
67 67
 
68
-    /**
69
-     * Form constructor.
70
-     *
71
-     * @param EE_Registry            $registry
72
-     * @param EE_Organization_Config $organization_config
73
-     * @param EE_Core_Config         $core_config
74
-     * @param EE_Network_Core_Config $network_core_config
75
-     * @param CountrySubRegionDao    $countrySubRegionDao
76
-     * @throws InvalidArgumentException
77
-     * @throws InvalidDataTypeException
78
-     * @throws DomainException
79
-     */
80
-    public function __construct(
81
-        EE_Registry $registry,
82
-        EE_Organization_Config $organization_config,
83
-        EE_Core_Config $core_config,
84
-        EE_Network_Core_Config $network_core_config,
85
-        CountrySubRegionDao $countrySubRegionDao
86
-    ) {
87
-        $this->organization_config = $organization_config;
88
-        $this->core_config         = $core_config;
89
-        $this->network_core_config = $network_core_config;
90
-        $this->countrySubRegionDao = $countrySubRegionDao;
91
-        parent::__construct(
92
-            esc_html__('Your Organization Settings', 'event_espresso'),
93
-            esc_html__('Your Organization Settings', 'event_espresso'),
94
-            'organization_settings',
95
-            '',
96
-            FormHandler::DO_NOT_SETUP_FORM,
97
-            $registry
98
-        );
99
-    }
68
+	/**
69
+	 * Form constructor.
70
+	 *
71
+	 * @param EE_Registry            $registry
72
+	 * @param EE_Organization_Config $organization_config
73
+	 * @param EE_Core_Config         $core_config
74
+	 * @param EE_Network_Core_Config $network_core_config
75
+	 * @param CountrySubRegionDao    $countrySubRegionDao
76
+	 * @throws InvalidArgumentException
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws DomainException
79
+	 */
80
+	public function __construct(
81
+		EE_Registry $registry,
82
+		EE_Organization_Config $organization_config,
83
+		EE_Core_Config $core_config,
84
+		EE_Network_Core_Config $network_core_config,
85
+		CountrySubRegionDao $countrySubRegionDao
86
+	) {
87
+		$this->organization_config = $organization_config;
88
+		$this->core_config         = $core_config;
89
+		$this->network_core_config = $network_core_config;
90
+		$this->countrySubRegionDao = $countrySubRegionDao;
91
+		parent::__construct(
92
+			esc_html__('Your Organization Settings', 'event_espresso'),
93
+			esc_html__('Your Organization Settings', 'event_espresso'),
94
+			'organization_settings',
95
+			'',
96
+			FormHandler::DO_NOT_SETUP_FORM,
97
+			$registry
98
+		);
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * creates and returns the actual form
104
-     *
105
-     * @return EE_Form_Section_Proper
106
-     * @throws EE_Error
107
-     * @throws InvalidArgumentException
108
-     * @throws InvalidDataTypeException
109
-     * @throws InvalidInterfaceException
110
-     * @throws ReflectionException
111
-     */
112
-    public function generate()
113
-    {
114
-        $has_sub_regions = EEM_State::instance()->count(
115
-            [['Country.CNT_ISO' => $this->organization_config->CNT_ISO]]
116
-        );
117
-        $form            = new EE_Form_Section_Proper(
118
-            [
119
-                'name'            => 'organization_settings',
120
-                'html_id'         => 'organization_settings',
121
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
122
-                'subsections'     => [
123
-                    'contact_information_hdr' => new EE_Form_Section_HTML(
124
-                        EEH_HTML::h2(
125
-                            esc_html__('Contact Information', 'event_espresso')
126
-                            . ' '
127
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
128
-                            '',
129
-                            'contact-information-hdr'
130
-                        )
131
-                    ),
132
-                    'organization_name'       => new EE_Text_Input(
133
-                        [
134
-                            'html_name'       => 'organization_name',
135
-                            'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
136
-                            'html_help_text'  => esc_html__(
137
-                                'Displayed on all emails and invoices.',
138
-                                'event_espresso'
139
-                            ),
140
-                            'default'         => $this->organization_config->get_pretty('name'),
141
-                            'required'        => false,
142
-                        ]
143
-                    ),
144
-                    'organization_address_1'  => new EE_Text_Input(
145
-                        [
146
-                            'html_name'       => 'organization_address_1',
147
-                            'html_label_text' => esc_html__('Street Address', 'event_espresso'),
148
-                            'default'         => $this->organization_config->get_pretty('address_1'),
149
-                            'required'        => false,
150
-                        ]
151
-                    ),
152
-                    'organization_address_2'  => new EE_Text_Input(
153
-                        [
154
-                            'html_name'       => 'organization_address_2',
155
-                            'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
156
-                            'default'         => $this->organization_config->get_pretty('address_2'),
157
-                            'required'        => false,
158
-                        ]
159
-                    ),
160
-                    'organization_city'       => new EE_Text_Input(
161
-                        [
162
-                            'html_name'       => 'organization_city',
163
-                            'html_class'      => 'ee-input-size--reg',
164
-                            'html_label_text' => esc_html__('City', 'event_espresso'),
165
-                            'default'         => $this->organization_config->get_pretty('city'),
166
-                            'required'        => false,
167
-                        ]
168
-                    ),
169
-                    'organization_country'    => new EE_Country_Select_Input(
170
-                        null,
171
-                        [
172
-                            EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,
173
-                            'html_name'                             => 'organization_country',
174
-                            'html_class'                            => 'ee-input-size--reg',
175
-                            'html_label_text'                       => esc_html__('Country', 'event_espresso'),
176
-                            'default'                               => $this->organization_config->CNT_ISO,
177
-                            'required'                              => false,
178
-                            'html_help_text'                        => sprintf(
179
-                                esc_html__(
180
-                                    '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
181
-                                    'event_espresso'
182
-                                ),
183
-                                '<span class="reminder-spn">',
184
-                                '</span>'
185
-                            ),
186
-                        ]
187
-                    ),
188
-                    'organization_state'      => new EE_State_Select_Input(
189
-                        null,
190
-                        [
191
-                            'html_name'       => 'organization_state',
192
-                            'html_label_text' => esc_html__('State/Province', 'event_espresso'),
193
-                            'default'         => $this->organization_config->STA_ID,
194
-                            'required'        => false,
195
-                            'html_help_text'  => empty($this->organization_config->STA_ID) || ! $has_sub_regions
196
-                                ? sprintf(
197
-                                    esc_html__(
198
-                                        'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',
199
-                                        'event_espresso'
200
-                                    ),
201
-                                    '<span class="reminder-spn">',
202
-                                    '</span>',
203
-                                    '<br />'
204
-                                )
205
-                                : '',
206
-                        ]
207
-                    ),
208
-                    'organization_zip'        => new EE_Text_Input(
209
-                        [
210
-                            'html_name'       => 'organization_zip',
211
-                            'html_class'      => 'ee-input-size--small',
212
-                            'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
213
-                            'default'         => $this->organization_config->get_pretty('zip'),
214
-                            'required'        => false,
215
-                        ]
216
-                    ),
217
-                    'organization_email'      => new EE_Text_Input(
218
-                        [
219
-                            'html_name'       => 'organization_email',
220
-                            'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
221
-                            'html_help_text'  => sprintf(
222
-                                esc_html__(
223
-                                    'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
224
-                                    'event_espresso'
225
-                                ),
226
-                                '<code>[CO_FORMATTED_EMAIL]</code>',
227
-                                '<code>[CO_EMAIL]</code>'
228
-                            ),
229
-                            'default'         => $this->organization_config->get_pretty('email'),
230
-                            'required'        => false,
231
-                        ]
232
-                    ),
233
-                    'organization_phone'      => new EE_Text_Input(
234
-                        [
235
-                            'html_name'       => 'organization_phone',
236
-                            'html_class'      => 'ee-input-size--small',
237
-                            'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
238
-                            'html_help_text'  => esc_html__(
239
-                                'The phone number for your organization.',
240
-                                'event_espresso'
241
-                            ),
242
-                            'default'         => $this->organization_config->get_pretty('phone'),
243
-                            'required'        => false,
244
-                        ]
245
-                    ),
246
-                    'organization_vat'        => new EE_Text_Input(
247
-                        [
248
-                            'html_name'       => 'organization_vat',
249
-                            'html_class'      => 'ee-input-size--reg',
250
-                            'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
251
-                            'html_help_text'  => esc_html__(
252
-                                'The VAT/Tax Number may be displayed on invoices and receipts.',
253
-                                'event_espresso'
254
-                            ),
255
-                            'default'         => $this->organization_config->get_pretty('vat'),
256
-                            'required'        => false,
257
-                        ]
258
-                    ),
259
-                    'company_logo_hdr'        => new EE_Form_Section_HTML(
260
-                        EEH_HTML::h2(
261
-                            esc_html__('Company Logo', 'event_espresso')
262
-                            . ' '
263
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
264
-                            '',
265
-                            'company-logo-hdr'
266
-                        )
267
-                    ),
268
-                    'organization_logo_url'   => new EE_Admin_File_Uploader_Input(
269
-                        [
270
-                            'html_name'       => 'organization_logo_url',
271
-                            'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
272
-                            'html_help_text'  => esc_html__(
273
-                                'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
274
-                                'event_espresso'
275
-                            ),
276
-                            'default'         => $this->organization_config->get_pretty('logo_url'),
277
-                            'required'        => false,
278
-                        ]
279
-                    ),
280
-                    'social_links_hdr'        => new EE_Form_Section_HTML(
281
-                        EEH_HTML::h2(
282
-                            esc_html__('Social Links', 'event_espresso')
283
-                            . ' '
284
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
285
-                            . EEH_HTML::br()
286
-                            . EEH_HTML::p(
287
-                                esc_html__(
288
-                                    'Enter any links to social accounts for your organization here',
289
-                                    'event_espresso'
290
-                                ),
291
-                                '',
292
-                                'description'
293
-                            ),
294
-                            '',
295
-                            'social-links-hdr'
296
-                        )
297
-                    ),
298
-                    'organization_facebook'   => new EE_Text_Input(
299
-                        [
300
-                            'html_name'             => 'organization_facebook',
301
-                            'html_label_text'       => esc_html__('Facebook', 'event_espresso'),
302
-                            'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
303
-                            'default'               => $this->organization_config->get_pretty('facebook'),
304
-                            'required'              => false,
305
-                        ]
306
-                    ),
307
-                    'organization_twitter'    => new EE_Text_Input(
308
-                        [
309
-                            'html_name'             => 'organization_twitter',
310
-                            'html_label_text'       => esc_html__('Twitter', 'event_espresso'),
311
-                            'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
312
-                            'default'               => $this->organization_config->get_pretty('twitter'),
313
-                            'required'              => false,
314
-                        ]
315
-                    ),
316
-                    'organization_linkedin'   => new EE_Text_Input(
317
-                        [
318
-                            'html_name'             => 'organization_linkedin',
319
-                            'html_label_text'       => esc_html__('LinkedIn', 'event_espresso'),
320
-                            'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
321
-                            'default'               => $this->organization_config->get_pretty('linkedin'),
322
-                            'required'              => false,
323
-                        ]
324
-                    ),
325
-                    'organization_pinterest'  => new EE_Text_Input(
326
-                        [
327
-                            'html_name'             => 'organization_pinterest',
328
-                            'html_label_text'       => esc_html__('Pinterest', 'event_espresso'),
329
-                            'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
330
-                            'default'               => $this->organization_config->get_pretty('pinterest'),
331
-                            'required'              => false,
332
-                        ]
333
-                    ),
334
-                    'organization_instagram'  => new EE_Text_Input(
335
-                        [
336
-                            'html_name'             => 'organization_instagram',
337
-                            'html_label_text'       => esc_html__('Instagram', 'event_espresso'),
338
-                            'other_html_attributes' => ' placeholder="instagram.com/handle"',
339
-                            'default'               => $this->organization_config->get_pretty('instagram'),
340
-                            'required'              => false,
341
-                        ]
342
-                    ),
343
-                ],
344
-            ]
345
-        );
346
-        if (is_main_site()) {
347
-            $form->add_subsections(
348
-                [
349
-                    'site_license_key_hdr' => new EE_Form_Section_HTML(
350
-                        EEH_HTML::h2(
351
-                            esc_html__('Your Event Espresso License Key', 'event_espresso')
352
-                            . ' '
353
-                            . EEH_HTML::span(
354
-                                EEH_Template::get_help_tab_link('site_license_key_info')
355
-                            ),
356
-                            '',
357
-                            'site-license-key-hdr'
358
-                        )
359
-                    ),
360
-                    'site_license_key'     => $this->getSiteLicenseKeyField(),
361
-                ]
362
-            );
363
-            $form->add_subsections(
364
-                [
365
-                    'uxip_optin_hdr' => new EE_Form_Section_HTML(
366
-                        $this->uxipOptinText()
367
-                    ),
368
-                    'ueip_optin'     => new EE_Checkbox_Multi_Input(
369
-                        [
370
-                            true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso'),
371
-                        ],
372
-                        [
373
-                            'html_name'       => EE_Core_Config::OPTION_NAME_UXIP,
374
-                            'html_label_text' => esc_html__(
375
-                                'UXIP Opt In?',
376
-                                'event_espresso'
377
-                            ),
378
-                            'default'         => isset($this->core_config->ee_ueip_optin)
379
-                                ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
380
-                                : false,
381
-                            'required'        => false,
382
-                        ]
383
-                    ),
384
-                ],
385
-                'organization_instagram',
386
-                false
387
-            );
388
-        }
389
-        return $form;
390
-    }
102
+	/**
103
+	 * creates and returns the actual form
104
+	 *
105
+	 * @return EE_Form_Section_Proper
106
+	 * @throws EE_Error
107
+	 * @throws InvalidArgumentException
108
+	 * @throws InvalidDataTypeException
109
+	 * @throws InvalidInterfaceException
110
+	 * @throws ReflectionException
111
+	 */
112
+	public function generate()
113
+	{
114
+		$has_sub_regions = EEM_State::instance()->count(
115
+			[['Country.CNT_ISO' => $this->organization_config->CNT_ISO]]
116
+		);
117
+		$form            = new EE_Form_Section_Proper(
118
+			[
119
+				'name'            => 'organization_settings',
120
+				'html_id'         => 'organization_settings',
121
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
122
+				'subsections'     => [
123
+					'contact_information_hdr' => new EE_Form_Section_HTML(
124
+						EEH_HTML::h2(
125
+							esc_html__('Contact Information', 'event_espresso')
126
+							. ' '
127
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
128
+							'',
129
+							'contact-information-hdr'
130
+						)
131
+					),
132
+					'organization_name'       => new EE_Text_Input(
133
+						[
134
+							'html_name'       => 'organization_name',
135
+							'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
136
+							'html_help_text'  => esc_html__(
137
+								'Displayed on all emails and invoices.',
138
+								'event_espresso'
139
+							),
140
+							'default'         => $this->organization_config->get_pretty('name'),
141
+							'required'        => false,
142
+						]
143
+					),
144
+					'organization_address_1'  => new EE_Text_Input(
145
+						[
146
+							'html_name'       => 'organization_address_1',
147
+							'html_label_text' => esc_html__('Street Address', 'event_espresso'),
148
+							'default'         => $this->organization_config->get_pretty('address_1'),
149
+							'required'        => false,
150
+						]
151
+					),
152
+					'organization_address_2'  => new EE_Text_Input(
153
+						[
154
+							'html_name'       => 'organization_address_2',
155
+							'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
156
+							'default'         => $this->organization_config->get_pretty('address_2'),
157
+							'required'        => false,
158
+						]
159
+					),
160
+					'organization_city'       => new EE_Text_Input(
161
+						[
162
+							'html_name'       => 'organization_city',
163
+							'html_class'      => 'ee-input-size--reg',
164
+							'html_label_text' => esc_html__('City', 'event_espresso'),
165
+							'default'         => $this->organization_config->get_pretty('city'),
166
+							'required'        => false,
167
+						]
168
+					),
169
+					'organization_country'    => new EE_Country_Select_Input(
170
+						null,
171
+						[
172
+							EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,
173
+							'html_name'                             => 'organization_country',
174
+							'html_class'                            => 'ee-input-size--reg',
175
+							'html_label_text'                       => esc_html__('Country', 'event_espresso'),
176
+							'default'                               => $this->organization_config->CNT_ISO,
177
+							'required'                              => false,
178
+							'html_help_text'                        => sprintf(
179
+								esc_html__(
180
+									'%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
181
+									'event_espresso'
182
+								),
183
+								'<span class="reminder-spn">',
184
+								'</span>'
185
+							),
186
+						]
187
+					),
188
+					'organization_state'      => new EE_State_Select_Input(
189
+						null,
190
+						[
191
+							'html_name'       => 'organization_state',
192
+							'html_label_text' => esc_html__('State/Province', 'event_espresso'),
193
+							'default'         => $this->organization_config->STA_ID,
194
+							'required'        => false,
195
+							'html_help_text'  => empty($this->organization_config->STA_ID) || ! $has_sub_regions
196
+								? sprintf(
197
+									esc_html__(
198
+										'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',
199
+										'event_espresso'
200
+									),
201
+									'<span class="reminder-spn">',
202
+									'</span>',
203
+									'<br />'
204
+								)
205
+								: '',
206
+						]
207
+					),
208
+					'organization_zip'        => new EE_Text_Input(
209
+						[
210
+							'html_name'       => 'organization_zip',
211
+							'html_class'      => 'ee-input-size--small',
212
+							'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
213
+							'default'         => $this->organization_config->get_pretty('zip'),
214
+							'required'        => false,
215
+						]
216
+					),
217
+					'organization_email'      => new EE_Text_Input(
218
+						[
219
+							'html_name'       => 'organization_email',
220
+							'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
221
+							'html_help_text'  => sprintf(
222
+								esc_html__(
223
+									'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
224
+									'event_espresso'
225
+								),
226
+								'<code>[CO_FORMATTED_EMAIL]</code>',
227
+								'<code>[CO_EMAIL]</code>'
228
+							),
229
+							'default'         => $this->organization_config->get_pretty('email'),
230
+							'required'        => false,
231
+						]
232
+					),
233
+					'organization_phone'      => new EE_Text_Input(
234
+						[
235
+							'html_name'       => 'organization_phone',
236
+							'html_class'      => 'ee-input-size--small',
237
+							'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
238
+							'html_help_text'  => esc_html__(
239
+								'The phone number for your organization.',
240
+								'event_espresso'
241
+							),
242
+							'default'         => $this->organization_config->get_pretty('phone'),
243
+							'required'        => false,
244
+						]
245
+					),
246
+					'organization_vat'        => new EE_Text_Input(
247
+						[
248
+							'html_name'       => 'organization_vat',
249
+							'html_class'      => 'ee-input-size--reg',
250
+							'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
251
+							'html_help_text'  => esc_html__(
252
+								'The VAT/Tax Number may be displayed on invoices and receipts.',
253
+								'event_espresso'
254
+							),
255
+							'default'         => $this->organization_config->get_pretty('vat'),
256
+							'required'        => false,
257
+						]
258
+					),
259
+					'company_logo_hdr'        => new EE_Form_Section_HTML(
260
+						EEH_HTML::h2(
261
+							esc_html__('Company Logo', 'event_espresso')
262
+							. ' '
263
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
264
+							'',
265
+							'company-logo-hdr'
266
+						)
267
+					),
268
+					'organization_logo_url'   => new EE_Admin_File_Uploader_Input(
269
+						[
270
+							'html_name'       => 'organization_logo_url',
271
+							'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
272
+							'html_help_text'  => esc_html__(
273
+								'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
274
+								'event_espresso'
275
+							),
276
+							'default'         => $this->organization_config->get_pretty('logo_url'),
277
+							'required'        => false,
278
+						]
279
+					),
280
+					'social_links_hdr'        => new EE_Form_Section_HTML(
281
+						EEH_HTML::h2(
282
+							esc_html__('Social Links', 'event_espresso')
283
+							. ' '
284
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
285
+							. EEH_HTML::br()
286
+							. EEH_HTML::p(
287
+								esc_html__(
288
+									'Enter any links to social accounts for your organization here',
289
+									'event_espresso'
290
+								),
291
+								'',
292
+								'description'
293
+							),
294
+							'',
295
+							'social-links-hdr'
296
+						)
297
+					),
298
+					'organization_facebook'   => new EE_Text_Input(
299
+						[
300
+							'html_name'             => 'organization_facebook',
301
+							'html_label_text'       => esc_html__('Facebook', 'event_espresso'),
302
+							'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
303
+							'default'               => $this->organization_config->get_pretty('facebook'),
304
+							'required'              => false,
305
+						]
306
+					),
307
+					'organization_twitter'    => new EE_Text_Input(
308
+						[
309
+							'html_name'             => 'organization_twitter',
310
+							'html_label_text'       => esc_html__('Twitter', 'event_espresso'),
311
+							'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
312
+							'default'               => $this->organization_config->get_pretty('twitter'),
313
+							'required'              => false,
314
+						]
315
+					),
316
+					'organization_linkedin'   => new EE_Text_Input(
317
+						[
318
+							'html_name'             => 'organization_linkedin',
319
+							'html_label_text'       => esc_html__('LinkedIn', 'event_espresso'),
320
+							'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
321
+							'default'               => $this->organization_config->get_pretty('linkedin'),
322
+							'required'              => false,
323
+						]
324
+					),
325
+					'organization_pinterest'  => new EE_Text_Input(
326
+						[
327
+							'html_name'             => 'organization_pinterest',
328
+							'html_label_text'       => esc_html__('Pinterest', 'event_espresso'),
329
+							'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
330
+							'default'               => $this->organization_config->get_pretty('pinterest'),
331
+							'required'              => false,
332
+						]
333
+					),
334
+					'organization_instagram'  => new EE_Text_Input(
335
+						[
336
+							'html_name'             => 'organization_instagram',
337
+							'html_label_text'       => esc_html__('Instagram', 'event_espresso'),
338
+							'other_html_attributes' => ' placeholder="instagram.com/handle"',
339
+							'default'               => $this->organization_config->get_pretty('instagram'),
340
+							'required'              => false,
341
+						]
342
+					),
343
+				],
344
+			]
345
+		);
346
+		if (is_main_site()) {
347
+			$form->add_subsections(
348
+				[
349
+					'site_license_key_hdr' => new EE_Form_Section_HTML(
350
+						EEH_HTML::h2(
351
+							esc_html__('Your Event Espresso License Key', 'event_espresso')
352
+							. ' '
353
+							. EEH_HTML::span(
354
+								EEH_Template::get_help_tab_link('site_license_key_info')
355
+							),
356
+							'',
357
+							'site-license-key-hdr'
358
+						)
359
+					),
360
+					'site_license_key'     => $this->getSiteLicenseKeyField(),
361
+				]
362
+			);
363
+			$form->add_subsections(
364
+				[
365
+					'uxip_optin_hdr' => new EE_Form_Section_HTML(
366
+						$this->uxipOptinText()
367
+					),
368
+					'ueip_optin'     => new EE_Checkbox_Multi_Input(
369
+						[
370
+							true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso'),
371
+						],
372
+						[
373
+							'html_name'       => EE_Core_Config::OPTION_NAME_UXIP,
374
+							'html_label_text' => esc_html__(
375
+								'UXIP Opt In?',
376
+								'event_espresso'
377
+							),
378
+							'default'         => isset($this->core_config->ee_ueip_optin)
379
+								? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
380
+								: false,
381
+							'required'        => false,
382
+						]
383
+					),
384
+				],
385
+				'organization_instagram',
386
+				false
387
+			);
388
+		}
389
+		return $form;
390
+	}
391 391
 
392 392
 
393
-    /**
394
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
395
-     * returns a string of HTML that can be directly echoed in a template
396
-     *
397
-     * @return string
398
-     * @throws EE_Error
399
-     * @throws InvalidArgumentException
400
-     * @throws InvalidDataTypeException
401
-     * @throws InvalidInterfaceException
402
-     * @throws LogicException
403
-     */
404
-    public function display()
405
-    {
406
-        $this->form()->enqueue_js();
407
-        return parent::display();
408
-    }
393
+	/**
394
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
395
+	 * returns a string of HTML that can be directly echoed in a template
396
+	 *
397
+	 * @return string
398
+	 * @throws EE_Error
399
+	 * @throws InvalidArgumentException
400
+	 * @throws InvalidDataTypeException
401
+	 * @throws InvalidInterfaceException
402
+	 * @throws LogicException
403
+	 */
404
+	public function display()
405
+	{
406
+		$this->form()->enqueue_js();
407
+		return parent::display();
408
+	}
409 409
 
410 410
 
411
-    /**
412
-     * handles processing the form submission
413
-     * returns true or false depending on whether the form was processed successfully or not
414
-     *
415
-     * @param array $form_data
416
-     * @return bool
417
-     * @throws InvalidFormSubmissionException
418
-     * @throws EE_Error
419
-     * @throws LogicException
420
-     * @throws InvalidArgumentException
421
-     * @throws InvalidDataTypeException
422
-     * @throws ReflectionException
423
-     */
424
-    public function process($form_data = [])
425
-    {
426
-        // process form
427
-        $valid_data = (array) parent::process($form_data);
428
-        if (empty($valid_data)) {
429
-            return false;
430
-        }
411
+	/**
412
+	 * handles processing the form submission
413
+	 * returns true or false depending on whether the form was processed successfully or not
414
+	 *
415
+	 * @param array $form_data
416
+	 * @return bool
417
+	 * @throws InvalidFormSubmissionException
418
+	 * @throws EE_Error
419
+	 * @throws LogicException
420
+	 * @throws InvalidArgumentException
421
+	 * @throws InvalidDataTypeException
422
+	 * @throws ReflectionException
423
+	 */
424
+	public function process($form_data = [])
425
+	{
426
+		// process form
427
+		$valid_data = (array) parent::process($form_data);
428
+		if (empty($valid_data)) {
429
+			return false;
430
+		}
431 431
 
432
-        if (is_main_site()) {
433
-            $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
434
-                ? sanitize_text_field($form_data['ee_site_license_key'])
435
-                : $this->network_core_config->site_license_key;
436
-        }
437
-        $this->organization_config->name         = isset($form_data['organization_name'])
438
-            ? sanitize_text_field($form_data['organization_name'])
439
-            : $this->organization_config->name;
440
-        $this->organization_config->address_1    = isset($form_data['organization_address_1'])
441
-            ? sanitize_text_field($form_data['organization_address_1'])
442
-            : $this->organization_config->address_1;
443
-        $this->organization_config->address_2    = isset($form_data['organization_address_2'])
444
-            ? sanitize_text_field($form_data['organization_address_2'])
445
-            : $this->organization_config->address_2;
446
-        $this->organization_config->city         = isset($form_data['organization_city'])
447
-            ? sanitize_text_field($form_data['organization_city'])
448
-            : $this->organization_config->city;
449
-        $this->organization_config->STA_ID       = isset($form_data['organization_state'])
450
-            ? absint($form_data['organization_state'])
451
-            : $this->organization_config->STA_ID;
452
-        $this->organization_config->CNT_ISO      = isset($form_data['organization_country'])
453
-            ? sanitize_text_field($form_data['organization_country'])
454
-            : $this->organization_config->CNT_ISO;
455
-        $this->organization_config->zip          = isset($form_data['organization_zip'])
456
-            ? sanitize_text_field($form_data['organization_zip'])
457
-            : $this->organization_config->zip;
458
-        $this->organization_config->email        = isset($form_data['organization_email'])
459
-            ? sanitize_email($form_data['organization_email'])
460
-            : $this->organization_config->email;
461
-        $this->organization_config->vat          = isset($form_data['organization_vat'])
462
-            ? sanitize_text_field($form_data['organization_vat'])
463
-            : $this->organization_config->vat;
464
-        $this->organization_config->phone        = isset($form_data['organization_phone'])
465
-            ? sanitize_text_field($form_data['organization_phone'])
466
-            : $this->organization_config->phone;
467
-        $this->organization_config->logo_url     = isset($form_data['organization_logo_url'])
468
-            ? esc_url_raw($form_data['organization_logo_url'])
469
-            : $this->organization_config->logo_url;
470
-        $this->organization_config->facebook     = isset($form_data['organization_facebook'])
471
-            ? esc_url_raw($form_data['organization_facebook'])
472
-            : $this->organization_config->facebook;
473
-        $this->organization_config->twitter      = isset($form_data['organization_twitter'])
474
-            ? esc_url_raw($form_data['organization_twitter'])
475
-            : $this->organization_config->twitter;
476
-        $this->organization_config->linkedin     = isset($form_data['organization_linkedin'])
477
-            ? esc_url_raw($form_data['organization_linkedin'])
478
-            : $this->organization_config->linkedin;
479
-        $this->organization_config->pinterest    = isset($form_data['organization_pinterest'])
480
-            ? esc_url_raw($form_data['organization_pinterest'])
481
-            : $this->organization_config->pinterest;
482
-        $this->organization_config->google       = isset($form_data['organization_google'])
483
-            ? esc_url_raw($form_data['organization_google'])
484
-            : $this->organization_config->google;
485
-        $this->organization_config->instagram    = isset($form_data['organization_instagram'])
486
-            ? esc_url_raw($form_data['organization_instagram'])
487
-            : $this->organization_config->instagram;
488
-        $this->core_config->ee_ueip_optin        = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
489
-            ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
490
-            : false;
491
-        $this->core_config->ee_ueip_has_notified = true;
432
+		if (is_main_site()) {
433
+			$this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
434
+				? sanitize_text_field($form_data['ee_site_license_key'])
435
+				: $this->network_core_config->site_license_key;
436
+		}
437
+		$this->organization_config->name         = isset($form_data['organization_name'])
438
+			? sanitize_text_field($form_data['organization_name'])
439
+			: $this->organization_config->name;
440
+		$this->organization_config->address_1    = isset($form_data['organization_address_1'])
441
+			? sanitize_text_field($form_data['organization_address_1'])
442
+			: $this->organization_config->address_1;
443
+		$this->organization_config->address_2    = isset($form_data['organization_address_2'])
444
+			? sanitize_text_field($form_data['organization_address_2'])
445
+			: $this->organization_config->address_2;
446
+		$this->organization_config->city         = isset($form_data['organization_city'])
447
+			? sanitize_text_field($form_data['organization_city'])
448
+			: $this->organization_config->city;
449
+		$this->organization_config->STA_ID       = isset($form_data['organization_state'])
450
+			? absint($form_data['organization_state'])
451
+			: $this->organization_config->STA_ID;
452
+		$this->organization_config->CNT_ISO      = isset($form_data['organization_country'])
453
+			? sanitize_text_field($form_data['organization_country'])
454
+			: $this->organization_config->CNT_ISO;
455
+		$this->organization_config->zip          = isset($form_data['organization_zip'])
456
+			? sanitize_text_field($form_data['organization_zip'])
457
+			: $this->organization_config->zip;
458
+		$this->organization_config->email        = isset($form_data['organization_email'])
459
+			? sanitize_email($form_data['organization_email'])
460
+			: $this->organization_config->email;
461
+		$this->organization_config->vat          = isset($form_data['organization_vat'])
462
+			? sanitize_text_field($form_data['organization_vat'])
463
+			: $this->organization_config->vat;
464
+		$this->organization_config->phone        = isset($form_data['organization_phone'])
465
+			? sanitize_text_field($form_data['organization_phone'])
466
+			: $this->organization_config->phone;
467
+		$this->organization_config->logo_url     = isset($form_data['organization_logo_url'])
468
+			? esc_url_raw($form_data['organization_logo_url'])
469
+			: $this->organization_config->logo_url;
470
+		$this->organization_config->facebook     = isset($form_data['organization_facebook'])
471
+			? esc_url_raw($form_data['organization_facebook'])
472
+			: $this->organization_config->facebook;
473
+		$this->organization_config->twitter      = isset($form_data['organization_twitter'])
474
+			? esc_url_raw($form_data['organization_twitter'])
475
+			: $this->organization_config->twitter;
476
+		$this->organization_config->linkedin     = isset($form_data['organization_linkedin'])
477
+			? esc_url_raw($form_data['organization_linkedin'])
478
+			: $this->organization_config->linkedin;
479
+		$this->organization_config->pinterest    = isset($form_data['organization_pinterest'])
480
+			? esc_url_raw($form_data['organization_pinterest'])
481
+			: $this->organization_config->pinterest;
482
+		$this->organization_config->google       = isset($form_data['organization_google'])
483
+			? esc_url_raw($form_data['organization_google'])
484
+			: $this->organization_config->google;
485
+		$this->organization_config->instagram    = isset($form_data['organization_instagram'])
486
+			? esc_url_raw($form_data['organization_instagram'])
487
+			: $this->organization_config->instagram;
488
+		$this->core_config->ee_ueip_optin        = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
489
+			? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
490
+			: false;
491
+		$this->core_config->ee_ueip_has_notified = true;
492 492
 
493
-        $this->registry->CFG->currency = new EE_Currency_Config(
494
-            $this->organization_config->CNT_ISO
495
-        );
496
-        /** @var EE_Country $country */
497
-        $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);
498
-        if ($country instanceof EE_Country) {
499
-            $country->set('CNT_active', 1);
500
-            $country->save();
501
-            $this->countrySubRegionDao->saveCountrySubRegions($country);
502
-        }
503
-        return true;
504
-    }
493
+		$this->registry->CFG->currency = new EE_Currency_Config(
494
+			$this->organization_config->CNT_ISO
495
+		);
496
+		/** @var EE_Country $country */
497
+		$country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);
498
+		if ($country instanceof EE_Country) {
499
+			$country->set('CNT_active', 1);
500
+			$country->save();
501
+			$this->countrySubRegionDao->saveCountrySubRegions($country);
502
+		}
503
+		return true;
504
+	}
505 505
 
506 506
 
507
-    /**
508
-     * @return string
509
-     */
510
-    private function uxipOptinText()
511
-    {
512
-        ob_start();
513
-        Stats::optinText(false);
514
-        return ob_get_clean();
515
-    }
507
+	/**
508
+	 * @return string
509
+	 */
510
+	private function uxipOptinText()
511
+	{
512
+		ob_start();
513
+		Stats::optinText(false);
514
+		return ob_get_clean();
515
+	}
516 516
 
517 517
 
518
-    /**
519
-     * Return whether the site license key has been verified or not.
520
-     *
521
-     * @return bool
522
-     */
523
-    private function licenseKeyVerified()
524
-    {
525
-        if (empty($this->network_core_config->site_license_key)) {
526
-            return false;
527
-        }
528
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
529
-        $verify_fail    = get_option($ver_option_key, false);
530
-        return $verify_fail === false
531
-               || ! empty($this->network_core_config->site_license_key);
532
-    }
518
+	/**
519
+	 * Return whether the site license key has been verified or not.
520
+	 *
521
+	 * @return bool
522
+	 */
523
+	private function licenseKeyVerified()
524
+	{
525
+		if (empty($this->network_core_config->site_license_key)) {
526
+			return false;
527
+		}
528
+		$ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
529
+		$verify_fail    = get_option($ver_option_key, false);
530
+		return $verify_fail === false
531
+			   || ! empty($this->network_core_config->site_license_key);
532
+	}
533 533
 
534 534
 
535
-    /**
536
-     * @return EE_Text_Input
537
-     */
538
-    private function getSiteLicenseKeyField()
539
-    {
540
-        $class = $this->licenseKeyVerified() ? 'ee-status-outline--success' : 'ee-status-outline--error';
541
-        return new EE_Text_Input(
542
-            [
543
-                'html_name'        => 'ee_site_license_key',
544
-                'html_id'          => 'site_license_key',
545
-                'html_class'       => 'ee-status-outline ' . $class,
546
-                'html_label_text'  => esc_html__('Support License Key', 'event_espresso'),
547
-                /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
548
-                'html_help_text'   => sprintf(
549
-                    esc_html__(
550
-                        'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
551
-                        'event_espresso'
552
-                    ),
553
-                    '<strong>',
554
-                    '</strong>'
555
-                ),
556
-                /** phpcs:enable */
557
-                'default'          => $this->network_core_config->site_license_key ?? '',
558
-                'required'         => false,
559
-                'form_html_filter' => new VsprintfFilter(
560
-                    '%2$s %1$s',
561
-                    [$this->getValidationIndicator()]
562
-                ),
563
-            ]
564
-        );
565
-    }
535
+	/**
536
+	 * @return EE_Text_Input
537
+	 */
538
+	private function getSiteLicenseKeyField()
539
+	{
540
+		$class = $this->licenseKeyVerified() ? 'ee-status-outline--success' : 'ee-status-outline--error';
541
+		return new EE_Text_Input(
542
+			[
543
+				'html_name'        => 'ee_site_license_key',
544
+				'html_id'          => 'site_license_key',
545
+				'html_class'       => 'ee-status-outline ' . $class,
546
+				'html_label_text'  => esc_html__('Support License Key', 'event_espresso'),
547
+				/** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
548
+				'html_help_text'   => sprintf(
549
+					esc_html__(
550
+						'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
551
+						'event_espresso'
552
+					),
553
+					'<strong>',
554
+					'</strong>'
555
+				),
556
+				/** phpcs:enable */
557
+				'default'          => $this->network_core_config->site_license_key ?? '',
558
+				'required'         => false,
559
+				'form_html_filter' => new VsprintfFilter(
560
+					'%2$s %1$s',
561
+					[$this->getValidationIndicator()]
562
+				),
563
+			]
564
+		);
565
+	}
566 566
 
567 567
 
568
-    /**
569
-     * @return string
570
-     */
571
-    private function getValidationIndicator()
572
-    {
573
-        $class = $this->licenseKeyVerified() ? 'ee-status--success' : 'ee-status--error';
574
-        return '<span class="dashicons dashicons-admin-network ' . $class . '"></span>';
575
-    }
568
+	/**
569
+	 * @return string
570
+	 */
571
+	private function getValidationIndicator()
572
+	{
573
+		$class = $this->licenseKeyVerified() ? 'ee-status--success' : 'ee-status--error';
574
+		return '<span class="dashicons dashicons-admin-network ' . $class . '"></span>';
575
+	}
576 576
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Indentation   +1419 added lines, -1419 removed lines patch added patch discarded remove patch
@@ -19,1436 +19,1436 @@
 block discarded – undo
19 19
  */
20 20
 class General_Settings_Admin_Page extends EE_Admin_Page
21 21
 {
22
-    /**
23
-     * @var EE_Core_Config
24
-     */
25
-    public $core_config;
26
-
27
-
28
-    /**
29
-     * Initialize basic properties.
30
-     */
31
-    protected function _init_page_props()
32
-    {
33
-        $this->page_slug        = GEN_SET_PG_SLUG;
34
-        $this->page_label       = GEN_SET_LABEL;
35
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
36
-        $this->_admin_base_path = GEN_SET_ADMIN;
37
-    }
38
-
39
-
40
-    /**
41
-     * Set ajax hooks
42
-     */
43
-    protected function _ajax_hooks()
44
-    {
45
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
46
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
47
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
48
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
49
-    }
50
-
51
-
52
-    /**
53
-     * More page properties initialization.
54
-     */
55
-    protected function _define_page_props()
56
-    {
57
-        $this->_admin_page_title = GEN_SET_LABEL;
58
-        $this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
59
-    }
60
-
61
-
62
-    /**
63
-     * Set page routes property.
64
-     */
65
-    protected function _set_page_routes()
66
-    {
67
-        $this->_page_routes = [
68
-            'critical_pages'                => [
69
-                'func'       => '_espresso_page_settings',
70
-                'capability' => 'manage_options',
71
-            ],
72
-            'update_espresso_page_settings' => [
73
-                'func'       => '_update_espresso_page_settings',
74
-                'capability' => 'manage_options',
75
-                'noheader'   => true,
76
-            ],
77
-            'default'                       => [
78
-                'func'       => '_your_organization_settings',
79
-                'capability' => 'manage_options',
80
-            ],
81
-
82
-            'update_your_organization_settings' => [
83
-                'func'       => '_update_your_organization_settings',
84
-                'capability' => 'manage_options',
85
-                'noheader'   => true,
86
-            ],
87
-
88
-            'admin_option_settings' => [
89
-                'func'       => '_admin_option_settings',
90
-                'capability' => 'manage_options',
91
-            ],
92
-
93
-            'update_admin_option_settings' => [
94
-                'func'       => '_update_admin_option_settings',
95
-                'capability' => 'manage_options',
96
-                'noheader'   => true,
97
-            ],
98
-
99
-            'country_settings' => [
100
-                'func'       => '_country_settings',
101
-                'capability' => 'manage_options',
102
-            ],
103
-
104
-            'update_country_settings' => [
105
-                'func'       => '_update_country_settings',
106
-                'capability' => 'manage_options',
107
-                'noheader'   => true,
108
-            ],
109
-
110
-            'display_country_settings' => [
111
-                'func'       => 'display_country_settings',
112
-                'capability' => 'manage_options',
113
-                'noheader'   => true,
114
-            ],
115
-
116
-            'add_new_state' => [
117
-                'func'       => 'add_new_state',
118
-                'capability' => 'manage_options',
119
-                'noheader'   => true,
120
-            ],
121
-
122
-            'delete_state'            => [
123
-                'func'       => 'delete_state',
124
-                'capability' => 'manage_options',
125
-                'noheader'   => true,
126
-            ],
127
-            'privacy_settings'        => [
128
-                'func'       => 'privacySettings',
129
-                'capability' => 'manage_options',
130
-            ],
131
-            'update_privacy_settings' => [
132
-                'func'               => 'updatePrivacySettings',
133
-                'capability'         => 'manage_options',
134
-                'noheader'           => true,
135
-                'headers_sent_route' => 'privacy_settings',
136
-            ],
137
-        ];
138
-    }
139
-
140
-
141
-    /**
142
-     * Set page configuration property
143
-     */
144
-    protected function _set_page_config()
145
-    {
146
-        $this->_page_config = [
147
-            'critical_pages'        => [
148
-                'nav'           => [
149
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
150
-                    'icon' => 'dashicons-warning',
151
-                    'order' => 50,
152
-                ],
153
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
-                'help_tabs'     => [
155
-                    'general_settings_critical_pages_help_tab' => [
156
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
-                        'filename' => 'general_settings_critical_pages',
158
-                    ],
159
-                ],
160
-                'require_nonce' => false,
161
-            ],
162
-            'default'               => [
163
-                'nav'           => [
164
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
165
-                    'icon' => 'dashicons-admin-home',
166
-                    'order' => 20,
167
-                ],
168
-                'help_tabs'     => [
169
-                    'general_settings_your_organization_help_tab' => [
170
-                        'title'    => esc_html__('Your Organization', 'event_espresso'),
171
-                        'filename' => 'general_settings_your_organization',
172
-                    ],
173
-                ],
174
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
175
-                'require_nonce' => false,
176
-            ],
177
-            'admin_option_settings' => [
178
-                'nav'           => [
179
-                    'label' => esc_html__('Admin Options', 'event_espresso'),
180
-                    'icon' => 'dashicons-admin-settings',
181
-                    'order' => 60,
182
-                ],
183
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
184
-                'help_tabs'     => [
185
-                    'general_settings_admin_options_help_tab' => [
186
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
187
-                        'filename' => 'general_settings_admin_options',
188
-                    ],
189
-                ],
190
-                'require_nonce' => false,
191
-            ],
192
-            'country_settings'      => [
193
-                'nav'           => [
194
-                    'label' => esc_html__('Countries', 'event_espresso'),
195
-                    'icon' => 'dashicons-admin-site',
196
-                    'order' => 70,
197
-                ],
198
-                'help_tabs'     => [
199
-                    'general_settings_countries_help_tab' => [
200
-                        'title'    => esc_html__('Countries', 'event_espresso'),
201
-                        'filename' => 'general_settings_countries',
202
-                    ],
203
-                ],
204
-                'require_nonce' => false,
205
-            ],
206
-            'privacy_settings'      => [
207
-                'nav'           => [
208
-                    'label' => esc_html__('Privacy', 'event_espresso'),
209
-                    'icon' => 'dashicons-privacy',
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
-        $this->core_config = EE_Registry::instance()->CFG->core;
247
-
248
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
249
-            esc_html__(
250
-                '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.',
251
-                'event_espresso'
252
-            )
253
-        );
254
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
255
-            esc_html__(
256
-                'An error occurred! Please refresh the page and try again.',
257
-                'event_espresso'
258
-            )
259
-        );
260
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
261
-            esc_html__(
262
-                'Are you sure you want to delete this State / Province?',
263
-                'event_espresso'
264
-            )
265
-        );
266
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
267
-            'admin-ajax.php?page=espresso_general_settings',
268
-            is_ssl() ? 'https://' : 'http://'
269
-        );
270
-    }
271
-
272
-
273
-    public function admin_notices()
274
-    {
275
-    }
276
-
277
-
278
-    public function admin_footer_scripts()
279
-    {
280
-    }
281
-
282
-
283
-    /**
284
-     * Enqueue scripts and styles for the default route.
285
-     */
286
-    public function load_scripts_styles_default()
287
-    {
288
-        // styles
289
-        wp_enqueue_style('thickbox');
290
-        // scripts
291
-        wp_enqueue_script('media-upload');
292
-        wp_enqueue_script('thickbox');
293
-        wp_register_script(
294
-            'organization_settings',
295
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
296
-            ['jquery', 'media-upload', 'thickbox'],
297
-            EVENT_ESPRESSO_VERSION,
298
-            true
299
-        );
300
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
301
-        wp_enqueue_script('organization_settings');
302
-        wp_enqueue_style('organization-css');
303
-        $confirm_image_delete = [
304
-            'text' => wp_strip_all_tags(
305
-                esc_html__(
306
-                    'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
307
-                    'event_espresso'
308
-                )
309
-            ),
310
-        ];
311
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
312
-    }
313
-
314
-
315
-    /**
316
-     * Enqueue scripts and styles for the country settings route.
317
-     */
318
-    public function load_scripts_styles_country_settings()
319
-    {
320
-        // scripts
321
-        wp_register_script(
322
-            'gen_settings_countries',
323
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
324
-            ['ee_admin_js'],
325
-            EVENT_ESPRESSO_VERSION,
326
-            true
327
-        );
328
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
329
-        wp_enqueue_script('gen_settings_countries');
330
-        wp_enqueue_style('organization-css');
331
-    }
332
-
333
-
334
-    /*************        Espresso Pages        *************/
335
-    /**
336
-     * _espresso_page_settings
337
-     *
338
-     * @throws EE_Error
339
-     * @throws DomainException
340
-     * @throws DomainException
341
-     * @throws InvalidDataTypeException
342
-     * @throws InvalidArgumentException
343
-     */
344
-    protected function _espresso_page_settings()
345
-    {
346
-        // Check to make sure all of the main pages are set up properly,
347
-        // if not create the default pages and display an admin notice
348
-        EEH_Activation::verify_default_pages_exist();
349
-        $this->_transient_garbage_collection();
350
-
351
-        $this->_template_args['values'] = $this->_yes_no_values;
352
-
353
-        $this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
354
-        $this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
355
-            ? get_post($this->core_config->reg_page_id)
356
-            : false;
357
-
358
-        $this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
359
-        $this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
360
-            ? get_post($this->core_config->txn_page_id)
361
-            : false;
362
-
363
-        $this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
364
-        $this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
365
-            ? get_post($this->core_config->thank_you_page_id)
366
-            : false;
367
-
368
-        $this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
369
-        $this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
370
-            ? get_post($this->core_config->cancel_page_id)
371
-            : false;
372
-
373
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
374
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
375
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
376
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
377
-            $this->_template_args,
378
-            true
379
-        );
380
-        $this->display_admin_page_with_sidebar();
381
-    }
382
-
383
-
384
-    /**
385
-     * Handler for updating espresso page settings.
386
-     *
387
-     * @throws EE_Error
388
-     */
389
-    protected function _update_espresso_page_settings()
390
-    {
391
-        $this->core_config = EE_Registry::instance()->CFG->core;
392
-        // capture incoming request data && set page IDs
393
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
394
-            'reg_page_id',
395
-            $this->core_config->reg_page_id,
396
-            DataType::INT
397
-        );
398
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
399
-            'txn_page_id',
400
-            $this->core_config->txn_page_id,
401
-            DataType::INT
402
-        );
403
-        $this->core_config->thank_you_page_id = $this->request->getRequestParam(
404
-            'thank_you_page_id',
405
-            $this->core_config->thank_you_page_id,
406
-            DataType::INT
407
-        );
408
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
409
-            'cancel_page_id',
410
-            $this->core_config->cancel_page_id,
411
-            DataType::INT
412
-        );
413
-
414
-        $this->core_config = apply_filters(
415
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
416
-            $this->core_config,
417
-            $this->request->requestParams()
418
-        );
419
-
420
-        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
421
-        $this->_redirect_after_action(
422
-            $this->_update_espresso_configuration(
423
-                $what,
424
-                $this->core_config,
425
-                __FILE__,
426
-                __FUNCTION__,
427
-                __LINE__
428
-            ),
429
-            $what,
430
-            '',
431
-            [
432
-                'action' => 'critical_pages',
433
-            ],
434
-            true
435
-        );
436
-    }
437
-
438
-
439
-    /*************        Your Organization        *************/
440
-
441
-
442
-    /**
443
-     * @throws DomainException
444
-     * @throws EE_Error
445
-     * @throws InvalidArgumentException
446
-     * @throws InvalidDataTypeException
447
-     * @throws InvalidInterfaceException
448
-     */
449
-    protected function _your_organization_settings()
450
-    {
451
-        $this->_template_args['admin_page_content'] = '';
452
-        try {
453
-            /** @var OrganizationSettings $organization_settings_form */
454
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
455
-
456
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
457
-                $organization_settings_form->display(),
458
-                '',
459
-                'padding'
460
-            );
461
-        } catch (Exception $e) {
462
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
463
-        }
464
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
465
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
466
-        $this->display_admin_page_with_sidebar();
467
-    }
468
-
469
-
470
-    /**
471
-     * Handler for updating organization settings.
472
-     *
473
-     * @throws EE_Error
474
-     */
475
-    protected function _update_your_organization_settings()
476
-    {
477
-        try {
478
-            /** @var OrganizationSettings $organization_settings_form */
479
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
480
-
481
-            $success = $organization_settings_form->process($this->request->requestParams());
482
-
483
-            EE_Registry::instance()->CFG = apply_filters(
484
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
485
-                EE_Registry::instance()->CFG
486
-            );
487
-        } catch (Exception $e) {
488
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
489
-            $success = false;
490
-        }
491
-
492
-        if ($success) {
493
-            $success = $this->_update_espresso_configuration(
494
-                esc_html__('Your Organization Settings', 'event_espresso'),
495
-                EE_Registry::instance()->CFG,
496
-                __FILE__,
497
-                __FUNCTION__,
498
-                __LINE__
499
-            );
500
-        }
501
-
502
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
503
-    }
504
-
505
-
506
-
507
-    /*************        Admin Options        *************/
508
-
509
-
510
-    /**
511
-     * _admin_option_settings
512
-     *
513
-     * @throws EE_Error
514
-     * @throws LogicException
515
-     */
516
-    protected function _admin_option_settings()
517
-    {
518
-        $this->_template_args['admin_page_content'] = '';
519
-        try {
520
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
521
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
522
-            $this->_template_args['values'] = $this->_yes_no_values;
523
-            // also need to account for the do_action that was in the old template
524
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
525
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
526
-                $admin_options_settings_form->display(),
527
-                '',
528
-                'padding'
529
-            );
530
-        } catch (Exception $e) {
531
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
532
-        }
533
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
534
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
535
-        $this->display_admin_page_with_sidebar();
536
-    }
537
-
538
-
539
-    /**
540
-     * _update_admin_option_settings
541
-     *
542
-     * @throws EE_Error
543
-     * @throws InvalidDataTypeException
544
-     * @throws InvalidFormSubmissionException
545
-     * @throws InvalidArgumentException
546
-     * @throws LogicException
547
-     */
548
-    protected function _update_admin_option_settings()
549
-    {
550
-        try {
551
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
552
-            $admin_options_settings_form->process(
553
-                $this->request->getRequestParam(
554
-                    $admin_options_settings_form->slug(),
555
-                    [],
556
-                    DataType::STRING,
557
-                    true
558
-                )
559
-            );
560
-            EE_Registry::instance()->CFG->admin = apply_filters(
561
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
562
-                EE_Registry::instance()->CFG->admin
563
-            );
564
-        } catch (Exception $e) {
565
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
566
-        }
567
-        $this->_redirect_after_action(
568
-            apply_filters(
569
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
570
-                $this->_update_espresso_configuration(
571
-                    esc_html__('Admin Options', 'event_espresso'),
572
-                    EE_Registry::instance()->CFG->admin,
573
-                    __FILE__,
574
-                    __FUNCTION__,
575
-                    __LINE__
576
-                )
577
-            ),
578
-            esc_html__('Admin Options', 'event_espresso'),
579
-            'updated',
580
-            ['action' => 'admin_option_settings']
581
-        );
582
-    }
583
-
584
-
585
-    /*************        Countries        *************/
586
-
587
-
588
-    /**
589
-     * @param string|null $default
590
-     * @return string
591
-     */
592
-    protected function getCountryISO(?string $default = null): string
593
-    {
594
-        $default = $default ?? $this->getCountryIsoForSite();
595
-        $CNT_ISO = $this->request->getRequestParam('country', $default);
596
-        $CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
597
-        return strtoupper($CNT_ISO);
598
-    }
599
-
600
-
601
-    /**
602
-     * @return string
603
-     */
604
-    protected function getCountryIsoForSite(): string
605
-    {
606
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
607
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
608
-            : 'US';
609
-    }
610
-
611
-
612
-    /**
613
-     * @param string          $CNT_ISO
614
-     * @param EE_Country|null $country
615
-     * @return EE_Base_Class|EE_Country
616
-     * @throws EE_Error
617
-     * @throws InvalidArgumentException
618
-     * @throws InvalidDataTypeException
619
-     * @throws InvalidInterfaceException
620
-     * @throws ReflectionException
621
-     */
622
-    protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
623
-    {
624
-        /** @var EE_Country $country */
625
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
626
-            ? $country
627
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
628
-    }
629
-
630
-
631
-    /**
632
-     * Output Country Settings view.
633
-     *
634
-     * @throws DomainException
635
-     * @throws EE_Error
636
-     * @throws InvalidArgumentException
637
-     * @throws InvalidDataTypeException
638
-     * @throws InvalidInterfaceException
639
-     * @throws ReflectionException
640
-     */
641
-    protected function _country_settings()
642
-    {
643
-        $CNT_ISO = $this->getCountryISO();
644
-
645
-        $this->_template_args['values']    = $this->_yes_no_values;
646
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
647
-            EE_Question::new_instance(
648
-                [
649
-                  'QST_ID'           => 0,
650
-                  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
651
-                  'QST_system'       => 'admin-country',
652
-                ]
653
-            ),
654
-            EE_Answer::new_instance(
655
-                [
656
-                    'ANS_ID'    => 0,
657
-                    'ANS_value' => $CNT_ISO,
658
-                ]
659
-            ),
660
-            [
661
-                'input_id'       => 'country',
662
-                'input_name'     => 'country',
663
-                'input_prefix'   => '',
664
-                'append_qstn_id' => false,
665
-            ]
666
-        );
667
-
668
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
669
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
670
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
671
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
672
-            $country->ID(),
673
-            $country
674
-        );
675
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
676
-            $country->ID(),
677
-            $country
678
-        );
679
-        $this->_template_args['CNT_name_for_site']        = $country->name();
680
-
681
-        $this->_set_add_edit_form_tags('update_country_settings');
682
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
683
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
684
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
685
-            $this->_template_args,
686
-            true
687
-        );
688
-        $this->display_admin_page_with_no_sidebar();
689
-    }
690
-
691
-
692
-    /**
693
-     * @param string          $CNT_ISO
694
-     * @param EE_Country|null $country
695
-     * @return string
696
-     * @throws DomainException
697
-     * @throws EE_Error
698
-     * @throws InvalidArgumentException
699
-     * @throws InvalidDataTypeException
700
-     * @throws InvalidInterfaceException
701
-     * @throws ReflectionException
702
-     */
703
-    public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
704
-    {
705
-        $CNT_ISO          = $this->getCountryISO($CNT_ISO);
706
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
707
-
708
-        if (! $CNT_ISO) {
709
-            return '';
710
-        }
711
-
712
-        // for ajax
713
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
714
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
715
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
716
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
717
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
718
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
719
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
720
-
721
-        $country_input_types            = [
722
-            'CNT_active'      => [
723
-                'type'             => 'RADIO_BTN',
724
-                'input_name'       => "cntry[$CNT_ISO]",
725
-                'class'            => '',
726
-                'options'          => $this->_yes_no_values,
727
-                'use_desc_4_label' => true,
728
-            ],
729
-            'CNT_ISO'         => [
730
-                'type'       => 'TEXT',
731
-                'input_name' => "cntry[$CNT_ISO]",
732
-                'class'      => 'ee-input-width--small',
733
-            ],
734
-            'CNT_ISO3'        => [
735
-                'type'       => 'TEXT',
736
-                'input_name' => "cntry[$CNT_ISO]",
737
-                'class'      => 'ee-input-width--small',
738
-            ],
739
-            // 'RGN_ID'          => [
740
-            //     'type'       => 'TEXT',
741
-            //     'input_name' => "cntry[$CNT_ISO]",
742
-            //     'class'      => 'ee-input-width--small',
743
-            // ],
744
-            'CNT_name'        => [
745
-                'type'       => 'TEXT',
746
-                'input_name' => "cntry[$CNT_ISO]",
747
-                'class'      => 'ee-input-width--big',
748
-            ],
749
-            'CNT_cur_code'    => [
750
-                'type'       => 'TEXT',
751
-                'input_name' => "cntry[$CNT_ISO]",
752
-                'class'      => 'ee-input-width--small',
753
-                'disabled'   => $CNT_cur_disabled,
754
-            ],
755
-            'CNT_cur_single'  => [
756
-                'type'       => 'TEXT',
757
-                'input_name' => "cntry[$CNT_ISO]",
758
-                'class'      => 'ee-input-width--reg',
759
-                'disabled'   => $CNT_cur_disabled,
760
-            ],
761
-            'CNT_cur_plural'  => [
762
-                'type'       => 'TEXT',
763
-                'input_name' => "cntry[$CNT_ISO]",
764
-                'class'      => 'ee-input-width--reg',
765
-                'disabled'   => $CNT_cur_disabled,
766
-            ],
767
-            'CNT_cur_sign'    => [
768
-                'type'         => 'TEXT',
769
-                'input_name'   => "cntry[$CNT_ISO]",
770
-                'class'        => 'ee-input-width--small',
771
-                'htmlentities' => false,
772
-                'disabled'     => $CNT_cur_disabled,
773
-            ],
774
-            'CNT_cur_sign_b4' => [
775
-                'type'             => 'RADIO_BTN',
776
-                'input_name'       => "cntry[$CNT_ISO]",
777
-                'class'            => '',
778
-                'options'          => $this->_yes_no_values,
779
-                'use_desc_4_label' => true,
780
-                'disabled'         => $CNT_cur_disabled,
781
-            ],
782
-            'CNT_cur_dec_plc' => [
783
-                'type'       => 'RADIO_BTN',
784
-                'input_name' => "cntry[$CNT_ISO]",
785
-                'class'      => '',
786
-                'options'    => [
787
-                    ['id' => 0, 'text' => ''],
788
-                    ['id' => 1, 'text' => ''],
789
-                    ['id' => 2, 'text' => ''],
790
-                    ['id' => 3, 'text' => ''],
791
-                ],
792
-                'disabled'   => $CNT_cur_disabled,
793
-            ],
794
-            'CNT_cur_dec_mrk' => [
795
-                'type'             => 'RADIO_BTN',
796
-                'input_name'       => "cntry[$CNT_ISO]",
797
-                'class'            => '',
798
-                'options'          => [
799
-                    [
800
-                        'id'   => ',',
801
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
802
-                    ],
803
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
804
-                ],
805
-                'use_desc_4_label' => true,
806
-                'disabled'         => $CNT_cur_disabled,
807
-            ],
808
-            'CNT_cur_thsnds'  => [
809
-                'type'             => 'RADIO_BTN',
810
-                'input_name'       => "cntry[$CNT_ISO]",
811
-                'class'            => '',
812
-                'options'          => [
813
-                    [
814
-                        'id'   => ',',
815
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
816
-                    ],
817
-                    [
818
-                        'id'   => '.',
819
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
820
-                    ],
821
-                    [
822
-                        'id'   => '&nbsp;',
823
-                        'text' => esc_html__('(space)', 'event_espresso'),
824
-                    ],
825
-                ],
826
-                'use_desc_4_label' => true,
827
-                'disabled'         => $CNT_cur_disabled,
828
-            ],
829
-            'CNT_tel_code'    => [
830
-                'type'       => 'TEXT',
831
-                'input_name' => "cntry[$CNT_ISO]",
832
-                'class'      => 'ee-input-width--small',
833
-            ],
834
-            'CNT_is_EU'       => [
835
-                'type'             => 'RADIO_BTN',
836
-                'input_name'       => "cntry[$CNT_ISO]",
837
-                'class'            => '',
838
-                'options'          => $this->_yes_no_values,
839
-                'use_desc_4_label' => true,
840
-            ],
841
-        ];
842
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
843
-            $country,
844
-            $country_input_types
845
-        );
846
-        $country_details_settings       = EEH_Template::display_template(
847
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
848
-            $this->_template_args,
849
-            true
850
-        );
851
-
852
-        if (defined('DOING_AJAX')) {
853
-            $notices = EE_Error::get_notices(false, false, false);
854
-            echo wp_json_encode(
855
-                [
856
-                    'return_data' => $country_details_settings,
857
-                    'success'     => $notices['success'],
858
-                    'errors'      => $notices['errors'],
859
-                ]
860
-            );
861
-            die();
862
-        }
863
-        return $country_details_settings;
864
-    }
865
-
866
-
867
-    /**
868
-     * @param string          $CNT_ISO
869
-     * @param EE_Country|null $country
870
-     * @return string
871
-     * @throws DomainException
872
-     * @throws EE_Error
873
-     * @throws InvalidArgumentException
874
-     * @throws InvalidDataTypeException
875
-     * @throws InvalidInterfaceException
876
-     * @throws ReflectionException
877
-     */
878
-    public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
879
-    {
880
-        $CNT_ISO = $this->getCountryISO($CNT_ISO);
881
-        if (! $CNT_ISO) {
882
-            return '';
883
-        }
884
-        // for ajax
885
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
886
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
887
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
888
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
889
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
890
-        if (empty($states)) {
891
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
892
-            $countrySubRegionDao = $this->loader->getShared(
893
-                'EventEspresso\core\services\address\CountrySubRegionDao'
894
-            );
895
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
896
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
897
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
898
-                    $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
899
-                }
900
-            }
901
-        }
902
-        if (is_array($states)) {
903
-            foreach ($states as $STA_ID => $state) {
904
-                if ($state instanceof EE_State) {
905
-                    $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
906
-                        $state,
907
-                        [
908
-                            'STA_abbrev' => [
909
-                                'type'             => 'TEXT',
910
-                                'label'            => esc_html__('Code', 'event_espresso'),
911
-                                'input_name'       => "states[$STA_ID]",
912
-                                'class'            => 'ee-input-width--tiny',
913
-                                'add_mobile_label' => true,
914
-                            ],
915
-                            'STA_name'   => [
916
-                                'type'             => 'TEXT',
917
-                                'label'            => esc_html__('Name', 'event_espresso'),
918
-                                'input_name'       => "states[$STA_ID]",
919
-                                'class'            => 'ee-input-width--big',
920
-                                'add_mobile_label' => true,
921
-                            ],
922
-                            'STA_active' => [
923
-                                'type'             => 'RADIO_BTN',
924
-                                'label'            => esc_html__(
925
-                                    'State Appears in Dropdown Select Lists',
926
-                                    'event_espresso'
927
-                                ),
928
-                                'input_name'       => "states[$STA_ID]",
929
-                                'options'          => $this->_yes_no_values,
930
-                                'use_desc_4_label' => true,
931
-                                'add_mobile_label' => true,
932
-                            ],
933
-                        ]
934
-                    );
935
-
936
-                    $delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
937
-                        [
938
-                            'action'     => 'delete_state',
939
-                            'STA_ID'     => $STA_ID,
940
-                            'CNT_ISO'    => $CNT_ISO,
941
-                            'STA_abbrev' => $state->abbrev(),
942
-                        ],
943
-                        GEN_SET_ADMIN_URL
944
-                    );
945
-
946
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
947
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
948
-                }
949
-            }
950
-        } else {
951
-            $this->_template_args['states'] = false;
952
-        }
953
-
954
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
955
-            ['action' => 'add_new_state'],
956
-            GEN_SET_ADMIN_URL
957
-        );
958
-
959
-        $state_details_settings = EEH_Template::display_template(
960
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
961
-            $this->_template_args,
962
-            true
963
-        );
964
-
965
-        if (defined('DOING_AJAX')) {
966
-            $notices = EE_Error::get_notices(false, false, false);
967
-            echo wp_json_encode(
968
-                [
969
-                    'return_data' => $state_details_settings,
970
-                    'success'     => $notices['success'],
971
-                    'errors'      => $notices['errors'],
972
-                ]
973
-            );
974
-            die();
975
-        }
976
-        return $state_details_settings;
977
-    }
978
-
979
-
980
-    /**
981
-     * @return void
982
-     * @throws EE_Error
983
-     * @throws InvalidArgumentException
984
-     * @throws InvalidDataTypeException
985
-     * @throws InvalidInterfaceException
986
-     * @throws ReflectionException
987
-     */
988
-    public function add_new_state()
989
-    {
990
-        $success = true;
991
-        $CNT_ISO = $this->getCountryISO('');
992
-        if (! $CNT_ISO) {
993
-            EE_Error::add_error(
994
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
995
-                __FILE__,
996
-                __FUNCTION__,
997
-                __LINE__
998
-            );
999
-            $success = false;
1000
-        }
1001
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1002
-        if (! $STA_abbrev) {
1003
-            EE_Error::add_error(
1004
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1005
-                __FILE__,
1006
-                __FUNCTION__,
1007
-                __LINE__
1008
-            );
1009
-            $success = false;
1010
-        }
1011
-        $STA_name = $this->request->getRequestParam('STA_name');
1012
-        if (! $STA_name) {
1013
-            EE_Error::add_error(
1014
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1015
-                __FILE__,
1016
-                __FUNCTION__,
1017
-                __LINE__
1018
-            );
1019
-            $success = false;
1020
-        }
1021
-
1022
-        if ($success) {
1023
-            $cols_n_values = [
1024
-                'CNT_ISO'    => $CNT_ISO,
1025
-                'STA_abbrev' => $STA_abbrev,
1026
-                'STA_name'   => $STA_name,
1027
-                'STA_active' => true,
1028
-            ];
1029
-            $success       = EEM_State::instance()->insert($cols_n_values);
1030
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1031
-        }
1032
-
1033
-        if (defined('DOING_AJAX')) {
1034
-            $notices = EE_Error::get_notices(false, false, false);
1035
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1036
-            die();
1037
-        }
1038
-        $this->_redirect_after_action(
1039
-            $success,
1040
-            esc_html__('State', 'event_espresso'),
1041
-            'added',
1042
-            ['action' => 'country_settings']
1043
-        );
1044
-    }
1045
-
1046
-
1047
-    /**
1048
-     * @return void
1049
-     * @throws EE_Error
1050
-     * @throws InvalidArgumentException
1051
-     * @throws InvalidDataTypeException
1052
-     * @throws InvalidInterfaceException
1053
-     * @throws ReflectionException
1054
-     */
1055
-    public function delete_state()
1056
-    {
1057
-        $CNT_ISO    = $this->getCountryISO();
1058
-        $STA_ID     = $this->request->getRequestParam('STA_ID');
1059
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1060
-
1061
-        if (! $STA_ID) {
1062
-            EE_Error::add_error(
1063
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1064
-                __FILE__,
1065
-                __FUNCTION__,
1066
-                __LINE__
1067
-            );
1068
-            return;
1069
-        }
1070
-
1071
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1072
-        if ($success !== false) {
1073
-            do_action(
1074
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1075
-                $CNT_ISO,
1076
-                $STA_ID,
1077
-                ['STA_abbrev' => $STA_abbrev]
1078
-            );
1079
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1080
-        }
1081
-        if (defined('DOING_AJAX')) {
1082
-            $notices                = EE_Error::get_notices(false);
1083
-            $notices['return_data'] = true;
1084
-            echo wp_json_encode($notices);
1085
-            die();
1086
-        }
1087
-        $this->_redirect_after_action(
1088
-            $success,
1089
-            esc_html__('State', 'event_espresso'),
1090
-            'deleted',
1091
-            ['action' => 'country_settings']
1092
-        );
1093
-    }
1094
-
1095
-
1096
-    /**
1097
-     * @return void
1098
-     * @throws EE_Error
1099
-     * @throws InvalidArgumentException
1100
-     * @throws InvalidDataTypeException
1101
-     * @throws InvalidInterfaceException
1102
-     * @throws ReflectionException
1103
-     */
1104
-    protected function _update_country_settings()
1105
-    {
1106
-        $CNT_ISO = $this->getCountryISO();
1107
-        if (! $CNT_ISO) {
1108
-            EE_Error::add_error(
1109
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1110
-                __FILE__,
1111
-                __FUNCTION__,
1112
-                __LINE__
1113
-            );
1114
-            return;
1115
-        }
1116
-
1117
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1118
-
1119
-        $cols_n_values                    = [];
1120
-        $cols_n_values['CNT_ISO3']        = strtoupper(
1121
-            $this->request->getRequestParam('cntry', '', $country->ISO3())
1122
-        );
1123
-        $cols_n_values['CNT_name']        = $this->request->getRequestParam(
1124
-            "cntry[$CNT_ISO][CNT_name]",
1125
-            $country->name()
1126
-        );
1127
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1128
-            $this->request->getRequestParam(
1129
-                "cntry[$CNT_ISO][CNT_cur_code]",
1130
-                $country->currency_code()
1131
-            )
1132
-        );
1133
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1134
-            "cntry[$CNT_ISO][CNT_cur_single]",
1135
-            $country->currency_name_single()
1136
-        );
1137
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1138
-            "cntry[$CNT_ISO][CNT_cur_plural]",
1139
-            $country->currency_name_plural()
1140
-        );
1141
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1142
-            "cntry[$CNT_ISO][CNT_cur_sign]",
1143
-            $country->currency_sign()
1144
-        );
1145
-        $cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1146
-            "cntry[$CNT_ISO][CNT_cur_sign_b4]",
1147
-            $country->currency_sign_before(),
1148
-            DataType::BOOL
1149
-        );
1150
-        $cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1151
-            "cntry[$CNT_ISO][CNT_cur_dec_plc]",
1152
-            $country->currency_decimal_places()
1153
-        );
1154
-        $cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1155
-            "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1156
-            $country->currency_decimal_mark()
1157
-        );
1158
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1159
-            "cntry[$CNT_ISO][CNT_cur_thsnds]",
1160
-            $country->currency_thousands_separator()
1161
-        );
1162
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1163
-            "cntry[$CNT_ISO][CNT_tel_code]",
1164
-            $country->telephoneCode()
1165
-        );
1166
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1167
-            "cntry[$CNT_ISO][CNT_active]",
1168
-            $country->isActive(),
1169
-            DataType::BOOL
1170
-        );
1171
-
1172
-        // allow filtering of country data
1173
-        $cols_n_values = apply_filters(
1174
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1175
-            $cols_n_values
1176
-        );
1177
-
1178
-        // where values
1179
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1180
-        // run the update
1181
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1182
-
1183
-        // allow filtering of states data
1184
-        $states = apply_filters(
1185
-            'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1186
-            $this->request->getRequestParam('states', [], DataType::STRING, true)
1187
-        );
1188
-
1189
-        if (! empty($states) && $success !== false) {
1190
-            // loop thru state data ( looks like : states[75][STA_name] )
1191
-            foreach ($states as $STA_ID => $state) {
1192
-                $cols_n_values = [
1193
-                    'CNT_ISO'    => $CNT_ISO,
1194
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1195
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1196
-                    'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1197
-                ];
1198
-                // where values
1199
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1200
-                // run the update
1201
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1202
-                if ($success !== false) {
1203
-                    do_action(
1204
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1205
-                        $CNT_ISO,
1206
-                        $STA_ID,
1207
-                        $cols_n_values
1208
-                    );
1209
-                }
1210
-            }
1211
-        }
1212
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1213
-        if (
1214
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1215
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1216
-        ) {
1217
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1218
-            EE_Registry::instance()->CFG->update_espresso_config();
1219
-        }
1220
-
1221
-        if ($success !== false) {
1222
-            EE_Error::add_success(
1223
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1224
-            );
1225
-        }
1226
-        $this->_redirect_after_action(
1227
-            $success,
1228
-            '',
1229
-            '',
1230
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1231
-            true
1232
-        );
1233
-    }
1234
-
1235
-
1236
-    /**
1237
-     * form_form_field_label_wrap
1238
-     *
1239
-     * @param string $label
1240
-     * @return string
1241
-     */
1242
-    public function country_form_field_label_wrap(string $label): string
1243
-    {
1244
-        return '
22
+	/**
23
+	 * @var EE_Core_Config
24
+	 */
25
+	public $core_config;
26
+
27
+
28
+	/**
29
+	 * Initialize basic properties.
30
+	 */
31
+	protected function _init_page_props()
32
+	{
33
+		$this->page_slug        = GEN_SET_PG_SLUG;
34
+		$this->page_label       = GEN_SET_LABEL;
35
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
36
+		$this->_admin_base_path = GEN_SET_ADMIN;
37
+	}
38
+
39
+
40
+	/**
41
+	 * Set ajax hooks
42
+	 */
43
+	protected function _ajax_hooks()
44
+	{
45
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
46
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
47
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
48
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
49
+	}
50
+
51
+
52
+	/**
53
+	 * More page properties initialization.
54
+	 */
55
+	protected function _define_page_props()
56
+	{
57
+		$this->_admin_page_title = GEN_SET_LABEL;
58
+		$this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
59
+	}
60
+
61
+
62
+	/**
63
+	 * Set page routes property.
64
+	 */
65
+	protected function _set_page_routes()
66
+	{
67
+		$this->_page_routes = [
68
+			'critical_pages'                => [
69
+				'func'       => '_espresso_page_settings',
70
+				'capability' => 'manage_options',
71
+			],
72
+			'update_espresso_page_settings' => [
73
+				'func'       => '_update_espresso_page_settings',
74
+				'capability' => 'manage_options',
75
+				'noheader'   => true,
76
+			],
77
+			'default'                       => [
78
+				'func'       => '_your_organization_settings',
79
+				'capability' => 'manage_options',
80
+			],
81
+
82
+			'update_your_organization_settings' => [
83
+				'func'       => '_update_your_organization_settings',
84
+				'capability' => 'manage_options',
85
+				'noheader'   => true,
86
+			],
87
+
88
+			'admin_option_settings' => [
89
+				'func'       => '_admin_option_settings',
90
+				'capability' => 'manage_options',
91
+			],
92
+
93
+			'update_admin_option_settings' => [
94
+				'func'       => '_update_admin_option_settings',
95
+				'capability' => 'manage_options',
96
+				'noheader'   => true,
97
+			],
98
+
99
+			'country_settings' => [
100
+				'func'       => '_country_settings',
101
+				'capability' => 'manage_options',
102
+			],
103
+
104
+			'update_country_settings' => [
105
+				'func'       => '_update_country_settings',
106
+				'capability' => 'manage_options',
107
+				'noheader'   => true,
108
+			],
109
+
110
+			'display_country_settings' => [
111
+				'func'       => 'display_country_settings',
112
+				'capability' => 'manage_options',
113
+				'noheader'   => true,
114
+			],
115
+
116
+			'add_new_state' => [
117
+				'func'       => 'add_new_state',
118
+				'capability' => 'manage_options',
119
+				'noheader'   => true,
120
+			],
121
+
122
+			'delete_state'            => [
123
+				'func'       => 'delete_state',
124
+				'capability' => 'manage_options',
125
+				'noheader'   => true,
126
+			],
127
+			'privacy_settings'        => [
128
+				'func'       => 'privacySettings',
129
+				'capability' => 'manage_options',
130
+			],
131
+			'update_privacy_settings' => [
132
+				'func'               => 'updatePrivacySettings',
133
+				'capability'         => 'manage_options',
134
+				'noheader'           => true,
135
+				'headers_sent_route' => 'privacy_settings',
136
+			],
137
+		];
138
+	}
139
+
140
+
141
+	/**
142
+	 * Set page configuration property
143
+	 */
144
+	protected function _set_page_config()
145
+	{
146
+		$this->_page_config = [
147
+			'critical_pages'        => [
148
+				'nav'           => [
149
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
150
+					'icon' => 'dashicons-warning',
151
+					'order' => 50,
152
+				],
153
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
+				'help_tabs'     => [
155
+					'general_settings_critical_pages_help_tab' => [
156
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
+						'filename' => 'general_settings_critical_pages',
158
+					],
159
+				],
160
+				'require_nonce' => false,
161
+			],
162
+			'default'               => [
163
+				'nav'           => [
164
+					'label' => esc_html__('Your Organization', 'event_espresso'),
165
+					'icon' => 'dashicons-admin-home',
166
+					'order' => 20,
167
+				],
168
+				'help_tabs'     => [
169
+					'general_settings_your_organization_help_tab' => [
170
+						'title'    => esc_html__('Your Organization', 'event_espresso'),
171
+						'filename' => 'general_settings_your_organization',
172
+					],
173
+				],
174
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
175
+				'require_nonce' => false,
176
+			],
177
+			'admin_option_settings' => [
178
+				'nav'           => [
179
+					'label' => esc_html__('Admin Options', 'event_espresso'),
180
+					'icon' => 'dashicons-admin-settings',
181
+					'order' => 60,
182
+				],
183
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
184
+				'help_tabs'     => [
185
+					'general_settings_admin_options_help_tab' => [
186
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
187
+						'filename' => 'general_settings_admin_options',
188
+					],
189
+				],
190
+				'require_nonce' => false,
191
+			],
192
+			'country_settings'      => [
193
+				'nav'           => [
194
+					'label' => esc_html__('Countries', 'event_espresso'),
195
+					'icon' => 'dashicons-admin-site',
196
+					'order' => 70,
197
+				],
198
+				'help_tabs'     => [
199
+					'general_settings_countries_help_tab' => [
200
+						'title'    => esc_html__('Countries', 'event_espresso'),
201
+						'filename' => 'general_settings_countries',
202
+					],
203
+				],
204
+				'require_nonce' => false,
205
+			],
206
+			'privacy_settings'      => [
207
+				'nav'           => [
208
+					'label' => esc_html__('Privacy', 'event_espresso'),
209
+					'icon' => 'dashicons-privacy',
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
+		$this->core_config = EE_Registry::instance()->CFG->core;
247
+
248
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
249
+			esc_html__(
250
+				'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.',
251
+				'event_espresso'
252
+			)
253
+		);
254
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
255
+			esc_html__(
256
+				'An error occurred! Please refresh the page and try again.',
257
+				'event_espresso'
258
+			)
259
+		);
260
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
261
+			esc_html__(
262
+				'Are you sure you want to delete this State / Province?',
263
+				'event_espresso'
264
+			)
265
+		);
266
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
267
+			'admin-ajax.php?page=espresso_general_settings',
268
+			is_ssl() ? 'https://' : 'http://'
269
+		);
270
+	}
271
+
272
+
273
+	public function admin_notices()
274
+	{
275
+	}
276
+
277
+
278
+	public function admin_footer_scripts()
279
+	{
280
+	}
281
+
282
+
283
+	/**
284
+	 * Enqueue scripts and styles for the default route.
285
+	 */
286
+	public function load_scripts_styles_default()
287
+	{
288
+		// styles
289
+		wp_enqueue_style('thickbox');
290
+		// scripts
291
+		wp_enqueue_script('media-upload');
292
+		wp_enqueue_script('thickbox');
293
+		wp_register_script(
294
+			'organization_settings',
295
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
296
+			['jquery', 'media-upload', 'thickbox'],
297
+			EVENT_ESPRESSO_VERSION,
298
+			true
299
+		);
300
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
301
+		wp_enqueue_script('organization_settings');
302
+		wp_enqueue_style('organization-css');
303
+		$confirm_image_delete = [
304
+			'text' => wp_strip_all_tags(
305
+				esc_html__(
306
+					'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
307
+					'event_espresso'
308
+				)
309
+			),
310
+		];
311
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
312
+	}
313
+
314
+
315
+	/**
316
+	 * Enqueue scripts and styles for the country settings route.
317
+	 */
318
+	public function load_scripts_styles_country_settings()
319
+	{
320
+		// scripts
321
+		wp_register_script(
322
+			'gen_settings_countries',
323
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
324
+			['ee_admin_js'],
325
+			EVENT_ESPRESSO_VERSION,
326
+			true
327
+		);
328
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
329
+		wp_enqueue_script('gen_settings_countries');
330
+		wp_enqueue_style('organization-css');
331
+	}
332
+
333
+
334
+	/*************        Espresso Pages        *************/
335
+	/**
336
+	 * _espresso_page_settings
337
+	 *
338
+	 * @throws EE_Error
339
+	 * @throws DomainException
340
+	 * @throws DomainException
341
+	 * @throws InvalidDataTypeException
342
+	 * @throws InvalidArgumentException
343
+	 */
344
+	protected function _espresso_page_settings()
345
+	{
346
+		// Check to make sure all of the main pages are set up properly,
347
+		// if not create the default pages and display an admin notice
348
+		EEH_Activation::verify_default_pages_exist();
349
+		$this->_transient_garbage_collection();
350
+
351
+		$this->_template_args['values'] = $this->_yes_no_values;
352
+
353
+		$this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
354
+		$this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
355
+			? get_post($this->core_config->reg_page_id)
356
+			: false;
357
+
358
+		$this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
359
+		$this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
360
+			? get_post($this->core_config->txn_page_id)
361
+			: false;
362
+
363
+		$this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
364
+		$this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
365
+			? get_post($this->core_config->thank_you_page_id)
366
+			: false;
367
+
368
+		$this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
369
+		$this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
370
+			? get_post($this->core_config->cancel_page_id)
371
+			: false;
372
+
373
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
374
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
375
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
376
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
377
+			$this->_template_args,
378
+			true
379
+		);
380
+		$this->display_admin_page_with_sidebar();
381
+	}
382
+
383
+
384
+	/**
385
+	 * Handler for updating espresso page settings.
386
+	 *
387
+	 * @throws EE_Error
388
+	 */
389
+	protected function _update_espresso_page_settings()
390
+	{
391
+		$this->core_config = EE_Registry::instance()->CFG->core;
392
+		// capture incoming request data && set page IDs
393
+		$this->core_config->reg_page_id       = $this->request->getRequestParam(
394
+			'reg_page_id',
395
+			$this->core_config->reg_page_id,
396
+			DataType::INT
397
+		);
398
+		$this->core_config->txn_page_id       = $this->request->getRequestParam(
399
+			'txn_page_id',
400
+			$this->core_config->txn_page_id,
401
+			DataType::INT
402
+		);
403
+		$this->core_config->thank_you_page_id = $this->request->getRequestParam(
404
+			'thank_you_page_id',
405
+			$this->core_config->thank_you_page_id,
406
+			DataType::INT
407
+		);
408
+		$this->core_config->cancel_page_id    = $this->request->getRequestParam(
409
+			'cancel_page_id',
410
+			$this->core_config->cancel_page_id,
411
+			DataType::INT
412
+		);
413
+
414
+		$this->core_config = apply_filters(
415
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
416
+			$this->core_config,
417
+			$this->request->requestParams()
418
+		);
419
+
420
+		$what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
421
+		$this->_redirect_after_action(
422
+			$this->_update_espresso_configuration(
423
+				$what,
424
+				$this->core_config,
425
+				__FILE__,
426
+				__FUNCTION__,
427
+				__LINE__
428
+			),
429
+			$what,
430
+			'',
431
+			[
432
+				'action' => 'critical_pages',
433
+			],
434
+			true
435
+		);
436
+	}
437
+
438
+
439
+	/*************        Your Organization        *************/
440
+
441
+
442
+	/**
443
+	 * @throws DomainException
444
+	 * @throws EE_Error
445
+	 * @throws InvalidArgumentException
446
+	 * @throws InvalidDataTypeException
447
+	 * @throws InvalidInterfaceException
448
+	 */
449
+	protected function _your_organization_settings()
450
+	{
451
+		$this->_template_args['admin_page_content'] = '';
452
+		try {
453
+			/** @var OrganizationSettings $organization_settings_form */
454
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
455
+
456
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
457
+				$organization_settings_form->display(),
458
+				'',
459
+				'padding'
460
+			);
461
+		} catch (Exception $e) {
462
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
463
+		}
464
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
465
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
466
+		$this->display_admin_page_with_sidebar();
467
+	}
468
+
469
+
470
+	/**
471
+	 * Handler for updating organization settings.
472
+	 *
473
+	 * @throws EE_Error
474
+	 */
475
+	protected function _update_your_organization_settings()
476
+	{
477
+		try {
478
+			/** @var OrganizationSettings $organization_settings_form */
479
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
480
+
481
+			$success = $organization_settings_form->process($this->request->requestParams());
482
+
483
+			EE_Registry::instance()->CFG = apply_filters(
484
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
485
+				EE_Registry::instance()->CFG
486
+			);
487
+		} catch (Exception $e) {
488
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
489
+			$success = false;
490
+		}
491
+
492
+		if ($success) {
493
+			$success = $this->_update_espresso_configuration(
494
+				esc_html__('Your Organization Settings', 'event_espresso'),
495
+				EE_Registry::instance()->CFG,
496
+				__FILE__,
497
+				__FUNCTION__,
498
+				__LINE__
499
+			);
500
+		}
501
+
502
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
503
+	}
504
+
505
+
506
+
507
+	/*************        Admin Options        *************/
508
+
509
+
510
+	/**
511
+	 * _admin_option_settings
512
+	 *
513
+	 * @throws EE_Error
514
+	 * @throws LogicException
515
+	 */
516
+	protected function _admin_option_settings()
517
+	{
518
+		$this->_template_args['admin_page_content'] = '';
519
+		try {
520
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
521
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
522
+			$this->_template_args['values'] = $this->_yes_no_values;
523
+			// also need to account for the do_action that was in the old template
524
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
525
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
526
+				$admin_options_settings_form->display(),
527
+				'',
528
+				'padding'
529
+			);
530
+		} catch (Exception $e) {
531
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
532
+		}
533
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
534
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
535
+		$this->display_admin_page_with_sidebar();
536
+	}
537
+
538
+
539
+	/**
540
+	 * _update_admin_option_settings
541
+	 *
542
+	 * @throws EE_Error
543
+	 * @throws InvalidDataTypeException
544
+	 * @throws InvalidFormSubmissionException
545
+	 * @throws InvalidArgumentException
546
+	 * @throws LogicException
547
+	 */
548
+	protected function _update_admin_option_settings()
549
+	{
550
+		try {
551
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
552
+			$admin_options_settings_form->process(
553
+				$this->request->getRequestParam(
554
+					$admin_options_settings_form->slug(),
555
+					[],
556
+					DataType::STRING,
557
+					true
558
+				)
559
+			);
560
+			EE_Registry::instance()->CFG->admin = apply_filters(
561
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
562
+				EE_Registry::instance()->CFG->admin
563
+			);
564
+		} catch (Exception $e) {
565
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
566
+		}
567
+		$this->_redirect_after_action(
568
+			apply_filters(
569
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
570
+				$this->_update_espresso_configuration(
571
+					esc_html__('Admin Options', 'event_espresso'),
572
+					EE_Registry::instance()->CFG->admin,
573
+					__FILE__,
574
+					__FUNCTION__,
575
+					__LINE__
576
+				)
577
+			),
578
+			esc_html__('Admin Options', 'event_espresso'),
579
+			'updated',
580
+			['action' => 'admin_option_settings']
581
+		);
582
+	}
583
+
584
+
585
+	/*************        Countries        *************/
586
+
587
+
588
+	/**
589
+	 * @param string|null $default
590
+	 * @return string
591
+	 */
592
+	protected function getCountryISO(?string $default = null): string
593
+	{
594
+		$default = $default ?? $this->getCountryIsoForSite();
595
+		$CNT_ISO = $this->request->getRequestParam('country', $default);
596
+		$CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
597
+		return strtoupper($CNT_ISO);
598
+	}
599
+
600
+
601
+	/**
602
+	 * @return string
603
+	 */
604
+	protected function getCountryIsoForSite(): string
605
+	{
606
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
607
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
608
+			: 'US';
609
+	}
610
+
611
+
612
+	/**
613
+	 * @param string          $CNT_ISO
614
+	 * @param EE_Country|null $country
615
+	 * @return EE_Base_Class|EE_Country
616
+	 * @throws EE_Error
617
+	 * @throws InvalidArgumentException
618
+	 * @throws InvalidDataTypeException
619
+	 * @throws InvalidInterfaceException
620
+	 * @throws ReflectionException
621
+	 */
622
+	protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
623
+	{
624
+		/** @var EE_Country $country */
625
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
626
+			? $country
627
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
628
+	}
629
+
630
+
631
+	/**
632
+	 * Output Country Settings view.
633
+	 *
634
+	 * @throws DomainException
635
+	 * @throws EE_Error
636
+	 * @throws InvalidArgumentException
637
+	 * @throws InvalidDataTypeException
638
+	 * @throws InvalidInterfaceException
639
+	 * @throws ReflectionException
640
+	 */
641
+	protected function _country_settings()
642
+	{
643
+		$CNT_ISO = $this->getCountryISO();
644
+
645
+		$this->_template_args['values']    = $this->_yes_no_values;
646
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
647
+			EE_Question::new_instance(
648
+				[
649
+				  'QST_ID'           => 0,
650
+				  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
651
+				  'QST_system'       => 'admin-country',
652
+				]
653
+			),
654
+			EE_Answer::new_instance(
655
+				[
656
+					'ANS_ID'    => 0,
657
+					'ANS_value' => $CNT_ISO,
658
+				]
659
+			),
660
+			[
661
+				'input_id'       => 'country',
662
+				'input_name'     => 'country',
663
+				'input_prefix'   => '',
664
+				'append_qstn_id' => false,
665
+			]
666
+		);
667
+
668
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
669
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
670
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
671
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
672
+			$country->ID(),
673
+			$country
674
+		);
675
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
676
+			$country->ID(),
677
+			$country
678
+		);
679
+		$this->_template_args['CNT_name_for_site']        = $country->name();
680
+
681
+		$this->_set_add_edit_form_tags('update_country_settings');
682
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
683
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
684
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
685
+			$this->_template_args,
686
+			true
687
+		);
688
+		$this->display_admin_page_with_no_sidebar();
689
+	}
690
+
691
+
692
+	/**
693
+	 * @param string          $CNT_ISO
694
+	 * @param EE_Country|null $country
695
+	 * @return string
696
+	 * @throws DomainException
697
+	 * @throws EE_Error
698
+	 * @throws InvalidArgumentException
699
+	 * @throws InvalidDataTypeException
700
+	 * @throws InvalidInterfaceException
701
+	 * @throws ReflectionException
702
+	 */
703
+	public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
704
+	{
705
+		$CNT_ISO          = $this->getCountryISO($CNT_ISO);
706
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
707
+
708
+		if (! $CNT_ISO) {
709
+			return '';
710
+		}
711
+
712
+		// for ajax
713
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
714
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
715
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
716
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
717
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
718
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
719
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
720
+
721
+		$country_input_types            = [
722
+			'CNT_active'      => [
723
+				'type'             => 'RADIO_BTN',
724
+				'input_name'       => "cntry[$CNT_ISO]",
725
+				'class'            => '',
726
+				'options'          => $this->_yes_no_values,
727
+				'use_desc_4_label' => true,
728
+			],
729
+			'CNT_ISO'         => [
730
+				'type'       => 'TEXT',
731
+				'input_name' => "cntry[$CNT_ISO]",
732
+				'class'      => 'ee-input-width--small',
733
+			],
734
+			'CNT_ISO3'        => [
735
+				'type'       => 'TEXT',
736
+				'input_name' => "cntry[$CNT_ISO]",
737
+				'class'      => 'ee-input-width--small',
738
+			],
739
+			// 'RGN_ID'          => [
740
+			//     'type'       => 'TEXT',
741
+			//     'input_name' => "cntry[$CNT_ISO]",
742
+			//     'class'      => 'ee-input-width--small',
743
+			// ],
744
+			'CNT_name'        => [
745
+				'type'       => 'TEXT',
746
+				'input_name' => "cntry[$CNT_ISO]",
747
+				'class'      => 'ee-input-width--big',
748
+			],
749
+			'CNT_cur_code'    => [
750
+				'type'       => 'TEXT',
751
+				'input_name' => "cntry[$CNT_ISO]",
752
+				'class'      => 'ee-input-width--small',
753
+				'disabled'   => $CNT_cur_disabled,
754
+			],
755
+			'CNT_cur_single'  => [
756
+				'type'       => 'TEXT',
757
+				'input_name' => "cntry[$CNT_ISO]",
758
+				'class'      => 'ee-input-width--reg',
759
+				'disabled'   => $CNT_cur_disabled,
760
+			],
761
+			'CNT_cur_plural'  => [
762
+				'type'       => 'TEXT',
763
+				'input_name' => "cntry[$CNT_ISO]",
764
+				'class'      => 'ee-input-width--reg',
765
+				'disabled'   => $CNT_cur_disabled,
766
+			],
767
+			'CNT_cur_sign'    => [
768
+				'type'         => 'TEXT',
769
+				'input_name'   => "cntry[$CNT_ISO]",
770
+				'class'        => 'ee-input-width--small',
771
+				'htmlentities' => false,
772
+				'disabled'     => $CNT_cur_disabled,
773
+			],
774
+			'CNT_cur_sign_b4' => [
775
+				'type'             => 'RADIO_BTN',
776
+				'input_name'       => "cntry[$CNT_ISO]",
777
+				'class'            => '',
778
+				'options'          => $this->_yes_no_values,
779
+				'use_desc_4_label' => true,
780
+				'disabled'         => $CNT_cur_disabled,
781
+			],
782
+			'CNT_cur_dec_plc' => [
783
+				'type'       => 'RADIO_BTN',
784
+				'input_name' => "cntry[$CNT_ISO]",
785
+				'class'      => '',
786
+				'options'    => [
787
+					['id' => 0, 'text' => ''],
788
+					['id' => 1, 'text' => ''],
789
+					['id' => 2, 'text' => ''],
790
+					['id' => 3, 'text' => ''],
791
+				],
792
+				'disabled'   => $CNT_cur_disabled,
793
+			],
794
+			'CNT_cur_dec_mrk' => [
795
+				'type'             => 'RADIO_BTN',
796
+				'input_name'       => "cntry[$CNT_ISO]",
797
+				'class'            => '',
798
+				'options'          => [
799
+					[
800
+						'id'   => ',',
801
+						'text' => esc_html__(', (comma)', 'event_espresso'),
802
+					],
803
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
804
+				],
805
+				'use_desc_4_label' => true,
806
+				'disabled'         => $CNT_cur_disabled,
807
+			],
808
+			'CNT_cur_thsnds'  => [
809
+				'type'             => 'RADIO_BTN',
810
+				'input_name'       => "cntry[$CNT_ISO]",
811
+				'class'            => '',
812
+				'options'          => [
813
+					[
814
+						'id'   => ',',
815
+						'text' => esc_html__(', (comma)', 'event_espresso'),
816
+					],
817
+					[
818
+						'id'   => '.',
819
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
820
+					],
821
+					[
822
+						'id'   => '&nbsp;',
823
+						'text' => esc_html__('(space)', 'event_espresso'),
824
+					],
825
+				],
826
+				'use_desc_4_label' => true,
827
+				'disabled'         => $CNT_cur_disabled,
828
+			],
829
+			'CNT_tel_code'    => [
830
+				'type'       => 'TEXT',
831
+				'input_name' => "cntry[$CNT_ISO]",
832
+				'class'      => 'ee-input-width--small',
833
+			],
834
+			'CNT_is_EU'       => [
835
+				'type'             => 'RADIO_BTN',
836
+				'input_name'       => "cntry[$CNT_ISO]",
837
+				'class'            => '',
838
+				'options'          => $this->_yes_no_values,
839
+				'use_desc_4_label' => true,
840
+			],
841
+		];
842
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
843
+			$country,
844
+			$country_input_types
845
+		);
846
+		$country_details_settings       = EEH_Template::display_template(
847
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
848
+			$this->_template_args,
849
+			true
850
+		);
851
+
852
+		if (defined('DOING_AJAX')) {
853
+			$notices = EE_Error::get_notices(false, false, false);
854
+			echo wp_json_encode(
855
+				[
856
+					'return_data' => $country_details_settings,
857
+					'success'     => $notices['success'],
858
+					'errors'      => $notices['errors'],
859
+				]
860
+			);
861
+			die();
862
+		}
863
+		return $country_details_settings;
864
+	}
865
+
866
+
867
+	/**
868
+	 * @param string          $CNT_ISO
869
+	 * @param EE_Country|null $country
870
+	 * @return string
871
+	 * @throws DomainException
872
+	 * @throws EE_Error
873
+	 * @throws InvalidArgumentException
874
+	 * @throws InvalidDataTypeException
875
+	 * @throws InvalidInterfaceException
876
+	 * @throws ReflectionException
877
+	 */
878
+	public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
879
+	{
880
+		$CNT_ISO = $this->getCountryISO($CNT_ISO);
881
+		if (! $CNT_ISO) {
882
+			return '';
883
+		}
884
+		// for ajax
885
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
886
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
887
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
888
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
889
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
890
+		if (empty($states)) {
891
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
892
+			$countrySubRegionDao = $this->loader->getShared(
893
+				'EventEspresso\core\services\address\CountrySubRegionDao'
894
+			);
895
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
896
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
897
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
898
+					$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
899
+				}
900
+			}
901
+		}
902
+		if (is_array($states)) {
903
+			foreach ($states as $STA_ID => $state) {
904
+				if ($state instanceof EE_State) {
905
+					$inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
906
+						$state,
907
+						[
908
+							'STA_abbrev' => [
909
+								'type'             => 'TEXT',
910
+								'label'            => esc_html__('Code', 'event_espresso'),
911
+								'input_name'       => "states[$STA_ID]",
912
+								'class'            => 'ee-input-width--tiny',
913
+								'add_mobile_label' => true,
914
+							],
915
+							'STA_name'   => [
916
+								'type'             => 'TEXT',
917
+								'label'            => esc_html__('Name', 'event_espresso'),
918
+								'input_name'       => "states[$STA_ID]",
919
+								'class'            => 'ee-input-width--big',
920
+								'add_mobile_label' => true,
921
+							],
922
+							'STA_active' => [
923
+								'type'             => 'RADIO_BTN',
924
+								'label'            => esc_html__(
925
+									'State Appears in Dropdown Select Lists',
926
+									'event_espresso'
927
+								),
928
+								'input_name'       => "states[$STA_ID]",
929
+								'options'          => $this->_yes_no_values,
930
+								'use_desc_4_label' => true,
931
+								'add_mobile_label' => true,
932
+							],
933
+						]
934
+					);
935
+
936
+					$delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
937
+						[
938
+							'action'     => 'delete_state',
939
+							'STA_ID'     => $STA_ID,
940
+							'CNT_ISO'    => $CNT_ISO,
941
+							'STA_abbrev' => $state->abbrev(),
942
+						],
943
+						GEN_SET_ADMIN_URL
944
+					);
945
+
946
+					$this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
947
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
948
+				}
949
+			}
950
+		} else {
951
+			$this->_template_args['states'] = false;
952
+		}
953
+
954
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
955
+			['action' => 'add_new_state'],
956
+			GEN_SET_ADMIN_URL
957
+		);
958
+
959
+		$state_details_settings = EEH_Template::display_template(
960
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
961
+			$this->_template_args,
962
+			true
963
+		);
964
+
965
+		if (defined('DOING_AJAX')) {
966
+			$notices = EE_Error::get_notices(false, false, false);
967
+			echo wp_json_encode(
968
+				[
969
+					'return_data' => $state_details_settings,
970
+					'success'     => $notices['success'],
971
+					'errors'      => $notices['errors'],
972
+				]
973
+			);
974
+			die();
975
+		}
976
+		return $state_details_settings;
977
+	}
978
+
979
+
980
+	/**
981
+	 * @return void
982
+	 * @throws EE_Error
983
+	 * @throws InvalidArgumentException
984
+	 * @throws InvalidDataTypeException
985
+	 * @throws InvalidInterfaceException
986
+	 * @throws ReflectionException
987
+	 */
988
+	public function add_new_state()
989
+	{
990
+		$success = true;
991
+		$CNT_ISO = $this->getCountryISO('');
992
+		if (! $CNT_ISO) {
993
+			EE_Error::add_error(
994
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
995
+				__FILE__,
996
+				__FUNCTION__,
997
+				__LINE__
998
+			);
999
+			$success = false;
1000
+		}
1001
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1002
+		if (! $STA_abbrev) {
1003
+			EE_Error::add_error(
1004
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1005
+				__FILE__,
1006
+				__FUNCTION__,
1007
+				__LINE__
1008
+			);
1009
+			$success = false;
1010
+		}
1011
+		$STA_name = $this->request->getRequestParam('STA_name');
1012
+		if (! $STA_name) {
1013
+			EE_Error::add_error(
1014
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1015
+				__FILE__,
1016
+				__FUNCTION__,
1017
+				__LINE__
1018
+			);
1019
+			$success = false;
1020
+		}
1021
+
1022
+		if ($success) {
1023
+			$cols_n_values = [
1024
+				'CNT_ISO'    => $CNT_ISO,
1025
+				'STA_abbrev' => $STA_abbrev,
1026
+				'STA_name'   => $STA_name,
1027
+				'STA_active' => true,
1028
+			];
1029
+			$success       = EEM_State::instance()->insert($cols_n_values);
1030
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1031
+		}
1032
+
1033
+		if (defined('DOING_AJAX')) {
1034
+			$notices = EE_Error::get_notices(false, false, false);
1035
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1036
+			die();
1037
+		}
1038
+		$this->_redirect_after_action(
1039
+			$success,
1040
+			esc_html__('State', 'event_espresso'),
1041
+			'added',
1042
+			['action' => 'country_settings']
1043
+		);
1044
+	}
1045
+
1046
+
1047
+	/**
1048
+	 * @return void
1049
+	 * @throws EE_Error
1050
+	 * @throws InvalidArgumentException
1051
+	 * @throws InvalidDataTypeException
1052
+	 * @throws InvalidInterfaceException
1053
+	 * @throws ReflectionException
1054
+	 */
1055
+	public function delete_state()
1056
+	{
1057
+		$CNT_ISO    = $this->getCountryISO();
1058
+		$STA_ID     = $this->request->getRequestParam('STA_ID');
1059
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1060
+
1061
+		if (! $STA_ID) {
1062
+			EE_Error::add_error(
1063
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1064
+				__FILE__,
1065
+				__FUNCTION__,
1066
+				__LINE__
1067
+			);
1068
+			return;
1069
+		}
1070
+
1071
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1072
+		if ($success !== false) {
1073
+			do_action(
1074
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1075
+				$CNT_ISO,
1076
+				$STA_ID,
1077
+				['STA_abbrev' => $STA_abbrev]
1078
+			);
1079
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1080
+		}
1081
+		if (defined('DOING_AJAX')) {
1082
+			$notices                = EE_Error::get_notices(false);
1083
+			$notices['return_data'] = true;
1084
+			echo wp_json_encode($notices);
1085
+			die();
1086
+		}
1087
+		$this->_redirect_after_action(
1088
+			$success,
1089
+			esc_html__('State', 'event_espresso'),
1090
+			'deleted',
1091
+			['action' => 'country_settings']
1092
+		);
1093
+	}
1094
+
1095
+
1096
+	/**
1097
+	 * @return void
1098
+	 * @throws EE_Error
1099
+	 * @throws InvalidArgumentException
1100
+	 * @throws InvalidDataTypeException
1101
+	 * @throws InvalidInterfaceException
1102
+	 * @throws ReflectionException
1103
+	 */
1104
+	protected function _update_country_settings()
1105
+	{
1106
+		$CNT_ISO = $this->getCountryISO();
1107
+		if (! $CNT_ISO) {
1108
+			EE_Error::add_error(
1109
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1110
+				__FILE__,
1111
+				__FUNCTION__,
1112
+				__LINE__
1113
+			);
1114
+			return;
1115
+		}
1116
+
1117
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1118
+
1119
+		$cols_n_values                    = [];
1120
+		$cols_n_values['CNT_ISO3']        = strtoupper(
1121
+			$this->request->getRequestParam('cntry', '', $country->ISO3())
1122
+		);
1123
+		$cols_n_values['CNT_name']        = $this->request->getRequestParam(
1124
+			"cntry[$CNT_ISO][CNT_name]",
1125
+			$country->name()
1126
+		);
1127
+		$cols_n_values['CNT_cur_code']    = strtoupper(
1128
+			$this->request->getRequestParam(
1129
+				"cntry[$CNT_ISO][CNT_cur_code]",
1130
+				$country->currency_code()
1131
+			)
1132
+		);
1133
+		$cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1134
+			"cntry[$CNT_ISO][CNT_cur_single]",
1135
+			$country->currency_name_single()
1136
+		);
1137
+		$cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1138
+			"cntry[$CNT_ISO][CNT_cur_plural]",
1139
+			$country->currency_name_plural()
1140
+		);
1141
+		$cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1142
+			"cntry[$CNT_ISO][CNT_cur_sign]",
1143
+			$country->currency_sign()
1144
+		);
1145
+		$cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1146
+			"cntry[$CNT_ISO][CNT_cur_sign_b4]",
1147
+			$country->currency_sign_before(),
1148
+			DataType::BOOL
1149
+		);
1150
+		$cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1151
+			"cntry[$CNT_ISO][CNT_cur_dec_plc]",
1152
+			$country->currency_decimal_places()
1153
+		);
1154
+		$cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1155
+			"cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1156
+			$country->currency_decimal_mark()
1157
+		);
1158
+		$cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1159
+			"cntry[$CNT_ISO][CNT_cur_thsnds]",
1160
+			$country->currency_thousands_separator()
1161
+		);
1162
+		$cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1163
+			"cntry[$CNT_ISO][CNT_tel_code]",
1164
+			$country->telephoneCode()
1165
+		);
1166
+		$cols_n_values['CNT_active']      = $this->request->getRequestParam(
1167
+			"cntry[$CNT_ISO][CNT_active]",
1168
+			$country->isActive(),
1169
+			DataType::BOOL
1170
+		);
1171
+
1172
+		// allow filtering of country data
1173
+		$cols_n_values = apply_filters(
1174
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1175
+			$cols_n_values
1176
+		);
1177
+
1178
+		// where values
1179
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1180
+		// run the update
1181
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1182
+
1183
+		// allow filtering of states data
1184
+		$states = apply_filters(
1185
+			'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1186
+			$this->request->getRequestParam('states', [], DataType::STRING, true)
1187
+		);
1188
+
1189
+		if (! empty($states) && $success !== false) {
1190
+			// loop thru state data ( looks like : states[75][STA_name] )
1191
+			foreach ($states as $STA_ID => $state) {
1192
+				$cols_n_values = [
1193
+					'CNT_ISO'    => $CNT_ISO,
1194
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1195
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1196
+					'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1197
+				];
1198
+				// where values
1199
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1200
+				// run the update
1201
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1202
+				if ($success !== false) {
1203
+					do_action(
1204
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1205
+						$CNT_ISO,
1206
+						$STA_ID,
1207
+						$cols_n_values
1208
+					);
1209
+				}
1210
+			}
1211
+		}
1212
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1213
+		if (
1214
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1215
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1216
+		) {
1217
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1218
+			EE_Registry::instance()->CFG->update_espresso_config();
1219
+		}
1220
+
1221
+		if ($success !== false) {
1222
+			EE_Error::add_success(
1223
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1224
+			);
1225
+		}
1226
+		$this->_redirect_after_action(
1227
+			$success,
1228
+			'',
1229
+			'',
1230
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1231
+			true
1232
+		);
1233
+	}
1234
+
1235
+
1236
+	/**
1237
+	 * form_form_field_label_wrap
1238
+	 *
1239
+	 * @param string $label
1240
+	 * @return string
1241
+	 */
1242
+	public function country_form_field_label_wrap(string $label): string
1243
+	{
1244
+		return '
1245 1245
 			<tr>
1246 1246
 				<th>
1247 1247
 					' . $label . '
1248 1248
 				</th>';
1249
-    }
1250
-
1251
-
1252
-    /**
1253
-     * form_form_field_input__wrap
1254
-     *
1255
-     * @param string $input
1256
-     * @return string
1257
-     */
1258
-    public function country_form_field_input__wrap(string $input): string
1259
-    {
1260
-        return '
1249
+	}
1250
+
1251
+
1252
+	/**
1253
+	 * form_form_field_input__wrap
1254
+	 *
1255
+	 * @param string $input
1256
+	 * @return string
1257
+	 */
1258
+	public function country_form_field_input__wrap(string $input): string
1259
+	{
1260
+		return '
1261 1261
 				<td class="general-settings-country-input-td">
1262 1262
 					' . $input . '
1263 1263
 				</td>
1264 1264
 			</tr>';
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     * form_form_field_label_wrap
1270
-     *
1271
-     * @param string $label
1272
-     * @param string $required_text
1273
-     * @return string
1274
-     */
1275
-    public function state_form_field_label_wrap(string $label, string $required_text): string
1276
-    {
1277
-        return $required_text;
1278
-    }
1279
-
1280
-
1281
-    /**
1282
-     * form_form_field_input__wrap
1283
-     *
1284
-     * @param string $input
1285
-     * @return string
1286
-     */
1287
-    public function state_form_field_input__wrap(string $input): string
1288
-    {
1289
-        return '
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 * form_form_field_label_wrap
1270
+	 *
1271
+	 * @param string $label
1272
+	 * @param string $required_text
1273
+	 * @return string
1274
+	 */
1275
+	public function state_form_field_label_wrap(string $label, string $required_text): string
1276
+	{
1277
+		return $required_text;
1278
+	}
1279
+
1280
+
1281
+	/**
1282
+	 * form_form_field_input__wrap
1283
+	 *
1284
+	 * @param string $input
1285
+	 * @return string
1286
+	 */
1287
+	public function state_form_field_input__wrap(string $input): string
1288
+	{
1289
+		return '
1290 1290
 				<td class="general-settings-country-state-input-td">
1291 1291
 					' . $input . '
1292 1292
 				</td>';
1293
-    }
1294
-
1295
-
1296
-    /***********/
1297
-
1298
-
1299
-    /**
1300
-     * displays edit and view links for critical EE pages
1301
-     *
1302
-     * @param int $ee_page_id
1303
-     * @return string
1304
-     */
1305
-    public static function edit_view_links(int $ee_page_id): string
1306
-    {
1307
-        $edit_url = add_query_arg(
1308
-            ['post' => $ee_page_id, 'action' => 'edit'],
1309
-            admin_url('post.php')
1310
-        );
1311
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1312
-        $links    .= ' &nbsp;|&nbsp; ';
1313
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1314
-
1315
-        return $links;
1316
-    }
1317
-
1318
-
1319
-    /**
1320
-     * displays page and shortcode status for critical EE pages
1321
-     *
1322
-     * @param WP_Post $ee_page
1323
-     * @param string  $shortcode
1324
-     * @return string
1325
-     */
1326
-    public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1327
-    {
1328
-        // page status
1329
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1330
-            $pg_class  = 'ee-status-bg--success';
1331
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1332
-        } else {
1333
-            $pg_class  = 'ee-status-bg--error';
1334
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1335
-        }
1336
-
1337
-        // shortcode status
1338
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1339
-            $sc_class  = 'ee-status-bg--success';
1340
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1341
-        } else {
1342
-            $sc_class  = 'ee-status-bg--error';
1343
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1344
-        }
1345
-
1346
-        return '
1293
+	}
1294
+
1295
+
1296
+	/***********/
1297
+
1298
+
1299
+	/**
1300
+	 * displays edit and view links for critical EE pages
1301
+	 *
1302
+	 * @param int $ee_page_id
1303
+	 * @return string
1304
+	 */
1305
+	public static function edit_view_links(int $ee_page_id): string
1306
+	{
1307
+		$edit_url = add_query_arg(
1308
+			['post' => $ee_page_id, 'action' => 'edit'],
1309
+			admin_url('post.php')
1310
+		);
1311
+		$links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1312
+		$links    .= ' &nbsp;|&nbsp; ';
1313
+		$links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1314
+
1315
+		return $links;
1316
+	}
1317
+
1318
+
1319
+	/**
1320
+	 * displays page and shortcode status for critical EE pages
1321
+	 *
1322
+	 * @param WP_Post $ee_page
1323
+	 * @param string  $shortcode
1324
+	 * @return string
1325
+	 */
1326
+	public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1327
+	{
1328
+		// page status
1329
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1330
+			$pg_class  = 'ee-status-bg--success';
1331
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1332
+		} else {
1333
+			$pg_class  = 'ee-status-bg--error';
1334
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1335
+		}
1336
+
1337
+		// shortcode status
1338
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1339
+			$sc_class  = 'ee-status-bg--success';
1340
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1341
+		} else {
1342
+			$sc_class  = 'ee-status-bg--error';
1343
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1344
+		}
1345
+
1346
+		return '
1347 1347
         <span class="ee-page-status ' . $pg_class . '"><strong>' . $pg_status . '</strong></span>
1348 1348
         <span class="ee-page-status ' . $sc_class . '"><strong>' . $sc_status . '</strong></span>';
1349
-    }
1350
-
1351
-
1352
-    /**
1353
-     * generates a dropdown of all parent pages - copied from WP core
1354
-     *
1355
-     * @param int  $default
1356
-     * @param int  $parent
1357
-     * @param int  $level
1358
-     * @param bool $echo
1359
-     * @return string;
1360
-     */
1361
-    public static function page_settings_dropdown(
1362
-        int $default = 0,
1363
-        int $parent = 0,
1364
-        int $level = 0,
1365
-        bool $echo = true
1366
-    ): string {
1367
-        global $wpdb;
1368
-        $items  = $wpdb->get_results(
1369
-            $wpdb->prepare(
1370
-                "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",
1371
-                $parent
1372
-            )
1373
-        );
1374
-        $output = '';
1375
-
1376
-        if ($items) {
1377
-            $level = absint($level);
1378
-            foreach ($items as $item) {
1379
-                $ID         = absint($item->ID);
1380
-                $post_title = wp_strip_all_tags($item->post_title);
1381
-                $pad        = str_repeat('&nbsp;', $level * 3);
1382
-                $option     = "\n\t";
1383
-                $option     .= '<option class="level-' . $level . '" ';
1384
-                $option     .= 'value="' . $ID . '" ';
1385
-                $option     .= $ID === absint($default) ? ' selected' : '';
1386
-                $option     .= '>';
1387
-                $option     .= "$pad {$post_title}";
1388
-                $option     .= '</option>';
1389
-                $output     .= $option;
1390
-                ob_start();
1391
-                parent_dropdown($default, $item->ID, $level + 1);
1392
-                $output .= ob_get_clean();
1393
-            }
1394
-        }
1395
-        if ($echo) {
1396
-            echo wp_kses($output, AllowedTags::getWithFormTags());
1397
-            return '';
1398
-        }
1399
-        return $output;
1400
-    }
1401
-
1402
-
1403
-    /**
1404
-     * Loads the scripts for the privacy settings form
1405
-     */
1406
-    public function load_scripts_styles_privacy_settings()
1407
-    {
1408
-        $form_handler = $this->loader->getShared(
1409
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1410
-        );
1411
-        $form_handler->enqueueStylesAndScripts();
1412
-    }
1413
-
1414
-
1415
-    /**
1416
-     * display the privacy settings form
1417
-     *
1418
-     * @throws EE_Error
1419
-     */
1420
-    public function privacySettings()
1421
-    {
1422
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1423
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1424
-        $form_handler                               = $this->loader->getShared(
1425
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1426
-        );
1427
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1428
-            $form_handler->display(),
1429
-            '',
1430
-            'padding'
1431
-        );
1432
-        $this->display_admin_page_with_sidebar();
1433
-    }
1434
-
1435
-
1436
-    /**
1437
-     * Update the privacy settings from form data
1438
-     *
1439
-     * @throws EE_Error
1440
-     */
1441
-    public function updatePrivacySettings()
1442
-    {
1443
-        $form_handler = $this->loader->getShared(
1444
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1445
-        );
1446
-        $success      = $form_handler->process($this->get_request_data());
1447
-        $this->_redirect_after_action(
1448
-            $success,
1449
-            esc_html__('Registration Form Options', 'event_espresso'),
1450
-            'updated',
1451
-            ['action' => 'privacy_settings']
1452
-        );
1453
-    }
1349
+	}
1350
+
1351
+
1352
+	/**
1353
+	 * generates a dropdown of all parent pages - copied from WP core
1354
+	 *
1355
+	 * @param int  $default
1356
+	 * @param int  $parent
1357
+	 * @param int  $level
1358
+	 * @param bool $echo
1359
+	 * @return string;
1360
+	 */
1361
+	public static function page_settings_dropdown(
1362
+		int $default = 0,
1363
+		int $parent = 0,
1364
+		int $level = 0,
1365
+		bool $echo = true
1366
+	): string {
1367
+		global $wpdb;
1368
+		$items  = $wpdb->get_results(
1369
+			$wpdb->prepare(
1370
+				"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",
1371
+				$parent
1372
+			)
1373
+		);
1374
+		$output = '';
1375
+
1376
+		if ($items) {
1377
+			$level = absint($level);
1378
+			foreach ($items as $item) {
1379
+				$ID         = absint($item->ID);
1380
+				$post_title = wp_strip_all_tags($item->post_title);
1381
+				$pad        = str_repeat('&nbsp;', $level * 3);
1382
+				$option     = "\n\t";
1383
+				$option     .= '<option class="level-' . $level . '" ';
1384
+				$option     .= 'value="' . $ID . '" ';
1385
+				$option     .= $ID === absint($default) ? ' selected' : '';
1386
+				$option     .= '>';
1387
+				$option     .= "$pad {$post_title}";
1388
+				$option     .= '</option>';
1389
+				$output     .= $option;
1390
+				ob_start();
1391
+				parent_dropdown($default, $item->ID, $level + 1);
1392
+				$output .= ob_get_clean();
1393
+			}
1394
+		}
1395
+		if ($echo) {
1396
+			echo wp_kses($output, AllowedTags::getWithFormTags());
1397
+			return '';
1398
+		}
1399
+		return $output;
1400
+	}
1401
+
1402
+
1403
+	/**
1404
+	 * Loads the scripts for the privacy settings form
1405
+	 */
1406
+	public function load_scripts_styles_privacy_settings()
1407
+	{
1408
+		$form_handler = $this->loader->getShared(
1409
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1410
+		);
1411
+		$form_handler->enqueueStylesAndScripts();
1412
+	}
1413
+
1414
+
1415
+	/**
1416
+	 * display the privacy settings form
1417
+	 *
1418
+	 * @throws EE_Error
1419
+	 */
1420
+	public function privacySettings()
1421
+	{
1422
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1423
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1424
+		$form_handler                               = $this->loader->getShared(
1425
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1426
+		);
1427
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1428
+			$form_handler->display(),
1429
+			'',
1430
+			'padding'
1431
+		);
1432
+		$this->display_admin_page_with_sidebar();
1433
+	}
1434
+
1435
+
1436
+	/**
1437
+	 * Update the privacy settings from form data
1438
+	 *
1439
+	 * @throws EE_Error
1440
+	 */
1441
+	public function updatePrivacySettings()
1442
+	{
1443
+		$form_handler = $this->loader->getShared(
1444
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1445
+		);
1446
+		$success      = $form_handler->process($this->get_request_data());
1447
+		$this->_redirect_after_action(
1448
+			$success,
1449
+			esc_html__('Registration Form Options', 'event_espresso'),
1450
+			'updated',
1451
+			['action' => 'privacy_settings']
1452
+		);
1453
+	}
1454 1454
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/templates/espresso_page_settings.template.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
     </h2>
18 18
     <p class="ee-attention">
19 19
         <?php printf(
20
-            esc_html__(
21
-                'The following shortcodes and page settings are required for Event Espresso to function properly. These shortcodes should not be replaced with any other shortcodes. Please view %sthis page%s for a list of optional shortcodes you can use on other pages.',
22
-                'event_espresso'
23
-            ),
24
-            '<a href="admin.php?page=espresso_support">',
25
-            '</a>'
26
-        );
20
+			esc_html__(
21
+				'The following shortcodes and page settings are required for Event Espresso to function properly. These shortcodes should not be replaced with any other shortcodes. Please view %sthis page%s for a list of optional shortcodes you can use on other pages.',
22
+				'event_espresso'
23
+			),
24
+			'<a href="admin.php?page=espresso_support">',
25
+			'</a>'
26
+		);
27 27
 ?>
28 28
     </p>
29 29
 
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
                     </select>
55 55
                     <div class="ee-page-status__wrapper">
56 56
                     <?php echo General_Settings_Admin_Page::page_and_shortcode_status(
57
-                        $reg_page_obj,
58
-                        '[ESPRESSO_CHECKOUT]'
59
-                    ); // already escaped ?>
57
+						$reg_page_obj,
58
+						'[ESPRESSO_CHECKOUT]'
59
+					); // already escaped ?>
60 60
                     </div>
61 61
                     <br />
62 62
                     <p class="description">
63 63
                         <?php printf(
64
-                            esc_html__(
65
-                                'This page can be hidden from navigation if desired, but should always contain the %s shortcode.',
66
-                                'event_espresso'
67
-                            ),
68
-                            '<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_CHECKOUT]</span>'
69
-                        );
64
+							esc_html__(
65
+								'This page can be hidden from navigation if desired, but should always contain the %s shortcode.',
66
+								'event_espresso'
67
+							),
68
+							'<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_CHECKOUT]</span>'
69
+						);
70 70
 ?>
71 71
                     </p>
72 72
                     <br /><br />
@@ -101,19 +101,19 @@  discard block
 block discarded – undo
101 101
                     </select>
102 102
                     <div class='ee-page-status__wrapper'>
103 103
                     <?php echo General_Settings_Admin_Page::page_and_shortcode_status(
104
-                        $txn_page_obj,
105
-                        '[ESPRESSO_TXN_PAGE]'
106
-                    ); // already escaped ?>
104
+						$txn_page_obj,
105
+						'[ESPRESSO_TXN_PAGE]'
106
+					); // already escaped ?>
107 107
                     </div>
108 108
                     <br />
109 109
                     <p class="description">
110 110
                         <?php printf(
111
-                            esc_html__(
112
-                                'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain the %s shortcode.',
113
-                                'event_espresso'
114
-                            ),
115
-                            '<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_TXN_PAGE]</span>'
116
-                        );
111
+							esc_html__(
112
+								'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain the %s shortcode.',
113
+								'event_espresso'
114
+							),
115
+							'<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_TXN_PAGE]</span>'
116
+						);
117 117
 ?>
118 118
                     </p>
119 119
                     <br /><br />
@@ -144,19 +144,19 @@  discard block
 block discarded – undo
144 144
                     </select>
145 145
                     <div class='ee-page-status__wrapper'>
146 146
                     <?php echo General_Settings_Admin_Page::page_and_shortcode_status(
147
-                        $thank_you_page_obj,
148
-                        '[ESPRESSO_THANK_YOU]'
149
-                    ); // already escaped ?>
147
+						$thank_you_page_obj,
148
+						'[ESPRESSO_THANK_YOU]'
149
+					); // already escaped ?>
150 150
                     </div>
151 151
                     <br />
152 152
                     <p class="description">
153 153
                         <?php printf(
154
-                            esc_html__(
155
-                                'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain the %s shortcode.',
156
-                                'event_espresso'
157
-                            ),
158
-                            '<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_THANK_YOU]</span>'
159
-                        );
154
+							esc_html__(
155
+								'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain the %s shortcode.',
156
+								'event_espresso'
157
+							),
158
+							'<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_THANK_YOU]</span>'
159
+						);
160 160
 ?>
161 161
                     </p>
162 162
                     <br /><br />
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
                     </select>
188 188
                     <div class='ee-page-status__wrapper'>
189 189
                     <?php echo General_Settings_Admin_Page::page_and_shortcode_status(
190
-                        $cancel_page_obj,
191
-                        '[ESPRESSO_CANCELLED]'
192
-                    ); // already escaped ?>
190
+						$cancel_page_obj,
191
+						'[ESPRESSO_CANCELLED]'
192
+					); // already escaped ?>
193 193
                     </div>
194 194
                     <br />
195 195
                     <p class="description">
196 196
                         <?php printf(
197
-                            esc_html__(
198
-                                'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain a "cancelled transaction" message and the %s shortcode.',
199
-                                'event_espresso'
200
-                            ),
201
-                            '<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_CANCELLED]</span>'
202
-                        );
197
+							esc_html__(
198
+								'This page should be hidden from your navigation, but still viewable to the public (not password protected), and should always contain a "cancelled transaction" message and the %s shortcode.',
199
+								'event_espresso'
200
+							),
201
+							'<span class="highlight" style="padding:3px;margin:0;">[ESPRESSO_CANCELLED]</span>'
202
+						);
203 203
 ?>
204 204
                     </p>
205 205
                     <br /><br />
@@ -222,19 +222,19 @@  discard block
 block discarded – undo
222 222
                 <td>
223 223
                     <p class="description">
224 224
                         <?php esc_html_e(
225
-                            'Events are custom post types and use WordPress\' normal archive pages for displaying events.',
226
-                            'event_espresso'
227
-                        ) ?>
225
+							'Events are custom post types and use WordPress\' normal archive pages for displaying events.',
226
+							'event_espresso'
227
+						) ?>
228 228
                     </p>
229 229
                     <p class="description">
230 230
                         <?php printf(
231
-                            esc_html__(
232
-                                'If you would still like your events on a page like in Event Espresso 3.1 or earlier, simply create a page and place a shortcode to display them on the page, as described %s here %s',
233
-                                'event_espresso'
234
-                            ),
235
-                            '<a href="admin.php?page=espresso_support">',
236
-                            '</a>'
237
-                        ); ?>
231
+							esc_html__(
232
+								'If you would still like your events on a page like in Event Espresso 3.1 or earlier, simply create a page and place a shortcode to display them on the page, as described %s here %s',
233
+								'event_espresso'
234
+							),
235
+							'<a href="admin.php?page=espresso_support">',
236
+							'</a>'
237
+						); ?>
238 238
                     </p>
239 239
                     <br /><br />
240 240
                 </td>
@@ -256,19 +256,19 @@  discard block
 block discarded – undo
256 256
                 <td>
257 257
                     <p class="description">
258 258
                         <?php esc_html_e(
259
-                            'Venues are custom post types and use WordPress\' normal archive pages for displaying events.',
260
-                            'event_espresso'
261
-                        ) ?>
259
+							'Venues are custom post types and use WordPress\' normal archive pages for displaying events.',
260
+							'event_espresso'
261
+						) ?>
262 262
                     </p>
263 263
                     <p class="description">
264 264
                         <?php printf(
265
-                            esc_html__(
266
-                                'If you would still like your venues on a page like in Event Espresso 3.1 or earlier, simply create a page and place a shortcode to display them on the page, as described %s here %s',
267
-                                'event_espresso'
268
-                            ),
269
-                            '<a href="admin.php?page=espresso_support">',
270
-                            '</a>'
271
-                        ); ?>
265
+							esc_html__(
266
+								'If you would still like your venues on a page like in Event Espresso 3.1 or earlier, simply create a page and place a shortcode to display them on the page, as described %s here %s',
267
+								'event_espresso'
268
+							),
269
+							'<a href="admin.php?page=espresso_support">',
270
+							'</a>'
271
+						); ?>
272 272
                     </p>
273 273
                 </td>
274 274
             </tr>
Please login to merge, or discard this patch.
admin_pages/support/Support_Admin_Page.core.php 1 patch
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -11,244 +11,244 @@
 block discarded – undo
11 11
  */
12 12
 class Support_Admin_Page extends EE_Admin_Page
13 13
 {
14
-    protected function _init_page_props()
15
-    {
16
-        $this->page_slug = EE_SUPPORT_PG_SLUG;
17
-        $this->page_label = esc_html__('Help & Support', 'event_espresso');
18
-        $this->_admin_base_url = EE_SUPPORT_ADMIN_URL;
19
-        $this->_admin_base_path = EE_SUPPORT_ADMIN;
20
-    }
21
-
22
-
23
-    protected function _ajax_hooks()
24
-    {
25
-    }
26
-
27
-
28
-    protected function _define_page_props()
29
-    {
30
-        $this->_labels = array();
31
-        $this->_admin_page_title = $this->page_label;
32
-    }
33
-
34
-
35
-    protected function _set_page_routes()
36
-    {
37
-        $this->_page_routes = array(
38
-            'default'    => array(
39
-                'func'       => '_contact_support',
40
-                'capability' => 'ee_read_ee',
41
-            ),
42
-            'developers' => array(
43
-                'func'       => '_developers',
44
-                'capability' => 'ee_read_ee',
45
-            ),
46
-            'shortcodes' => array(
47
-                'func'       => '_shortcodes',
48
-                'capability' => 'ee_read_ee',
49
-            ),
50
-        );
51
-    }
52
-
53
-
54
-    protected function _set_page_config()
55
-    {
56
-        $this->_page_config = array(
57
-            'default'    => array(
58
-                'nav'           => array(
59
-                    'label' => esc_html__('Support', 'event_espresso'),
60
-                    'icon' => 'dashicons-sos',
61
-                    'order' => 30,
62
-                ),
63
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
64
-                'require_nonce' => false,
65
-            ),
66
-            'developers' => array(
67
-                'nav'           => array(
68
-                    'label' => esc_html__('Developers', 'event_espresso'),
69
-                    'icon' => 'dashicons-coffee',
70
-                    'order' => 50,
71
-                ),
72
-                'metaboxes'     => $this->_default_espresso_metaboxes,
73
-                'require_nonce' => false,
74
-            ),
75
-            'shortcodes' => array(
76
-                'nav'           => array(
77
-                    'label' => esc_html__('Shortcodes', 'event_espresso'),
78
-                    'icon' => 'dashicons-shortcode',
79
-                    'order' => 60,
80
-                ),
81
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
82
-                'require_nonce' => false,
83
-            ),
84
-        );
85
-    }
86
-
87
-
88
-    // none of the below group are currently used for Support pages
89
-    protected function _add_screen_options()
90
-    {
91
-    }
92
-
93
-
94
-    protected function _add_feature_pointers()
95
-    {
96
-    }
97
-
98
-
99
-    public function admin_init()
100
-    {
101
-    }
102
-
103
-
104
-    public function admin_notices()
105
-    {
106
-    }
107
-
108
-
109
-    public function admin_footer_scripts()
110
-    {
111
-    }
112
-
113
-
114
-    public function load_scripts_styles()
115
-    {
116
-    }
117
-
118
-
119
-    protected function _installation()
120
-    {
121
-        $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
122
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
123
-            $template_path,
124
-            '',
125
-            true
126
-        );
127
-        $this->display_admin_page_with_sidebar();
128
-    }
129
-
130
-
131
-    protected function _resources()
132
-    {
133
-        $this->display_admin_page_with_sidebar();
134
-    }
135
-
136
-
137
-    protected function _add_settings_metabox($box, $label, array $args)
138
-    {
139
-        $this->addMetaBox(
140
-            "espresso_{$box}_settings",
141
-            $label,
142
-            function ($post, $metabox) {
143
-                EEH_Template::display_template(
144
-                    $metabox['args']['template_path'],
145
-                    $metabox['args']['template_args']
146
-                );
147
-            },
148
-            $this->_current_screen->id,
149
-            'normal',
150
-            'high',
151
-            apply_filters(
152
-                "FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array",
153
-                $args
154
-            )
155
-        );
156
-    }
157
-
158
-
159
-    protected function _resources_boxes()
160
-    {
161
-        $boxes = apply_filters(
162
-            'FHEE__Support_Admin_Page___resources_boxes__boxes_array',
163
-            array(
164
-                'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'),
165
-                'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'),
166
-                'hire_developer'            => esc_html__('Hire a Developer', 'event_espresso'),
167
-                'partners'                  => esc_html__('Partners', 'event_espresso'),
168
-                'recommended_plugins'       => esc_html__('Recommended Plugins', 'event_espresso'),
169
-                'other_resources'           => esc_html__('Other Resources', 'event_espresso'),
170
-            )
171
-        );
172
-        foreach ($boxes as $box => $label) {
173
-            $this->_add_settings_metabox(
174
-                $box,
175
-                $label,
176
-                array(
177
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
178
-                    'template_args' => $this->_template_args,
179
-                )
180
-            );
181
-        }
182
-    }
183
-
184
-
185
-    protected function _shortcodes()
186
-    {
187
-        $this->display_admin_page_with_sidebar();
188
-    }
189
-
190
-
191
-    protected function _shortcodes_boxes()
192
-    {
193
-        $boxes = apply_filters(
194
-            'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array',
195
-            array(
196
-                'shortcodes_event_listings'  => esc_html__('Event Listings', 'event_espresso'),
197
-                'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'),
198
-                'shortcodes_category'        => esc_html__('Event Categories', 'event_espresso'),
199
-                'shortcodes_attendee'        => esc_html__('Event Attendees', 'event_espresso')
200
-                /*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/
201
-                /*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/
202
-            )
203
-        );
204
-        foreach ($boxes as $box => $label) {
205
-            $this->_add_settings_metabox(
206
-                $box,
207
-                $label,
208
-                array(
209
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
210
-                    'template_args' => $this->_template_args,
211
-                )
212
-            );
213
-        }
214
-    }
215
-
216
-
217
-    protected function _contact_support()
218
-    {
219
-        $this->display_admin_page_with_sidebar();
220
-    }
221
-
222
-
223
-    protected function _support_boxes()
224
-    {
225
-        $boxes = apply_filters(
226
-            'FHEE__Support_Admin_Page___support_boxes__boxes_array',
227
-            array(
228
-                'contact_support'       => esc_html__('Contact Support', 'event_espresso'),
229
-                'important_information' => esc_html__('Important Information', 'event_espresso'),
230
-            )
231
-        );
232
-        foreach ($boxes as $box => $label) {
233
-            $this->_add_settings_metabox(
234
-                $box,
235
-                $label,
236
-                array(
237
-                    'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
238
-                    'template_args' => $this->_template_args,
239
-                )
240
-            );
241
-        }
242
-    }
243
-
244
-
245
-    protected function _developers()
246
-    {
247
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
248
-            EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
249
-            array(),
250
-            true
251
-        );
252
-        $this->display_admin_page_with_sidebar();
253
-    }
14
+	protected function _init_page_props()
15
+	{
16
+		$this->page_slug = EE_SUPPORT_PG_SLUG;
17
+		$this->page_label = esc_html__('Help & Support', 'event_espresso');
18
+		$this->_admin_base_url = EE_SUPPORT_ADMIN_URL;
19
+		$this->_admin_base_path = EE_SUPPORT_ADMIN;
20
+	}
21
+
22
+
23
+	protected function _ajax_hooks()
24
+	{
25
+	}
26
+
27
+
28
+	protected function _define_page_props()
29
+	{
30
+		$this->_labels = array();
31
+		$this->_admin_page_title = $this->page_label;
32
+	}
33
+
34
+
35
+	protected function _set_page_routes()
36
+	{
37
+		$this->_page_routes = array(
38
+			'default'    => array(
39
+				'func'       => '_contact_support',
40
+				'capability' => 'ee_read_ee',
41
+			),
42
+			'developers' => array(
43
+				'func'       => '_developers',
44
+				'capability' => 'ee_read_ee',
45
+			),
46
+			'shortcodes' => array(
47
+				'func'       => '_shortcodes',
48
+				'capability' => 'ee_read_ee',
49
+			),
50
+		);
51
+	}
52
+
53
+
54
+	protected function _set_page_config()
55
+	{
56
+		$this->_page_config = array(
57
+			'default'    => array(
58
+				'nav'           => array(
59
+					'label' => esc_html__('Support', 'event_espresso'),
60
+					'icon' => 'dashicons-sos',
61
+					'order' => 30,
62
+				),
63
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
64
+				'require_nonce' => false,
65
+			),
66
+			'developers' => array(
67
+				'nav'           => array(
68
+					'label' => esc_html__('Developers', 'event_espresso'),
69
+					'icon' => 'dashicons-coffee',
70
+					'order' => 50,
71
+				),
72
+				'metaboxes'     => $this->_default_espresso_metaboxes,
73
+				'require_nonce' => false,
74
+			),
75
+			'shortcodes' => array(
76
+				'nav'           => array(
77
+					'label' => esc_html__('Shortcodes', 'event_espresso'),
78
+					'icon' => 'dashicons-shortcode',
79
+					'order' => 60,
80
+				),
81
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
82
+				'require_nonce' => false,
83
+			),
84
+		);
85
+	}
86
+
87
+
88
+	// none of the below group are currently used for Support pages
89
+	protected function _add_screen_options()
90
+	{
91
+	}
92
+
93
+
94
+	protected function _add_feature_pointers()
95
+	{
96
+	}
97
+
98
+
99
+	public function admin_init()
100
+	{
101
+	}
102
+
103
+
104
+	public function admin_notices()
105
+	{
106
+	}
107
+
108
+
109
+	public function admin_footer_scripts()
110
+	{
111
+	}
112
+
113
+
114
+	public function load_scripts_styles()
115
+	{
116
+	}
117
+
118
+
119
+	protected function _installation()
120
+	{
121
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
122
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
123
+			$template_path,
124
+			'',
125
+			true
126
+		);
127
+		$this->display_admin_page_with_sidebar();
128
+	}
129
+
130
+
131
+	protected function _resources()
132
+	{
133
+		$this->display_admin_page_with_sidebar();
134
+	}
135
+
136
+
137
+	protected function _add_settings_metabox($box, $label, array $args)
138
+	{
139
+		$this->addMetaBox(
140
+			"espresso_{$box}_settings",
141
+			$label,
142
+			function ($post, $metabox) {
143
+				EEH_Template::display_template(
144
+					$metabox['args']['template_path'],
145
+					$metabox['args']['template_args']
146
+				);
147
+			},
148
+			$this->_current_screen->id,
149
+			'normal',
150
+			'high',
151
+			apply_filters(
152
+				"FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array",
153
+				$args
154
+			)
155
+		);
156
+	}
157
+
158
+
159
+	protected function _resources_boxes()
160
+	{
161
+		$boxes = apply_filters(
162
+			'FHEE__Support_Admin_Page___resources_boxes__boxes_array',
163
+			array(
164
+				'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'),
165
+				'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'),
166
+				'hire_developer'            => esc_html__('Hire a Developer', 'event_espresso'),
167
+				'partners'                  => esc_html__('Partners', 'event_espresso'),
168
+				'recommended_plugins'       => esc_html__('Recommended Plugins', 'event_espresso'),
169
+				'other_resources'           => esc_html__('Other Resources', 'event_espresso'),
170
+			)
171
+		);
172
+		foreach ($boxes as $box => $label) {
173
+			$this->_add_settings_metabox(
174
+				$box,
175
+				$label,
176
+				array(
177
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
178
+					'template_args' => $this->_template_args,
179
+				)
180
+			);
181
+		}
182
+	}
183
+
184
+
185
+	protected function _shortcodes()
186
+	{
187
+		$this->display_admin_page_with_sidebar();
188
+	}
189
+
190
+
191
+	protected function _shortcodes_boxes()
192
+	{
193
+		$boxes = apply_filters(
194
+			'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array',
195
+			array(
196
+				'shortcodes_event_listings'  => esc_html__('Event Listings', 'event_espresso'),
197
+				'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'),
198
+				'shortcodes_category'        => esc_html__('Event Categories', 'event_espresso'),
199
+				'shortcodes_attendee'        => esc_html__('Event Attendees', 'event_espresso')
200
+				/*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/
201
+				/*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/
202
+			)
203
+		);
204
+		foreach ($boxes as $box => $label) {
205
+			$this->_add_settings_metabox(
206
+				$box,
207
+				$label,
208
+				array(
209
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
210
+					'template_args' => $this->_template_args,
211
+				)
212
+			);
213
+		}
214
+	}
215
+
216
+
217
+	protected function _contact_support()
218
+	{
219
+		$this->display_admin_page_with_sidebar();
220
+	}
221
+
222
+
223
+	protected function _support_boxes()
224
+	{
225
+		$boxes = apply_filters(
226
+			'FHEE__Support_Admin_Page___support_boxes__boxes_array',
227
+			array(
228
+				'contact_support'       => esc_html__('Contact Support', 'event_espresso'),
229
+				'important_information' => esc_html__('Important Information', 'event_espresso'),
230
+			)
231
+		);
232
+		foreach ($boxes as $box => $label) {
233
+			$this->_add_settings_metabox(
234
+				$box,
235
+				$label,
236
+				array(
237
+					'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php",
238
+					'template_args' => $this->_template_args,
239
+				)
240
+			);
241
+		}
242
+	}
243
+
244
+
245
+	protected function _developers()
246
+	{
247
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
248
+			EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php',
249
+			array(),
250
+			true
251
+		);
252
+		$this->display_admin_page_with_sidebar();
253
+	}
254 254
 }
Please login to merge, or discard this patch.
admin/extend/transactions/Extend_Transactions_Admin_Page.core.php 1 patch
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -14,247 +14,247 @@
 block discarded – undo
14 14
  */
15 15
 class Extend_Transactions_Admin_Page extends Transactions_Admin_Page
16 16
 {
17
-    /**
18
-     * This is used to hold the reports template data which is setup early in the request.
19
-     *
20
-     * @type array
21
-     */
22
-    protected $_reports_template_data = array();
23
-
24
-    /**
25
-     * @Constructor
26
-     * @access public
27
-     *
28
-     * @param bool $routing
29
-     *
30
-     * @return \Extend_Transactions_Admin_Page
31
-     */
32
-    public function __construct($routing = true)
33
-    {
34
-        parent::__construct($routing);
35
-        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
36
-        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
37
-        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
38
-    }
39
-
40
-
41
-    /**
42
-     *    _extend_page_config
43
-     *
44
-     * @access protected
45
-     * @return void
46
-     */
47
-    protected function _extend_page_config()
48
-    {
49
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
50
-
51
-        $new_page_routes = array(
52
-            'reports' => array(
53
-                'func'       => '_transaction_reports',
54
-                'capability' => 'ee_read_transactions',
55
-            ),
56
-        );
57
-
58
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
59
-
60
-        $new_page_config = array(
61
-            'reports' => array(
62
-                'nav'           => array(
63
-                    'label' => esc_html__('Reports', 'event_espresso'),
64
-                    'icon' => 'dashicons-chart-bar',
65
-                    'order' => 20,
66
-                ),
67
-                'help_tabs'     => array(
68
-                    'transactions_reports_help_tab' => array(
69
-                        'title'    => esc_html__('Transaction Reports', 'event_espresso'),
70
-                        'filename' => 'transactions_reports',
71
-                    ),
72
-                ),
73
-                'require_nonce' => false,
74
-            ),
75
-        );
76
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
77
-    }
78
-
79
-
80
-    /**
81
-     *    load_scripts_styles_reports
82
-     *
83
-     * @access public
84
-     * @return void
85
-     */
86
-    public function load_scripts_styles_reports()
87
-    {
88
-        wp_register_script(
89
-            'ee-txn-reports-js',
90
-            TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
91
-            array('google-charts'),
92
-            EVENT_ESPRESSO_VERSION,
93
-            true
94
-        );
95
-        wp_enqueue_script('ee-txn-reports-js');
96
-        $this->_transaction_reports_js_setup();
97
-        EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
98
-    }
99
-
100
-
101
-    /**
102
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
103
-     * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method.
104
-     */
105
-    protected function _transaction_reports_js_setup()
106
-    {
107
-        $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report();
108
-        $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report();
109
-    }
110
-
111
-
112
-    /**
113
-     * _transaction_reports
114
-     *    generates Business Reports regarding Transactions
115
-     *
116
-     * @return void
117
-     */
118
-    protected function _transaction_reports()
119
-    {
120
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
121
-        $this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
122
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
123
-            $template_path,
124
-            $this->_reports_template_data,
125
-            true
126
-        );
127
-
128
-        // the final template wrapper
129
-        $this->display_admin_page_with_no_sidebar();
130
-    }
131
-
132
-
133
-    /**
134
-     * _revenue_per_day_report
135
-     * generates Business Report showing Total Revenue per Day.
136
-     *
137
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
138
-     *
139
-     * @return string
140
-     */
141
-    private function _revenue_per_day_report($period = '-1 month')
142
-    {
143
-
144
-        $report_ID = 'txn-admin-revenue-per-day-report-dv';
145
-
146
-        $TXN = EEM_Transaction::instance();
147
-
148
-        $results = $TXN->get_revenue_per_day_report($period);
149
-        $results = (array) $results;
150
-        $revenue = array();
151
-        $subtitle = '';
152
-
153
-        if ($results) {
154
-            $revenue[] = array(
155
-                esc_html__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'),
156
-                esc_html__('Total Revenue', 'event_espresso'),
157
-            );
158
-            foreach ($results as $result) {
159
-                $revenue[] = array($result->txnDate, (float) $result->revenue);
160
-            }
161
-
162
-            // setup the date range.
163
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
164
-            $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
165
-            $subtitle = sprintf(
166
-                wp_strip_all_tags(
167
-                    _x('For the period: %s to %s', 'Used to give date range', 'event_espresso')
168
-                ),
169
-                $beginning_date->format('Y-m-d'),
170
-                $ending_date->format('Y-m-d')
171
-            );
172
-        }
173
-
174
-        $report_title = wp_strip_all_tags(__('Total Revenue per Day', 'event_espresso'));
175
-
176
-        $report_params = array(
177
-            'title'     => $report_title,
178
-            'subtitle'  => $subtitle,
179
-            'id'        => $report_ID,
180
-            'revenue'   => $revenue,
181
-            'noResults' => empty($revenue) || count($revenue) === 1,
182
-            'noTxnMsg'  => sprintf(
183
-                wp_strip_all_tags(
184
-                    __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso')
185
-                ),
186
-                '<h2>' . $report_title . '</h2><p>',
187
-                '</p>'
188
-            ),
189
-        );
190
-        wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
191
-
192
-        return $report_ID;
193
-    }
194
-
195
-
196
-    /**
197
-     * _revenue_per_event_report
198
-     * generates Business Report showing total revenue per event.
199
-     *
200
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
201
-     *
202
-     * @return int
203
-     */
204
-    private function _revenue_per_event_report($period = '-1 month')
205
-    {
206
-
207
-        $report_ID = 'txn-admin-revenue-per-event-report-dv';
208
-
209
-        $TXN = EEM_Transaction::instance();
210
-        $results = $TXN->get_revenue_per_event_report($period);
211
-        $results = (array) $results;
212
-        $revenue = array();
213
-        $subtitle = '';
214
-
215
-        if ($results) {
216
-            $revenue[] = array(
217
-                esc_html__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'),
218
-                esc_html__('Total Revenue', 'event_espresso'),
219
-            );
220
-            foreach ($results as $result) {
221
-                if ($result->revenue > 1) {
222
-                    $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
223
-                    $event_name = wp_trim_words($event_name, 5, '...');
224
-                    $revenue[] = array($event_name, (float) $result->revenue);
225
-                }
226
-            }
227
-
228
-            // setup the date range.
229
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
230
-            $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
231
-            $subtitle = sprintf(
232
-                wp_strip_all_tags(
233
-                    _x('For the period: %s to %s', 'Used to give date range', 'event_espresso')
234
-                ),
235
-                $beginning_date->format('Y-m-d'),
236
-                $ending_date->format('Y-m-d')
237
-            );
238
-        }
239
-
240
-        $report_title = wp_strip_all_tags(__('Total Revenue per Event', 'event_espresso'));
241
-
242
-        $report_params = array(
243
-            'title'     => $report_title,
244
-            'subtitle'  => $subtitle,
245
-            'id'        => $report_ID,
246
-            'revenue'   => $revenue,
247
-            'noResults' => empty($revenue),
248
-            'noTxnMsg'  => sprintf(
249
-                wp_strip_all_tags(
250
-                    __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso')
251
-                ),
252
-                '<h2>' . $report_title . '</h2><p>',
253
-                '</p>'
254
-            ),
255
-        );
256
-        wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
257
-
258
-        return $report_ID;
259
-    }
17
+	/**
18
+	 * This is used to hold the reports template data which is setup early in the request.
19
+	 *
20
+	 * @type array
21
+	 */
22
+	protected $_reports_template_data = array();
23
+
24
+	/**
25
+	 * @Constructor
26
+	 * @access public
27
+	 *
28
+	 * @param bool $routing
29
+	 *
30
+	 * @return \Extend_Transactions_Admin_Page
31
+	 */
32
+	public function __construct($routing = true)
33
+	{
34
+		parent::__construct($routing);
35
+		define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
36
+		define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
37
+		define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
38
+	}
39
+
40
+
41
+	/**
42
+	 *    _extend_page_config
43
+	 *
44
+	 * @access protected
45
+	 * @return void
46
+	 */
47
+	protected function _extend_page_config()
48
+	{
49
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
50
+
51
+		$new_page_routes = array(
52
+			'reports' => array(
53
+				'func'       => '_transaction_reports',
54
+				'capability' => 'ee_read_transactions',
55
+			),
56
+		);
57
+
58
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
59
+
60
+		$new_page_config = array(
61
+			'reports' => array(
62
+				'nav'           => array(
63
+					'label' => esc_html__('Reports', 'event_espresso'),
64
+					'icon' => 'dashicons-chart-bar',
65
+					'order' => 20,
66
+				),
67
+				'help_tabs'     => array(
68
+					'transactions_reports_help_tab' => array(
69
+						'title'    => esc_html__('Transaction Reports', 'event_espresso'),
70
+						'filename' => 'transactions_reports',
71
+					),
72
+				),
73
+				'require_nonce' => false,
74
+			),
75
+		);
76
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
77
+	}
78
+
79
+
80
+	/**
81
+	 *    load_scripts_styles_reports
82
+	 *
83
+	 * @access public
84
+	 * @return void
85
+	 */
86
+	public function load_scripts_styles_reports()
87
+	{
88
+		wp_register_script(
89
+			'ee-txn-reports-js',
90
+			TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
91
+			array('google-charts'),
92
+			EVENT_ESPRESSO_VERSION,
93
+			true
94
+		);
95
+		wp_enqueue_script('ee-txn-reports-js');
96
+		$this->_transaction_reports_js_setup();
97
+		EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
98
+	}
99
+
100
+
101
+	/**
102
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
103
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method.
104
+	 */
105
+	protected function _transaction_reports_js_setup()
106
+	{
107
+		$this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report();
108
+		$this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report();
109
+	}
110
+
111
+
112
+	/**
113
+	 * _transaction_reports
114
+	 *    generates Business Reports regarding Transactions
115
+	 *
116
+	 * @return void
117
+	 */
118
+	protected function _transaction_reports()
119
+	{
120
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
121
+		$this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
122
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
123
+			$template_path,
124
+			$this->_reports_template_data,
125
+			true
126
+		);
127
+
128
+		// the final template wrapper
129
+		$this->display_admin_page_with_no_sidebar();
130
+	}
131
+
132
+
133
+	/**
134
+	 * _revenue_per_day_report
135
+	 * generates Business Report showing Total Revenue per Day.
136
+	 *
137
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
138
+	 *
139
+	 * @return string
140
+	 */
141
+	private function _revenue_per_day_report($period = '-1 month')
142
+	{
143
+
144
+		$report_ID = 'txn-admin-revenue-per-day-report-dv';
145
+
146
+		$TXN = EEM_Transaction::instance();
147
+
148
+		$results = $TXN->get_revenue_per_day_report($period);
149
+		$results = (array) $results;
150
+		$revenue = array();
151
+		$subtitle = '';
152
+
153
+		if ($results) {
154
+			$revenue[] = array(
155
+				esc_html__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'),
156
+				esc_html__('Total Revenue', 'event_espresso'),
157
+			);
158
+			foreach ($results as $result) {
159
+				$revenue[] = array($result->txnDate, (float) $result->revenue);
160
+			}
161
+
162
+			// setup the date range.
163
+			$beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
164
+			$ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
165
+			$subtitle = sprintf(
166
+				wp_strip_all_tags(
167
+					_x('For the period: %s to %s', 'Used to give date range', 'event_espresso')
168
+				),
169
+				$beginning_date->format('Y-m-d'),
170
+				$ending_date->format('Y-m-d')
171
+			);
172
+		}
173
+
174
+		$report_title = wp_strip_all_tags(__('Total Revenue per Day', 'event_espresso'));
175
+
176
+		$report_params = array(
177
+			'title'     => $report_title,
178
+			'subtitle'  => $subtitle,
179
+			'id'        => $report_ID,
180
+			'revenue'   => $revenue,
181
+			'noResults' => empty($revenue) || count($revenue) === 1,
182
+			'noTxnMsg'  => sprintf(
183
+				wp_strip_all_tags(
184
+					__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso')
185
+				),
186
+				'<h2>' . $report_title . '</h2><p>',
187
+				'</p>'
188
+			),
189
+		);
190
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
191
+
192
+		return $report_ID;
193
+	}
194
+
195
+
196
+	/**
197
+	 * _revenue_per_event_report
198
+	 * generates Business Report showing total revenue per event.
199
+	 *
200
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
201
+	 *
202
+	 * @return int
203
+	 */
204
+	private function _revenue_per_event_report($period = '-1 month')
205
+	{
206
+
207
+		$report_ID = 'txn-admin-revenue-per-event-report-dv';
208
+
209
+		$TXN = EEM_Transaction::instance();
210
+		$results = $TXN->get_revenue_per_event_report($period);
211
+		$results = (array) $results;
212
+		$revenue = array();
213
+		$subtitle = '';
214
+
215
+		if ($results) {
216
+			$revenue[] = array(
217
+				esc_html__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'),
218
+				esc_html__('Total Revenue', 'event_espresso'),
219
+			);
220
+			foreach ($results as $result) {
221
+				if ($result->revenue > 1) {
222
+					$event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
223
+					$event_name = wp_trim_words($event_name, 5, '...');
224
+					$revenue[] = array($event_name, (float) $result->revenue);
225
+				}
226
+			}
227
+
228
+			// setup the date range.
229
+			$beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
230
+			$ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
231
+			$subtitle = sprintf(
232
+				wp_strip_all_tags(
233
+					_x('For the period: %s to %s', 'Used to give date range', 'event_espresso')
234
+				),
235
+				$beginning_date->format('Y-m-d'),
236
+				$ending_date->format('Y-m-d')
237
+			);
238
+		}
239
+
240
+		$report_title = wp_strip_all_tags(__('Total Revenue per Event', 'event_espresso'));
241
+
242
+		$report_params = array(
243
+			'title'     => $report_title,
244
+			'subtitle'  => $subtitle,
245
+			'id'        => $report_ID,
246
+			'revenue'   => $revenue,
247
+			'noResults' => empty($revenue),
248
+			'noTxnMsg'  => sprintf(
249
+				wp_strip_all_tags(
250
+					__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso')
251
+				),
252
+				'<h2>' . $report_title . '</h2><p>',
253
+				'</p>'
254
+			),
255
+		);
256
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
257
+
258
+		return $report_ID;
259
+	}
260 260
 }
Please login to merge, or discard this patch.
admin/extend/registration_form/Extend_Registration_Form_Admin_Page.core.php 1 patch
Indentation   +1440 added lines, -1440 removed lines patch added patch discarded remove patch
@@ -14,1444 +14,1444 @@
 block discarded – undo
14 14
  */
15 15
 class Extend_Registration_Form_Admin_Page extends Registration_Form_Admin_Page
16 16
 {
17
-    /**
18
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
19
-     */
20
-    public function __construct($routing = true)
21
-    {
22
-        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/');
23
-        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/');
24
-        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
25
-        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/');
26
-        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
27
-        parent::__construct($routing);
28
-    }
29
-
30
-
31
-    /**
32
-     * @return void
33
-     */
34
-    protected function _extend_page_config()
35
-    {
36
-        $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
37
-        $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID'])
38
-            ? $this->_req_data['QST_ID'] : 0;
39
-        $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID'])
40
-            ? $this->_req_data['QSG_ID'] : 0;
41
-
42
-        $new_page_routes = array(
43
-            'question_groups'    => array(
44
-                'func'       => '_question_groups_overview_list_table',
45
-                'capability' => 'ee_read_question_groups',
46
-            ),
47
-            'add_question'       => array(
48
-                'func'       => '_edit_question',
49
-                'capability' => 'ee_edit_questions',
50
-            ),
51
-            'insert_question'    => array(
52
-                'func'       => '_insert_or_update_question',
53
-                'args'       => array('new_question' => true),
54
-                'capability' => 'ee_edit_questions',
55
-                'noheader'   => true,
56
-            ),
57
-            'duplicate_question' => array(
58
-                'func'       => '_duplicate_question',
59
-                'capability' => 'ee_edit_questions',
60
-                'noheader'   => true,
61
-            ),
62
-            'trash_question'     => array(
63
-                'func'       => '_trash_question',
64
-                'capability' => 'ee_delete_question',
65
-                'obj_id'     => $qst_id,
66
-                'noheader'   => true,
67
-            ),
68
-
69
-            'restore_question' => array(
70
-                'func'       => '_trash_or_restore_questions',
71
-                'capability' => 'ee_delete_question',
72
-                'obj_id'     => $qst_id,
73
-                'args'       => array('trash' => false),
74
-                'noheader'   => true,
75
-            ),
76
-
77
-            'delete_question' => array(
78
-                'func'       => '_delete_question',
79
-                'capability' => 'ee_delete_question',
80
-                'obj_id'     => $qst_id,
81
-                'noheader'   => true,
82
-            ),
83
-
84
-            'trash_questions' => array(
85
-                'func'       => '_trash_or_restore_questions',
86
-                'capability' => 'ee_delete_questions',
87
-                'args'       => array('trash' => true),
88
-                'noheader'   => true,
89
-            ),
90
-
91
-            'restore_questions' => array(
92
-                'func'       => '_trash_or_restore_questions',
93
-                'capability' => 'ee_delete_questions',
94
-                'args'       => array('trash' => false),
95
-                'noheader'   => true,
96
-            ),
97
-
98
-            'delete_questions' => array(
99
-                'func'       => '_delete_questions',
100
-                'args'       => array(),
101
-                'capability' => 'ee_delete_questions',
102
-                'noheader'   => true,
103
-            ),
104
-
105
-            'add_question_group' => array(
106
-                'func'       => '_edit_question_group',
107
-                'capability' => 'ee_edit_question_groups',
108
-            ),
109
-
110
-            'edit_question_group' => array(
111
-                'func'       => '_edit_question_group',
112
-                'capability' => 'ee_edit_question_group',
113
-                'obj_id'     => $qsg_id,
114
-                'args'       => array('edit'),
115
-            ),
116
-
117
-            'delete_question_groups' => array(
118
-                'func'       => '_delete_question_groups',
119
-                'capability' => 'ee_delete_question_groups',
120
-                'noheader'   => true,
121
-            ),
122
-
123
-            'delete_question_group' => array(
124
-                'func'       => '_delete_question_groups',
125
-                'capability' => 'ee_delete_question_group',
126
-                'obj_id'     => $qsg_id,
127
-                'noheader'   => true,
128
-            ),
129
-
130
-            'trash_question_group' => array(
131
-                'func'       => '_trash_or_restore_question_groups',
132
-                'args'       => array('trash' => true),
133
-                'capability' => 'ee_delete_question_group',
134
-                'obj_id'     => $qsg_id,
135
-                'noheader'   => true,
136
-            ),
137
-
138
-            'restore_question_group' => array(
139
-                'func'       => '_trash_or_restore_question_groups',
140
-                'args'       => array('trash' => false),
141
-                'capability' => 'ee_delete_question_group',
142
-                'obj_id'     => $qsg_id,
143
-                'noheader'   => true,
144
-            ),
145
-
146
-            'insert_question_group' => array(
147
-                'func'       => '_insert_or_update_question_group',
148
-                'args'       => array('new_question_group' => true),
149
-                'capability' => 'ee_edit_question_groups',
150
-                'noheader'   => true,
151
-            ),
152
-
153
-            'update_question_group' => array(
154
-                'func'       => '_insert_or_update_question_group',
155
-                'args'       => array('new_question_group' => false),
156
-                'capability' => 'ee_edit_question_group',
157
-                'obj_id'     => $qsg_id,
158
-                'noheader'   => true,
159
-            ),
160
-
161
-            'trash_question_groups' => array(
162
-                'func'       => '_trash_or_restore_question_groups',
163
-                'args'       => array('trash' => true),
164
-                'capability' => 'ee_delete_question_groups',
165
-                'noheader'   => array('trash' => false),
166
-            ),
167
-
168
-            'restore_question_groups' => array(
169
-                'func'       => '_trash_or_restore_question_groups',
170
-                'args'       => array('trash' => false),
171
-                'capability' => 'ee_delete_question_groups',
172
-                'noheader'   => true,
173
-            ),
174
-
175
-
176
-            'espresso_update_question_group_order' => array(
177
-                'func'       => 'update_question_group_order',
178
-                'capability' => 'ee_edit_question_groups',
179
-                'noheader'   => true,
180
-            ),
181
-
182
-            'view_reg_form_settings' => array(
183
-                'func'       => '_reg_form_settings',
184
-                'capability' => 'manage_options',
185
-            ),
186
-
187
-            'update_reg_form_settings' => array(
188
-                'func'       => '_update_reg_form_settings',
189
-                'capability' => 'manage_options',
190
-                'noheader'   => true,
191
-            ),
192
-        );
193
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
194
-
195
-        $new_page_config = array(
196
-
197
-            'question_groups' => array(//dashicons-editor-help
198
-                'nav'           => array(
199
-                    'label' => esc_html__('Question Groups', 'event_espresso'),
200
-                    'icon' => 'dashicons-forms',
201
-                    'order' => 20,
202
-                ),
203
-                'list_table'    => 'Registration_Form_Question_Groups_Admin_List_Table',
204
-                'help_tabs'     => array(
205
-                    'registration_form_question_groups_help_tab'                           => array(
206
-                        'title'    => esc_html__('Question Groups', 'event_espresso'),
207
-                        'filename' => 'registration_form_question_groups',
208
-                    ),
209
-                    'registration_form_question_groups_table_column_headings_help_tab'     => array(
210
-                        'title'    => esc_html__('Question Groups Table Column Headings', 'event_espresso'),
211
-                        'filename' => 'registration_form_question_groups_table_column_headings',
212
-                    ),
213
-                    'registration_form_question_groups_views_bulk_actions_search_help_tab' => array(
214
-                        'title'    => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'),
215
-                        'filename' => 'registration_form_question_groups_views_bulk_actions_search',
216
-                    ),
217
-                ),
218
-                'metaboxes'     => $this->_default_espresso_metaboxes,
219
-                'require_nonce' => false,
220
-            ),
221
-
222
-            'add_question' => array(
223
-                'nav'           => array(
224
-                    'label'      => esc_html__('Add Question', 'event_espresso'),
225
-                    'icon' => 'dashicons-plus-alt',
226
-                    'order'      => 15,
227
-                    'persistent' => false,
228
-                ),
229
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
230
-                'help_tabs'     => array(
231
-                    'registration_form_add_question_help_tab' => array(
232
-                        'title'    => esc_html__('Add Question', 'event_espresso'),
233
-                        'filename' => 'registration_form_add_question',
234
-                    ),
235
-                ),
236
-                'require_nonce' => false,
237
-            ),
238
-
239
-            'add_question_group' => array(
240
-                'nav'           => array(
241
-                    'label'      => esc_html__('Add Question Group', 'event_espresso'),
242
-                    'icon' => 'dashicons-plus-alt',
243
-                    'order'      => 25,
244
-                    'persistent' => false,
245
-                ),
246
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
247
-                'help_tabs'     => array(
248
-                    'registration_form_add_question_group_help_tab' => array(
249
-                        'title'    => esc_html__('Add Question Group', 'event_espresso'),
250
-                        'filename' => 'registration_form_add_question_group',
251
-                    ),
252
-                ),
253
-                'require_nonce' => false,
254
-            ),
255
-
256
-            'edit_question_group' => array(
257
-                'nav'           => array(
258
-                    'label'      => esc_html__('Edit Question Group', 'event_espresso'),
259
-                    'icon' => 'dashicons-edit-large',
260
-                    'order'      => 25,
261
-                    'persistent' => false,
262
-                    'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(
263
-                        array('question_group_id' => $this->_req_data['question_group_id']),
264
-                        $this->_current_page_view_url
265
-                    ) : $this->_admin_base_url,
266
-                ),
267
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
268
-                'help_tabs'     => array(
269
-                    'registration_form_edit_question_group_help_tab' => array(
270
-                        'title'    => esc_html__('Edit Question Group', 'event_espresso'),
271
-                        'filename' => 'registration_form_edit_question_group',
272
-                    ),
273
-                ),
274
-                'require_nonce' => false,
275
-            ),
276
-
277
-            'view_reg_form_settings' => array(
278
-                'nav'           => array(
279
-                    'label' => esc_html__('Reg Form Settings', 'event_espresso'),
280
-                    'icon' => 'dashicons-admin-generic',
281
-                    'order' => 40,
282
-                ),
283
-                'labels'        => array(
284
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
285
-                ),
286
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
287
-                'help_tabs'     => array(
288
-                    'registration_form_reg_form_settings_help_tab' => array(
289
-                        'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
290
-                        'filename' => 'registration_form_reg_form_settings',
291
-                    ),
292
-                ),
293
-                'require_nonce' => false,
294
-            ),
295
-
296
-        );
297
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
298
-
299
-        // change the list table we're going to use so it's the NEW list table!
300
-        $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
301
-
302
-
303
-        // additional labels
304
-        $new_labels = array(
305
-            'add_question'          => esc_html__('Add New Question', 'event_espresso'),
306
-            'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
307
-            'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
308
-            'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
309
-            'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
310
-        );
311
-        $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
312
-    }
313
-
314
-
315
-    /**
316
-     * @return void
317
-     */
318
-    protected function _ajax_hooks()
319
-    {
320
-        add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
321
-    }
322
-
323
-
324
-    /**
325
-     * @return void
326
-     */
327
-    public function load_scripts_styles_question_groups()
328
-    {
329
-        wp_enqueue_script('espresso_ajax_table_sorting');
330
-    }
331
-
332
-
333
-    /**
334
-     * @return void
335
-     */
336
-    public function load_scripts_styles_add_question_group()
337
-    {
338
-        $this->load_scripts_styles_forms();
339
-        $this->load_sortable_question_script();
340
-    }
341
-
342
-
343
-    /**
344
-     * @return void
345
-     */
346
-    public function load_scripts_styles_edit_question_group()
347
-    {
348
-        $this->load_scripts_styles_forms();
349
-        $this->load_sortable_question_script();
350
-    }
351
-
352
-
353
-    /**
354
-     * registers and enqueues script for questions
355
-     *
356
-     * @return void
357
-     */
358
-    public function load_sortable_question_script()
359
-    {
360
-        wp_register_script(
361
-            'ee-question-sortable',
362
-            REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
363
-            array('jquery-ui-sortable'),
364
-            EVENT_ESPRESSO_VERSION,
365
-            true
366
-        );
367
-        wp_enqueue_script('ee-question-sortable');
368
-    }
369
-
370
-
371
-    /**
372
-     * @return void
373
-     */
374
-    protected function _set_list_table_views_default()
375
-    {
376
-        $this->_views = array(
377
-            'all' => array(
378
-                'slug'        => 'all',
379
-                'label'       => esc_html__('View All Questions', 'event_espresso'),
380
-                'count'       => 0,
381
-                'bulk_action' => array(
382
-                    'trash_questions' => esc_html__('Trash', 'event_espresso'),
383
-                ),
384
-            ),
385
-        );
386
-
387
-        if (
388
-            EE_Registry::instance()->CAP->current_user_can(
389
-                'ee_delete_questions',
390
-                'espresso_registration_form_trash_questions'
391
-            )
392
-        ) {
393
-            $this->_views['trash'] = array(
394
-                'slug'        => 'trash',
395
-                'label'       => esc_html__('Trash', 'event_espresso'),
396
-                'count'       => 0,
397
-                'bulk_action' => array(
398
-                    'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
399
-                    'restore_questions' => esc_html__('Restore', 'event_espresso'),
400
-                ),
401
-            );
402
-        }
403
-    }
404
-
405
-
406
-    /**
407
-     * @return void
408
-     */
409
-    protected function _set_list_table_views_question_groups()
410
-    {
411
-        $this->_views = array(
412
-            'all' => array(
413
-                'slug'        => 'all',
414
-                'label'       => esc_html__('All', 'event_espresso'),
415
-                'count'       => 0,
416
-                'bulk_action' => array(
417
-                    'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
418
-                ),
419
-            ),
420
-        );
421
-
422
-        if (
423
-            EE_Registry::instance()->CAP->current_user_can(
424
-                'ee_delete_question_groups',
425
-                'espresso_registration_form_trash_question_groups'
426
-            )
427
-        ) {
428
-            $this->_views['trash'] = array(
429
-                'slug'        => 'trash',
430
-                'label'       => esc_html__('Trash', 'event_espresso'),
431
-                'count'       => 0,
432
-                'bulk_action' => array(
433
-                    'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
434
-                    'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
435
-                ),
436
-            );
437
-        }
438
-    }
439
-
440
-
441
-    /**
442
-     * @return void
443
-     * @throws EE_Error
444
-     * @throws InvalidArgumentException
445
-     * @throws InvalidDataTypeException
446
-     * @throws InvalidInterfaceException
447
-     */
448
-    protected function _questions_overview_list_table()
449
-    {
450
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
451
-            'add_question',
452
-            'add_question',
453
-            array(),
454
-            'add-new-h2'
455
-        );
456
-        parent::_questions_overview_list_table();
457
-    }
458
-
459
-
460
-    /**
461
-     * @return void
462
-     * @throws DomainException
463
-     * @throws EE_Error
464
-     * @throws InvalidArgumentException
465
-     * @throws InvalidDataTypeException
466
-     * @throws InvalidInterfaceException
467
-     */
468
-    protected function _question_groups_overview_list_table()
469
-    {
470
-        $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
471
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
472
-            'add_question_group',
473
-            'add_question_group',
474
-            array(),
475
-            'add-new-h2'
476
-        );
477
-        $this->display_admin_list_table_page_with_sidebar();
478
-    }
479
-
480
-
481
-    /**
482
-     * @return void
483
-     * @throws EE_Error
484
-     * @throws InvalidArgumentException
485
-     * @throws InvalidDataTypeException
486
-     * @throws InvalidInterfaceException
487
-     */
488
-    protected function _delete_question()
489
-    {
490
-        $success = $this->_delete_items($this->_question_model);
491
-        $this->_redirect_after_action(
492
-            $success,
493
-            $this->_question_model->item_name($success),
494
-            'deleted',
495
-            array('action' => 'default', 'status' => 'all')
496
-        );
497
-    }
498
-
499
-
500
-    /**
501
-     * @return void
502
-     * @throws EE_Error
503
-     * @throws InvalidArgumentException
504
-     * @throws InvalidDataTypeException
505
-     * @throws InvalidInterfaceException
506
-     */
507
-    protected function _delete_questions()
508
-    {
509
-        $success = $this->_delete_items($this->_question_model);
510
-        $this->_redirect_after_action(
511
-            $success,
512
-            $this->_question_model->item_name($success),
513
-            'deleted permanently',
514
-            array('action' => 'default', 'status' => 'trash')
515
-        );
516
-    }
517
-
518
-
519
-    /**
520
-     * Performs the deletion of a single or multiple questions or question groups.
521
-     *
522
-     * @param EEM_Soft_Delete_Base $model
523
-     * @return int number of items deleted permanently
524
-     * @throws EE_Error
525
-     * @throws InvalidArgumentException
526
-     * @throws InvalidDataTypeException
527
-     * @throws InvalidInterfaceException
528
-     */
529
-    private function _delete_items(EEM_Soft_Delete_Base $model)
530
-    {
531
-        $success = 0;
532
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
533
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
534
-            // if array has more than one element than success message should be plural
535
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
536
-            // cycle thru bulk action checkboxes
537
-            while (list($ID, $value) = each($this->_req_data['checkbox'])) {
538
-                if (! $this->_delete_item($ID, $model)) {
539
-                    $success = 0;
540
-                }
541
-            }
542
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
543
-            $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
544
-        } elseif (! empty($this->_req_data['QST_ID'])) {
545
-            $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
546
-        } else {
547
-            EE_Error::add_error(
548
-                sprintf(
549
-                    esc_html__(
550
-                        "No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
551
-                        "event_espresso"
552
-                    )
553
-                ),
554
-                __FILE__,
555
-                __FUNCTION__,
556
-                __LINE__
557
-            );
558
-        }
559
-        return $success;
560
-    }
561
-
562
-
563
-    /**
564
-     * Deletes the specified question (and its associated question options) or question group
565
-     *
566
-     * @param int                  $id
567
-     * @param EEM_Soft_Delete_Base $model
568
-     * @return boolean
569
-     * @throws EE_Error
570
-     * @throws InvalidArgumentException
571
-     * @throws InvalidDataTypeException
572
-     * @throws InvalidInterfaceException
573
-     */
574
-    protected function _delete_item($id, $model)
575
-    {
576
-        if ($model instanceof EEM_Question) {
577
-            EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
578
-        }
579
-        return $model->delete_permanently_by_ID(absint($id));
580
-    }
581
-
582
-
583
-    /******************************    QUESTION GROUPS    ******************************/
584
-
585
-
586
-    /**
587
-     * @param string $type
588
-     * @return void
589
-     * @throws DomainException
590
-     * @throws EE_Error
591
-     * @throws InvalidArgumentException
592
-     * @throws InvalidDataTypeException
593
-     * @throws InvalidInterfaceException
594
-     */
595
-    protected function _edit_question_group($type = 'add')
596
-    {
597
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
598
-        $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID'])
599
-            ? absint($this->_req_data['QSG_ID'])
600
-            : false;
601
-
602
-        switch ($this->_req_action) {
603
-            case 'add_question_group':
604
-                $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
605
-                break;
606
-            case 'edit_question_group':
607
-                $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
608
-                break;
609
-            default:
610
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
611
-        }
612
-        // add ID to title if editing
613
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
614
-        if ($ID) {
615
-            /** @var EE_Question_Group $questionGroup */
616
-            $questionGroup = $this->_question_group_model->get_one_by_ID($ID);
617
-            $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
618
-            $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
619
-        } else {
620
-            /** @var EE_Question_Group $questionGroup */
621
-            $questionGroup = EEM_Question_Group::instance()->create_default_object();
622
-            $questionGroup->set_order_to_latest();
623
-            $this->_set_add_edit_form_tags('insert_question_group');
624
-        }
625
-        $this->_template_args['values'] = $this->_yes_no_values;
626
-        $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
627
-        $this->_template_args['QSG_ID'] = $ID ? $ID : true;
628
-        $this->_template_args['question_group'] = $questionGroup;
629
-
630
-        $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
631
-        $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
632
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
633
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
634
-            $this->_template_args,
635
-            true
636
-        );
637
-
638
-        // the details template wrapper
639
-        $this->display_admin_page_with_sidebar();
640
-    }
641
-
642
-
643
-    /**
644
-     * @return void
645
-     * @throws EE_Error
646
-     * @throws InvalidArgumentException
647
-     * @throws InvalidDataTypeException
648
-     * @throws InvalidInterfaceException
649
-     */
650
-    protected function _delete_question_groups()
651
-    {
652
-        $success = $this->_delete_items($this->_question_group_model);
653
-        $this->_redirect_after_action(
654
-            $success,
655
-            $this->_question_group_model->item_name($success),
656
-            'deleted permanently',
657
-            array('action' => 'question_groups', 'status' => 'trash')
658
-        );
659
-    }
660
-
661
-
662
-    /**
663
-     * @param bool $new_question_group
664
-     * @throws EE_Error
665
-     * @throws InvalidArgumentException
666
-     * @throws InvalidDataTypeException
667
-     * @throws InvalidInterfaceException
668
-     */
669
-    protected function _insert_or_update_question_group($new_question_group = true)
670
-    {
671
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
672
-        $set_column_values = $this->_set_column_values_for($this->_question_group_model);
673
-
674
-        // make sure identifier is unique
675
-        $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : '';
676
-        $where_values = ['QSG_identifier' => $set_column_values['QSG_identifier']];
677
-        if (! $new_question_group && isset($set_column_values['QSG_ID'])) {
678
-            $where_values['QSG_ID'] = ['!=', $set_column_values['QSG_ID']];
679
-        }
680
-        $identifier_exists = ! empty($identifier_value)
681
-            ? $this->_question_group_model->count([$where_values]) > 0
682
-            : false;
683
-        if ($identifier_exists) {
684
-            $set_column_values['QSG_identifier'] .= uniqid('id', true);
685
-        }
686
-
687
-        if ($new_question_group) {
688
-            $QSG_ID = $this->_question_group_model->insert($set_column_values);
689
-            $success = $QSG_ID ? 1 : 0;
690
-            if ($success === 0) {
691
-                EE_Error::add_error(
692
-                    esc_html__('Something went wrong saving the question group.', 'event_espresso'),
693
-                    __FILE__,
694
-                    __FUNCTION__,
695
-                    __LINE__
696
-                );
697
-                $this->_redirect_after_action(
698
-                    false,
699
-                    '',
700
-                    '',
701
-                    array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
702
-                    true
703
-                );
704
-            }
705
-        } else {
706
-            $QSG_ID = absint($this->_req_data['QSG_ID']);
707
-            unset($set_column_values['QSG_ID']);
708
-            $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
709
-        }
710
-
711
-        $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(
712
-            EEM_Attendee::system_question_phone
713
-        );
714
-        // update the existing related questions
715
-        // BUT FIRST...  delete the phone question from the Question_Group_Question
716
-        // if it is being added to this question group (therefore removed from the existing group)
717
-        if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
718
-            // delete where QST ID = system phone question ID and Question Group ID is NOT this group
719
-            EEM_Question_Group_Question::instance()->delete(
720
-                array(
721
-                    array(
722
-                        'QST_ID' => $phone_question_id,
723
-                        'QSG_ID' => array('!=', $QSG_ID),
724
-                    ),
725
-                )
726
-            );
727
-        }
728
-        /** @type EE_Question_Group $question_group */
729
-        $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
730
-        $questions = $question_group->questions();
731
-        // make sure system phone question is added to list of questions for this group
732
-        if (! isset($questions[ $phone_question_id ])) {
733
-            $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
734
-        }
735
-
736
-        foreach ($questions as $question_ID => $question) {
737
-            // first we always check for order.
738
-            if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
739
-                // update question order
740
-                $question_group->update_question_order(
741
-                    $question_ID,
742
-                    $this->_req_data['question_orders'][ $question_ID ]
743
-                );
744
-            }
745
-
746
-            // then we always check if adding or removing.
747
-            if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
748
-                $question_group->add_question($question_ID);
749
-            } else {
750
-                // not found, remove it (but only if not a system question for the personal group
751
-                // with the exception of lname system question - we allow removal of it)
752
-                if (
753
-                    in_array(
754
-                        $question->system_ID(),
755
-                        EEM_Question::instance()->required_system_questions_in_system_question_group(
756
-                            $question_group->system_group()
757
-                        )
758
-                    )
759
-                ) {
760
-                    continue;
761
-                } else {
762
-                    $question_group->remove_question($question_ID);
763
-                }
764
-            }
765
-        }
766
-        // save new related questions
767
-        if (isset($this->_req_data['questions'])) {
768
-            foreach ($this->_req_data['questions'] as $QST_ID) {
769
-                $question_group->add_question($QST_ID);
770
-                if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
771
-                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
772
-                }
773
-            }
774
-        }
775
-
776
-        if ($success !== false) {
777
-            $msg = $new_question_group
778
-                ? sprintf(
779
-                    esc_html__('The %s has been created', 'event_espresso'),
780
-                    $this->_question_group_model->item_name()
781
-                )
782
-                : sprintf(
783
-                    esc_html__(
784
-                        'The %s has been updated',
785
-                        'event_espresso'
786
-                    ),
787
-                    $this->_question_group_model->item_name()
788
-                );
789
-            EE_Error::add_success($msg);
790
-        }
791
-        $this->_redirect_after_action(
792
-            false,
793
-            '',
794
-            '',
795
-            array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
796
-            true
797
-        );
798
-    }
799
-
800
-
801
-    /**
802
-     * duplicates a question and all its question options and redirects to the new question.
803
-     *
804
-     * @return void
805
-     * @throws EE_Error
806
-     * @throws InvalidArgumentException
807
-     * @throws ReflectionException
808
-     * @throws InvalidDataTypeException
809
-     * @throws InvalidInterfaceException
810
-     */
811
-    public function _duplicate_question()
812
-    {
813
-        $question_ID = (int) $this->_req_data['QST_ID'];
814
-        $question = EEM_Question::instance()->get_one_by_ID($question_ID);
815
-        if ($question instanceof EE_Question) {
816
-            $new_question = $question->duplicate();
817
-            if ($new_question instanceof EE_Question) {
818
-                $this->_redirect_after_action(
819
-                    true,
820
-                    esc_html__('Question', 'event_espresso'),
821
-                    esc_html__('Duplicated', 'event_espresso'),
822
-                    array('action' => 'edit_question', 'QST_ID' => $new_question->ID()),
823
-                    true
824
-                );
825
-            } else {
826
-                global $wpdb;
827
-                EE_Error::add_error(
828
-                    sprintf(
829
-                        esc_html__(
830
-                            'Could not duplicate question with ID %1$d because: %2$s',
831
-                            'event_espresso'
832
-                        ),
833
-                        $question_ID,
834
-                        $wpdb->last_error
835
-                    ),
836
-                    __FILE__,
837
-                    __FUNCTION__,
838
-                    __LINE__
839
-                );
840
-                $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
841
-            }
842
-        } else {
843
-            EE_Error::add_error(
844
-                sprintf(
845
-                    esc_html__(
846
-                        'Could not duplicate question with ID %d because it didn\'t exist!',
847
-                        'event_espresso'
848
-                    ),
849
-                    $question_ID
850
-                ),
851
-                __FILE__,
852
-                __FUNCTION__,
853
-                __LINE__
854
-            );
855
-            $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
856
-        }
857
-    }
858
-
859
-
860
-    /**
861
-     * @param bool $trash
862
-     * @throws EE_Error
863
-     */
864
-    protected function _trash_or_restore_question_groups($trash = true)
865
-    {
866
-        $this->_trash_or_restore_items($this->_question_group_model, $trash);
867
-    }
868
-
869
-
870
-    /**
871
-     *_trash_question
872
-     *
873
-     * @return void
874
-     * @throws EE_Error
875
-     */
876
-    protected function _trash_question()
877
-    {
878
-        $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
879
-        $query_args = array('action' => 'default', 'status' => 'all');
880
-        $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
881
-    }
882
-
883
-
884
-    /**
885
-     * @param bool $trash
886
-     * @throws EE_Error
887
-     */
888
-    protected function _trash_or_restore_questions($trash = true)
889
-    {
890
-        $this->_trash_or_restore_items($this->_question_model, $trash);
891
-    }
892
-
893
-
894
-    /**
895
-     * Internally used to delete or restore items, using the request data. Meant to be
896
-     * flexible between question or question groups
897
-     *
898
-     * @param EEM_Soft_Delete_Base $model
899
-     * @param boolean              $trash whether to trash or restore
900
-     * @throws EE_Error
901
-     */
902
-    private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
903
-    {
904
-
905
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
906
-
907
-        $success = 1;
908
-        // Checkboxes
909
-        // echo "trash $trash";
910
-        // var_dump($this->_req_data['checkbox']);die;
911
-        if (isset($this->_req_data['checkbox'])) {
912
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
913
-                // if array has more than one element than success message should be plural
914
-                $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
915
-                // cycle thru bulk action checkboxes
916
-                while (list($ID, $value) = each($this->_req_data['checkbox'])) {
917
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
918
-                        $success = 0;
919
-                    }
920
-                }
921
-            } else {
922
-                // grab single id and delete
923
-                $ID = absint($this->_req_data['checkbox']);
924
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
925
-                    $success = 0;
926
-                }
927
-            }
928
-        } else {
929
-            // delete via trash link
930
-            // grab single id and delete
931
-            $ID = absint($this->_req_data[ $model->primary_key_name() ]);
932
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
933
-                $success = 0;
934
-            }
935
-        }
936
-
937
-
938
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
939
-        // echo "action :$action";
940
-        // $action = 'questions' ? 'default' : $action;
941
-        if ($trash) {
942
-            $action_desc = 'trashed';
943
-            $status = 'trash';
944
-        } else {
945
-            $action_desc = 'restored';
946
-            $status = 'all';
947
-        }
948
-        $this->_redirect_after_action(
949
-            $success,
950
-            $model->item_name($success),
951
-            $action_desc,
952
-            array('action' => $action, 'status' => $status)
953
-        );
954
-    }
955
-
956
-
957
-    /**
958
-     * @param            $per_page
959
-     * @param int        $current_page
960
-     * @param bool|false $count
961
-     * @return EE_Soft_Delete_Base_Class[]|int
962
-     * @throws EE_Error
963
-     * @throws InvalidArgumentException
964
-     * @throws InvalidDataTypeException
965
-     * @throws InvalidInterfaceException
966
-     */
967
-    public function get_trashed_questions($per_page, $current_page = 1, $count = false)
968
-    {
969
-        $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
970
-
971
-        if ($count) {
972
-            // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
973
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
974
-            $results = $this->_question_model->count_deleted($where);
975
-        } else {
976
-            // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
977
-            $results = $this->_question_model->get_all_deleted($query_params);
978
-        }
979
-        return $results;
980
-    }
981
-
982
-
983
-    /**
984
-     * @param            $per_page
985
-     * @param int        $current_page
986
-     * @param bool|false $count
987
-     * @return EE_Soft_Delete_Base_Class[]|int
988
-     * @throws EE_Error
989
-     * @throws InvalidArgumentException
990
-     * @throws InvalidDataTypeException
991
-     * @throws InvalidInterfaceException
992
-     */
993
-    public function get_question_groups($per_page, $current_page = 1, $count = false)
994
-    {
995
-        $questionGroupModel = EEM_Question_Group::instance();
996
-        $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
997
-        if ($count) {
998
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
999
-            $results = $questionGroupModel->count($where);
1000
-        } else {
1001
-            $results = $questionGroupModel->get_all($query_params);
1002
-        }
1003
-        return $results;
1004
-    }
1005
-
1006
-
1007
-    /**
1008
-     * @param      $per_page
1009
-     * @param int  $current_page
1010
-     * @param bool $count
1011
-     * @return EE_Soft_Delete_Base_Class[]|int
1012
-     * @throws EE_Error
1013
-     * @throws InvalidArgumentException
1014
-     * @throws InvalidDataTypeException
1015
-     * @throws InvalidInterfaceException
1016
-     */
1017
-    public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
1018
-    {
1019
-        $questionGroupModel = EEM_Question_Group::instance();
1020
-        $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
1021
-        if ($count) {
1022
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
1023
-            $query_params['limit'] = null;
1024
-            $results = $questionGroupModel->count_deleted($where);
1025
-        } else {
1026
-            $results = $questionGroupModel->get_all_deleted($query_params);
1027
-        }
1028
-        return $results;
1029
-    }
1030
-
1031
-
1032
-    /**
1033
-     * method for performing updates to question order
1034
-     *
1035
-     * @return void results array
1036
-     * @throws EE_Error
1037
-     * @throws InvalidArgumentException
1038
-     * @throws InvalidDataTypeException
1039
-     * @throws InvalidInterfaceException
1040
-     */
1041
-    public function update_question_group_order()
1042
-    {
1043
-
1044
-        $success = esc_html__('Question group order was updated successfully.', 'event_espresso');
1045
-
1046
-        // grab our row IDs
1047
-        $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
1048
-            ? explode(',', rtrim($this->_req_data['row_ids'], ','))
1049
-            : array();
1050
-
1051
-        $perpage = ! empty($this->_req_data['perpage'])
1052
-            ? (int) $this->_req_data['perpage']
1053
-            : null;
1054
-        $curpage = ! empty($this->_req_data['curpage'])
1055
-            ? (int) $this->_req_data['curpage']
1056
-            : null;
1057
-
1058
-        if (! empty($row_ids)) {
1059
-            // figure out where we start the row_id count at for the current page.
1060
-            $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1061
-
1062
-            $row_count = count($row_ids);
1063
-            for ($i = 0; $i < $row_count; $i++) {
1064
-                // Update the questions when re-ordering
1065
-                $updated = EEM_Question_Group::instance()->update(
1066
-                    array('QSG_order' => $qsgcount),
1067
-                    array(array('QSG_ID' => $row_ids[ $i ]))
1068
-                );
1069
-                if ($updated === false) {
1070
-                    $success = false;
1071
-                }
1072
-                $qsgcount++;
1073
-            }
1074
-        } else {
1075
-            $success = false;
1076
-        }
1077
-
1078
-        $errors = ! $success
1079
-            ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
1080
-            : false;
1081
-
1082
-        echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
1083
-        die();
1084
-    }
1085
-
1086
-
1087
-
1088
-    /***************************************       REGISTRATION SETTINGS       ***************************************/
1089
-
1090
-
1091
-    /**
1092
-     * @throws DomainException
1093
-     * @throws EE_Error
1094
-     * @throws InvalidArgumentException
1095
-     * @throws InvalidDataTypeException
1096
-     * @throws InvalidInterfaceException
1097
-     */
1098
-    protected function _reg_form_settings()
1099
-    {
1100
-        $this->_template_args['values'] = $this->_yes_no_values;
1101
-        add_action(
1102
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1103
-            array($this, 'email_validation_settings_form'),
1104
-            2
1105
-        );
1106
-        add_action(
1107
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1108
-            array($this, 'copy_attendee_info_settings_form'),
1109
-            4
1110
-        );
1111
-        $this->_template_args = (array) apply_filters(
1112
-            'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
1113
-            $this->_template_args
1114
-        );
1115
-        $this->_set_add_edit_form_tags('update_reg_form_settings');
1116
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1117
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1118
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1119
-            $this->_template_args,
1120
-            true
1121
-        );
1122
-        $this->display_admin_page_with_sidebar();
1123
-    }
1124
-
1125
-
1126
-    /**
1127
-     * @return void
1128
-     * @throws EE_Error
1129
-     * @throws InvalidArgumentException
1130
-     * @throws ReflectionException
1131
-     * @throws InvalidDataTypeException
1132
-     * @throws InvalidInterfaceException
1133
-     */
1134
-    protected function _update_reg_form_settings()
1135
-    {
1136
-        EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
1137
-            EE_Registry::instance()->CFG->registration
1138
-        );
1139
-        EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form(
1140
-            EE_Registry::instance()->CFG->registration
1141
-        );
1142
-        EE_Registry::instance()->CFG->registration = apply_filters(
1143
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
1144
-            EE_Registry::instance()->CFG->registration
1145
-        );
1146
-        $success = $this->_update_espresso_configuration(
1147
-            esc_html__('Registration Form Options', 'event_espresso'),
1148
-            EE_Registry::instance()->CFG,
1149
-            __FILE__,
1150
-            __FUNCTION__,
1151
-            __LINE__
1152
-        );
1153
-        $this->_redirect_after_action(
1154
-            $success,
1155
-            esc_html__('Registration Form Options', 'event_espresso'),
1156
-            'updated',
1157
-            array('action' => 'view_reg_form_settings')
1158
-        );
1159
-    }
1160
-
1161
-
1162
-    /**
1163
-     * @return void
1164
-     * @throws EE_Error
1165
-     * @throws InvalidArgumentException
1166
-     * @throws InvalidDataTypeException
1167
-     * @throws InvalidInterfaceException
1168
-     */
1169
-    public function copy_attendee_info_settings_form()
1170
-    {
1171
-        echo wp_kses($this->_copy_attendee_info_settings_form()->get_html(), AllowedTags::getWithFormTags());
1172
-    }
1173
-
1174
-    /**
1175
-     * _copy_attendee_info_settings_form
1176
-     *
1177
-     * @access protected
1178
-     * @return EE_Form_Section_Proper
1179
-     * @throws \EE_Error
1180
-     */
1181
-    protected function _copy_attendee_info_settings_form()
1182
-    {
1183
-        return new EE_Form_Section_Proper(
1184
-            array(
1185
-                'name'            => 'copy_attendee_info_settings',
1186
-                'html_id'         => 'copy_attendee_info_settings',
1187
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1188
-                'subsections'     => apply_filters(
1189
-                    'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections',
1190
-                    array(
1191
-                        'copy_attendee_info_hdr'   => new EE_Form_Section_HTML(
1192
-                            EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso'))
1193
-                        ),
1194
-                        'copy_attendee_info' => new EE_Yes_No_Input(
1195
-                            array(
1196
-                                'html_label_text' => esc_html__(
1197
-                                    'Allow copy #1 attendee info to extra attendees?',
1198
-                                    'event_espresso'
1199
-                                ),
1200
-                                'html_help_text'  => esc_html__(
1201
-                                    'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.',
1202
-                                    'event_espresso'
1203
-                                ),
1204
-                                'default'         => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(),
1205
-                                'required'        => false,
1206
-                                'display_html_label_text' => false,
1207
-                            )
1208
-                        ),
1209
-                    )
1210
-                ),
1211
-            )
1212
-        );
1213
-    }
1214
-
1215
-    /**
1216
-     * @param EE_Registration_Config $EE_Registration_Config
1217
-     * @return EE_Registration_Config
1218
-     * @throws EE_Error
1219
-     * @throws InvalidArgumentException
1220
-     * @throws ReflectionException
1221
-     * @throws InvalidDataTypeException
1222
-     * @throws InvalidInterfaceException
1223
-     */
1224
-    public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config)
1225
-    {
1226
-        $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo();
1227
-        try {
1228
-            $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form();
1229
-            // if not displaying a form, then check for form submission
1230
-            if ($copy_attendee_info_settings_form->was_submitted()) {
1231
-                // capture form data
1232
-                $copy_attendee_info_settings_form->receive_form_submission();
1233
-                // validate form data
1234
-                if ($copy_attendee_info_settings_form->is_valid()) {
1235
-                    // grab validated data from form
1236
-                    $valid_data = $copy_attendee_info_settings_form->valid_data();
1237
-                    if (isset($valid_data['copy_attendee_info'])) {
1238
-                        $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']);
1239
-                    } else {
1240
-                        EE_Error::add_error(
1241
-                            esc_html__(
1242
-                                'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.',
1243
-                                'event_espresso'
1244
-                            ),
1245
-                            __FILE__,
1246
-                            __FUNCTION__,
1247
-                            __LINE__
1248
-                        );
1249
-                    }
1250
-                } else {
1251
-                    if ($copy_attendee_info_settings_form->submission_error_message() !== '') {
1252
-                        EE_Error::add_error(
1253
-                            $copy_attendee_info_settings_form->submission_error_message(),
1254
-                            __FILE__,
1255
-                            __FUNCTION__,
1256
-                            __LINE__
1257
-                        );
1258
-                    }
1259
-                }
1260
-            }
1261
-        } catch (EE_Error $e) {
1262
-            $e->get_error();
1263
-        }
1264
-        return $EE_Registration_Config;
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     * @return void
1270
-     * @throws EE_Error
1271
-     * @throws InvalidArgumentException
1272
-     * @throws InvalidDataTypeException
1273
-     * @throws InvalidInterfaceException
1274
-     */
1275
-    public function email_validation_settings_form()
1276
-    {
1277
-        echo wp_kses($this->_email_validation_settings_form()->get_html(), AllowedTags::getWithFormTags());
1278
-    }
1279
-
1280
-
1281
-    /**
1282
-     * _email_validation_settings_form
1283
-     *
1284
-     * @access protected
1285
-     * @return EE_Form_Section_Proper
1286
-     * @throws \EE_Error
1287
-     */
1288
-    protected function _email_validation_settings_form()
1289
-    {
1290
-        return new EE_Form_Section_Proper(
1291
-            array(
1292
-                'name'            => 'email_validation_settings',
1293
-                'html_id'         => 'email_validation_settings',
1294
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1295
-                'subsections'     => apply_filters(
1296
-                    'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
1297
-                    array(
1298
-                        'email_validation_hdr'   => new EE_Form_Section_HTML(
1299
-                            EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
1300
-                        ),
1301
-                        'email_validation_level' => new EE_Select_Input(
1302
-                            array(
1303
-                                'basic'      => esc_html__('Basic', 'event_espresso'),
1304
-                                'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
1305
-                                'i18n'       => esc_html__('International', 'event_espresso'),
1306
-                                'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
1307
-                            ),
1308
-                            array(
1309
-                                'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
1310
-                                                     . EEH_Template::get_help_tab_link('email_validation_info'),
1311
-                                'html_help_text'  => esc_html__(
1312
-                                    'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.',
1313
-                                    'event_espresso'
1314
-                                ),
1315
-                                'default'         => isset(
1316
-                                    EE_Registry::instance()->CFG->registration->email_validation_level
1317
-                                )
1318
-                                    ? EE_Registry::instance()->CFG->registration->email_validation_level
1319
-                                    : 'wp_default',
1320
-                                'required'        => false,
1321
-                            )
1322
-                        ),
1323
-                    )
1324
-                ),
1325
-            )
1326
-        );
1327
-    }
1328
-
1329
-
1330
-    /**
1331
-     * @param EE_Registration_Config $EE_Registration_Config
1332
-     * @return EE_Registration_Config
1333
-     * @throws EE_Error
1334
-     * @throws InvalidArgumentException
1335
-     * @throws ReflectionException
1336
-     * @throws InvalidDataTypeException
1337
-     * @throws InvalidInterfaceException
1338
-     */
1339
-    public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1340
-    {
1341
-        $prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1342
-        try {
1343
-            $email_validation_settings_form = $this->_email_validation_settings_form();
1344
-            // if not displaying a form, then check for form submission
1345
-            if ($email_validation_settings_form->was_submitted()) {
1346
-                // capture form data
1347
-                $email_validation_settings_form->receive_form_submission();
1348
-                // validate form data
1349
-                if ($email_validation_settings_form->is_valid()) {
1350
-                    // grab validated data from form
1351
-                    $valid_data = $email_validation_settings_form->valid_data();
1352
-                    if (isset($valid_data['email_validation_level'])) {
1353
-                        $email_validation_level = $valid_data['email_validation_level'];
1354
-                        // now if they want to use international email addresses
1355
-                        if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1356
-                            // in case we need to reset their email validation level,
1357
-                            // make sure that the previous value wasn't already set to one of the i18n options.
1358
-                            if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1359
-                                // if so, then reset it back to "basic" since that is the only other option that,
1360
-                                // despite offering poor validation, supports i18n email addresses
1361
-                                $prev_email_validation_level = 'basic';
1362
-                            }
1363
-                            // confirm our i18n email validation will work on the server
1364
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1365
-                                // or reset email validation level to previous value
1366
-                                $email_validation_level = $prev_email_validation_level;
1367
-                            }
1368
-                        }
1369
-                        $EE_Registration_Config->email_validation_level = $email_validation_level;
1370
-                    } else {
1371
-                        EE_Error::add_error(
1372
-                            esc_html__(
1373
-                                'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1374
-                                'event_espresso'
1375
-                            ),
1376
-                            __FILE__,
1377
-                            __FUNCTION__,
1378
-                            __LINE__
1379
-                        );
1380
-                    }
1381
-                } else {
1382
-                    if ($email_validation_settings_form->submission_error_message() !== '') {
1383
-                        EE_Error::add_error(
1384
-                            $email_validation_settings_form->submission_error_message(),
1385
-                            __FILE__,
1386
-                            __FUNCTION__,
1387
-                            __LINE__
1388
-                        );
1389
-                    }
1390
-                }
1391
-            }
1392
-        } catch (EE_Error $e) {
1393
-            $e->get_error();
1394
-        }
1395
-        return $EE_Registration_Config;
1396
-    }
1397
-
1398
-
1399
-    /**
1400
-     * confirms that the server's PHP version has the PCRE module enabled,
1401
-     * and that the PCRE version works with our i18n email validation
1402
-     *
1403
-     * @param EE_Registration_Config $EE_Registration_Config
1404
-     * @param string                 $email_validation_level
1405
-     * @return bool
1406
-     */
1407
-    private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1408
-    {
1409
-        // first check that PCRE is enabled
1410
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1411
-            EE_Error::add_error(
1412
-                sprintf(
1413
-                    esc_html__(
1414
-                        'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.',
1415
-                        'event_espresso'
1416
-                    ),
1417
-                    '<br />'
1418
-                ),
1419
-                __FILE__,
1420
-                __FUNCTION__,
1421
-                __LINE__
1422
-            );
1423
-            return false;
1424
-        } else {
1425
-            // PCRE support is enabled, but let's still
1426
-            // perform a test to see if the server will support it.
1427
-            // but first, save the updated validation level to the config,
1428
-            // so that the validation strategy picks it up.
1429
-            // this will get bumped back down if it doesn't work
1430
-            $EE_Registration_Config->email_validation_level = $email_validation_level;
1431
-            try {
1432
-                $email_validator = new EE_Email_Validation_Strategy();
1433
-                $i18n_email_address = apply_filters(
1434
-                    'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1435
-                    'jägerjü[email protected]'
1436
-                );
1437
-                $email_validator->validate($i18n_email_address);
1438
-            } catch (Exception $e) {
1439
-                EE_Error::add_error(
1440
-                    sprintf(
1441
-                        esc_html__(
1442
-                            'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s',
1443
-                            'event_espresso'
1444
-                        ),
1445
-                        '<br />',
1446
-                        '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>'
1447
-                    ),
1448
-                    __FILE__,
1449
-                    __FUNCTION__,
1450
-                    __LINE__
1451
-                );
1452
-                return false;
1453
-            }
1454
-        }
1455
-        return true;
1456
-    }
17
+	/**
18
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
19
+	 */
20
+	public function __construct($routing = true)
21
+	{
22
+		define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/');
23
+		define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/');
24
+		define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
25
+		define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/');
26
+		define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
27
+		parent::__construct($routing);
28
+	}
29
+
30
+
31
+	/**
32
+	 * @return void
33
+	 */
34
+	protected function _extend_page_config()
35
+	{
36
+		$this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
37
+		$qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID'])
38
+			? $this->_req_data['QST_ID'] : 0;
39
+		$qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID'])
40
+			? $this->_req_data['QSG_ID'] : 0;
41
+
42
+		$new_page_routes = array(
43
+			'question_groups'    => array(
44
+				'func'       => '_question_groups_overview_list_table',
45
+				'capability' => 'ee_read_question_groups',
46
+			),
47
+			'add_question'       => array(
48
+				'func'       => '_edit_question',
49
+				'capability' => 'ee_edit_questions',
50
+			),
51
+			'insert_question'    => array(
52
+				'func'       => '_insert_or_update_question',
53
+				'args'       => array('new_question' => true),
54
+				'capability' => 'ee_edit_questions',
55
+				'noheader'   => true,
56
+			),
57
+			'duplicate_question' => array(
58
+				'func'       => '_duplicate_question',
59
+				'capability' => 'ee_edit_questions',
60
+				'noheader'   => true,
61
+			),
62
+			'trash_question'     => array(
63
+				'func'       => '_trash_question',
64
+				'capability' => 'ee_delete_question',
65
+				'obj_id'     => $qst_id,
66
+				'noheader'   => true,
67
+			),
68
+
69
+			'restore_question' => array(
70
+				'func'       => '_trash_or_restore_questions',
71
+				'capability' => 'ee_delete_question',
72
+				'obj_id'     => $qst_id,
73
+				'args'       => array('trash' => false),
74
+				'noheader'   => true,
75
+			),
76
+
77
+			'delete_question' => array(
78
+				'func'       => '_delete_question',
79
+				'capability' => 'ee_delete_question',
80
+				'obj_id'     => $qst_id,
81
+				'noheader'   => true,
82
+			),
83
+
84
+			'trash_questions' => array(
85
+				'func'       => '_trash_or_restore_questions',
86
+				'capability' => 'ee_delete_questions',
87
+				'args'       => array('trash' => true),
88
+				'noheader'   => true,
89
+			),
90
+
91
+			'restore_questions' => array(
92
+				'func'       => '_trash_or_restore_questions',
93
+				'capability' => 'ee_delete_questions',
94
+				'args'       => array('trash' => false),
95
+				'noheader'   => true,
96
+			),
97
+
98
+			'delete_questions' => array(
99
+				'func'       => '_delete_questions',
100
+				'args'       => array(),
101
+				'capability' => 'ee_delete_questions',
102
+				'noheader'   => true,
103
+			),
104
+
105
+			'add_question_group' => array(
106
+				'func'       => '_edit_question_group',
107
+				'capability' => 'ee_edit_question_groups',
108
+			),
109
+
110
+			'edit_question_group' => array(
111
+				'func'       => '_edit_question_group',
112
+				'capability' => 'ee_edit_question_group',
113
+				'obj_id'     => $qsg_id,
114
+				'args'       => array('edit'),
115
+			),
116
+
117
+			'delete_question_groups' => array(
118
+				'func'       => '_delete_question_groups',
119
+				'capability' => 'ee_delete_question_groups',
120
+				'noheader'   => true,
121
+			),
122
+
123
+			'delete_question_group' => array(
124
+				'func'       => '_delete_question_groups',
125
+				'capability' => 'ee_delete_question_group',
126
+				'obj_id'     => $qsg_id,
127
+				'noheader'   => true,
128
+			),
129
+
130
+			'trash_question_group' => array(
131
+				'func'       => '_trash_or_restore_question_groups',
132
+				'args'       => array('trash' => true),
133
+				'capability' => 'ee_delete_question_group',
134
+				'obj_id'     => $qsg_id,
135
+				'noheader'   => true,
136
+			),
137
+
138
+			'restore_question_group' => array(
139
+				'func'       => '_trash_or_restore_question_groups',
140
+				'args'       => array('trash' => false),
141
+				'capability' => 'ee_delete_question_group',
142
+				'obj_id'     => $qsg_id,
143
+				'noheader'   => true,
144
+			),
145
+
146
+			'insert_question_group' => array(
147
+				'func'       => '_insert_or_update_question_group',
148
+				'args'       => array('new_question_group' => true),
149
+				'capability' => 'ee_edit_question_groups',
150
+				'noheader'   => true,
151
+			),
152
+
153
+			'update_question_group' => array(
154
+				'func'       => '_insert_or_update_question_group',
155
+				'args'       => array('new_question_group' => false),
156
+				'capability' => 'ee_edit_question_group',
157
+				'obj_id'     => $qsg_id,
158
+				'noheader'   => true,
159
+			),
160
+
161
+			'trash_question_groups' => array(
162
+				'func'       => '_trash_or_restore_question_groups',
163
+				'args'       => array('trash' => true),
164
+				'capability' => 'ee_delete_question_groups',
165
+				'noheader'   => array('trash' => false),
166
+			),
167
+
168
+			'restore_question_groups' => array(
169
+				'func'       => '_trash_or_restore_question_groups',
170
+				'args'       => array('trash' => false),
171
+				'capability' => 'ee_delete_question_groups',
172
+				'noheader'   => true,
173
+			),
174
+
175
+
176
+			'espresso_update_question_group_order' => array(
177
+				'func'       => 'update_question_group_order',
178
+				'capability' => 'ee_edit_question_groups',
179
+				'noheader'   => true,
180
+			),
181
+
182
+			'view_reg_form_settings' => array(
183
+				'func'       => '_reg_form_settings',
184
+				'capability' => 'manage_options',
185
+			),
186
+
187
+			'update_reg_form_settings' => array(
188
+				'func'       => '_update_reg_form_settings',
189
+				'capability' => 'manage_options',
190
+				'noheader'   => true,
191
+			),
192
+		);
193
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
194
+
195
+		$new_page_config = array(
196
+
197
+			'question_groups' => array(//dashicons-editor-help
198
+				'nav'           => array(
199
+					'label' => esc_html__('Question Groups', 'event_espresso'),
200
+					'icon' => 'dashicons-forms',
201
+					'order' => 20,
202
+				),
203
+				'list_table'    => 'Registration_Form_Question_Groups_Admin_List_Table',
204
+				'help_tabs'     => array(
205
+					'registration_form_question_groups_help_tab'                           => array(
206
+						'title'    => esc_html__('Question Groups', 'event_espresso'),
207
+						'filename' => 'registration_form_question_groups',
208
+					),
209
+					'registration_form_question_groups_table_column_headings_help_tab'     => array(
210
+						'title'    => esc_html__('Question Groups Table Column Headings', 'event_espresso'),
211
+						'filename' => 'registration_form_question_groups_table_column_headings',
212
+					),
213
+					'registration_form_question_groups_views_bulk_actions_search_help_tab' => array(
214
+						'title'    => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'),
215
+						'filename' => 'registration_form_question_groups_views_bulk_actions_search',
216
+					),
217
+				),
218
+				'metaboxes'     => $this->_default_espresso_metaboxes,
219
+				'require_nonce' => false,
220
+			),
221
+
222
+			'add_question' => array(
223
+				'nav'           => array(
224
+					'label'      => esc_html__('Add Question', 'event_espresso'),
225
+					'icon' => 'dashicons-plus-alt',
226
+					'order'      => 15,
227
+					'persistent' => false,
228
+				),
229
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
230
+				'help_tabs'     => array(
231
+					'registration_form_add_question_help_tab' => array(
232
+						'title'    => esc_html__('Add Question', 'event_espresso'),
233
+						'filename' => 'registration_form_add_question',
234
+					),
235
+				),
236
+				'require_nonce' => false,
237
+			),
238
+
239
+			'add_question_group' => array(
240
+				'nav'           => array(
241
+					'label'      => esc_html__('Add Question Group', 'event_espresso'),
242
+					'icon' => 'dashicons-plus-alt',
243
+					'order'      => 25,
244
+					'persistent' => false,
245
+				),
246
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
247
+				'help_tabs'     => array(
248
+					'registration_form_add_question_group_help_tab' => array(
249
+						'title'    => esc_html__('Add Question Group', 'event_espresso'),
250
+						'filename' => 'registration_form_add_question_group',
251
+					),
252
+				),
253
+				'require_nonce' => false,
254
+			),
255
+
256
+			'edit_question_group' => array(
257
+				'nav'           => array(
258
+					'label'      => esc_html__('Edit Question Group', 'event_espresso'),
259
+					'icon' => 'dashicons-edit-large',
260
+					'order'      => 25,
261
+					'persistent' => false,
262
+					'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(
263
+						array('question_group_id' => $this->_req_data['question_group_id']),
264
+						$this->_current_page_view_url
265
+					) : $this->_admin_base_url,
266
+				),
267
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
268
+				'help_tabs'     => array(
269
+					'registration_form_edit_question_group_help_tab' => array(
270
+						'title'    => esc_html__('Edit Question Group', 'event_espresso'),
271
+						'filename' => 'registration_form_edit_question_group',
272
+					),
273
+				),
274
+				'require_nonce' => false,
275
+			),
276
+
277
+			'view_reg_form_settings' => array(
278
+				'nav'           => array(
279
+					'label' => esc_html__('Reg Form Settings', 'event_espresso'),
280
+					'icon' => 'dashicons-admin-generic',
281
+					'order' => 40,
282
+				),
283
+				'labels'        => array(
284
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
285
+				),
286
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
287
+				'help_tabs'     => array(
288
+					'registration_form_reg_form_settings_help_tab' => array(
289
+						'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
290
+						'filename' => 'registration_form_reg_form_settings',
291
+					),
292
+				),
293
+				'require_nonce' => false,
294
+			),
295
+
296
+		);
297
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
298
+
299
+		// change the list table we're going to use so it's the NEW list table!
300
+		$this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
301
+
302
+
303
+		// additional labels
304
+		$new_labels = array(
305
+			'add_question'          => esc_html__('Add New Question', 'event_espresso'),
306
+			'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
307
+			'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
308
+			'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
309
+			'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
310
+		);
311
+		$this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
312
+	}
313
+
314
+
315
+	/**
316
+	 * @return void
317
+	 */
318
+	protected function _ajax_hooks()
319
+	{
320
+		add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
321
+	}
322
+
323
+
324
+	/**
325
+	 * @return void
326
+	 */
327
+	public function load_scripts_styles_question_groups()
328
+	{
329
+		wp_enqueue_script('espresso_ajax_table_sorting');
330
+	}
331
+
332
+
333
+	/**
334
+	 * @return void
335
+	 */
336
+	public function load_scripts_styles_add_question_group()
337
+	{
338
+		$this->load_scripts_styles_forms();
339
+		$this->load_sortable_question_script();
340
+	}
341
+
342
+
343
+	/**
344
+	 * @return void
345
+	 */
346
+	public function load_scripts_styles_edit_question_group()
347
+	{
348
+		$this->load_scripts_styles_forms();
349
+		$this->load_sortable_question_script();
350
+	}
351
+
352
+
353
+	/**
354
+	 * registers and enqueues script for questions
355
+	 *
356
+	 * @return void
357
+	 */
358
+	public function load_sortable_question_script()
359
+	{
360
+		wp_register_script(
361
+			'ee-question-sortable',
362
+			REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
363
+			array('jquery-ui-sortable'),
364
+			EVENT_ESPRESSO_VERSION,
365
+			true
366
+		);
367
+		wp_enqueue_script('ee-question-sortable');
368
+	}
369
+
370
+
371
+	/**
372
+	 * @return void
373
+	 */
374
+	protected function _set_list_table_views_default()
375
+	{
376
+		$this->_views = array(
377
+			'all' => array(
378
+				'slug'        => 'all',
379
+				'label'       => esc_html__('View All Questions', 'event_espresso'),
380
+				'count'       => 0,
381
+				'bulk_action' => array(
382
+					'trash_questions' => esc_html__('Trash', 'event_espresso'),
383
+				),
384
+			),
385
+		);
386
+
387
+		if (
388
+			EE_Registry::instance()->CAP->current_user_can(
389
+				'ee_delete_questions',
390
+				'espresso_registration_form_trash_questions'
391
+			)
392
+		) {
393
+			$this->_views['trash'] = array(
394
+				'slug'        => 'trash',
395
+				'label'       => esc_html__('Trash', 'event_espresso'),
396
+				'count'       => 0,
397
+				'bulk_action' => array(
398
+					'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
399
+					'restore_questions' => esc_html__('Restore', 'event_espresso'),
400
+				),
401
+			);
402
+		}
403
+	}
404
+
405
+
406
+	/**
407
+	 * @return void
408
+	 */
409
+	protected function _set_list_table_views_question_groups()
410
+	{
411
+		$this->_views = array(
412
+			'all' => array(
413
+				'slug'        => 'all',
414
+				'label'       => esc_html__('All', 'event_espresso'),
415
+				'count'       => 0,
416
+				'bulk_action' => array(
417
+					'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
418
+				),
419
+			),
420
+		);
421
+
422
+		if (
423
+			EE_Registry::instance()->CAP->current_user_can(
424
+				'ee_delete_question_groups',
425
+				'espresso_registration_form_trash_question_groups'
426
+			)
427
+		) {
428
+			$this->_views['trash'] = array(
429
+				'slug'        => 'trash',
430
+				'label'       => esc_html__('Trash', 'event_espresso'),
431
+				'count'       => 0,
432
+				'bulk_action' => array(
433
+					'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
434
+					'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
435
+				),
436
+			);
437
+		}
438
+	}
439
+
440
+
441
+	/**
442
+	 * @return void
443
+	 * @throws EE_Error
444
+	 * @throws InvalidArgumentException
445
+	 * @throws InvalidDataTypeException
446
+	 * @throws InvalidInterfaceException
447
+	 */
448
+	protected function _questions_overview_list_table()
449
+	{
450
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
451
+			'add_question',
452
+			'add_question',
453
+			array(),
454
+			'add-new-h2'
455
+		);
456
+		parent::_questions_overview_list_table();
457
+	}
458
+
459
+
460
+	/**
461
+	 * @return void
462
+	 * @throws DomainException
463
+	 * @throws EE_Error
464
+	 * @throws InvalidArgumentException
465
+	 * @throws InvalidDataTypeException
466
+	 * @throws InvalidInterfaceException
467
+	 */
468
+	protected function _question_groups_overview_list_table()
469
+	{
470
+		$this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
471
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
472
+			'add_question_group',
473
+			'add_question_group',
474
+			array(),
475
+			'add-new-h2'
476
+		);
477
+		$this->display_admin_list_table_page_with_sidebar();
478
+	}
479
+
480
+
481
+	/**
482
+	 * @return void
483
+	 * @throws EE_Error
484
+	 * @throws InvalidArgumentException
485
+	 * @throws InvalidDataTypeException
486
+	 * @throws InvalidInterfaceException
487
+	 */
488
+	protected function _delete_question()
489
+	{
490
+		$success = $this->_delete_items($this->_question_model);
491
+		$this->_redirect_after_action(
492
+			$success,
493
+			$this->_question_model->item_name($success),
494
+			'deleted',
495
+			array('action' => 'default', 'status' => 'all')
496
+		);
497
+	}
498
+
499
+
500
+	/**
501
+	 * @return void
502
+	 * @throws EE_Error
503
+	 * @throws InvalidArgumentException
504
+	 * @throws InvalidDataTypeException
505
+	 * @throws InvalidInterfaceException
506
+	 */
507
+	protected function _delete_questions()
508
+	{
509
+		$success = $this->_delete_items($this->_question_model);
510
+		$this->_redirect_after_action(
511
+			$success,
512
+			$this->_question_model->item_name($success),
513
+			'deleted permanently',
514
+			array('action' => 'default', 'status' => 'trash')
515
+		);
516
+	}
517
+
518
+
519
+	/**
520
+	 * Performs the deletion of a single or multiple questions or question groups.
521
+	 *
522
+	 * @param EEM_Soft_Delete_Base $model
523
+	 * @return int number of items deleted permanently
524
+	 * @throws EE_Error
525
+	 * @throws InvalidArgumentException
526
+	 * @throws InvalidDataTypeException
527
+	 * @throws InvalidInterfaceException
528
+	 */
529
+	private function _delete_items(EEM_Soft_Delete_Base $model)
530
+	{
531
+		$success = 0;
532
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
533
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
534
+			// if array has more than one element than success message should be plural
535
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
536
+			// cycle thru bulk action checkboxes
537
+			while (list($ID, $value) = each($this->_req_data['checkbox'])) {
538
+				if (! $this->_delete_item($ID, $model)) {
539
+					$success = 0;
540
+				}
541
+			}
542
+		} elseif (! empty($this->_req_data['QSG_ID'])) {
543
+			$success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
544
+		} elseif (! empty($this->_req_data['QST_ID'])) {
545
+			$success = $this->_delete_item($this->_req_data['QST_ID'], $model);
546
+		} else {
547
+			EE_Error::add_error(
548
+				sprintf(
549
+					esc_html__(
550
+						"No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
551
+						"event_espresso"
552
+					)
553
+				),
554
+				__FILE__,
555
+				__FUNCTION__,
556
+				__LINE__
557
+			);
558
+		}
559
+		return $success;
560
+	}
561
+
562
+
563
+	/**
564
+	 * Deletes the specified question (and its associated question options) or question group
565
+	 *
566
+	 * @param int                  $id
567
+	 * @param EEM_Soft_Delete_Base $model
568
+	 * @return boolean
569
+	 * @throws EE_Error
570
+	 * @throws InvalidArgumentException
571
+	 * @throws InvalidDataTypeException
572
+	 * @throws InvalidInterfaceException
573
+	 */
574
+	protected function _delete_item($id, $model)
575
+	{
576
+		if ($model instanceof EEM_Question) {
577
+			EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
578
+		}
579
+		return $model->delete_permanently_by_ID(absint($id));
580
+	}
581
+
582
+
583
+	/******************************    QUESTION GROUPS    ******************************/
584
+
585
+
586
+	/**
587
+	 * @param string $type
588
+	 * @return void
589
+	 * @throws DomainException
590
+	 * @throws EE_Error
591
+	 * @throws InvalidArgumentException
592
+	 * @throws InvalidDataTypeException
593
+	 * @throws InvalidInterfaceException
594
+	 */
595
+	protected function _edit_question_group($type = 'add')
596
+	{
597
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
598
+		$ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID'])
599
+			? absint($this->_req_data['QSG_ID'])
600
+			: false;
601
+
602
+		switch ($this->_req_action) {
603
+			case 'add_question_group':
604
+				$this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
605
+				break;
606
+			case 'edit_question_group':
607
+				$this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
608
+				break;
609
+			default:
610
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
611
+		}
612
+		// add ID to title if editing
613
+		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
614
+		if ($ID) {
615
+			/** @var EE_Question_Group $questionGroup */
616
+			$questionGroup = $this->_question_group_model->get_one_by_ID($ID);
617
+			$additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
618
+			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
619
+		} else {
620
+			/** @var EE_Question_Group $questionGroup */
621
+			$questionGroup = EEM_Question_Group::instance()->create_default_object();
622
+			$questionGroup->set_order_to_latest();
623
+			$this->_set_add_edit_form_tags('insert_question_group');
624
+		}
625
+		$this->_template_args['values'] = $this->_yes_no_values;
626
+		$this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
627
+		$this->_template_args['QSG_ID'] = $ID ? $ID : true;
628
+		$this->_template_args['question_group'] = $questionGroup;
629
+
630
+		$redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
631
+		$this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
632
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
633
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
634
+			$this->_template_args,
635
+			true
636
+		);
637
+
638
+		// the details template wrapper
639
+		$this->display_admin_page_with_sidebar();
640
+	}
641
+
642
+
643
+	/**
644
+	 * @return void
645
+	 * @throws EE_Error
646
+	 * @throws InvalidArgumentException
647
+	 * @throws InvalidDataTypeException
648
+	 * @throws InvalidInterfaceException
649
+	 */
650
+	protected function _delete_question_groups()
651
+	{
652
+		$success = $this->_delete_items($this->_question_group_model);
653
+		$this->_redirect_after_action(
654
+			$success,
655
+			$this->_question_group_model->item_name($success),
656
+			'deleted permanently',
657
+			array('action' => 'question_groups', 'status' => 'trash')
658
+		);
659
+	}
660
+
661
+
662
+	/**
663
+	 * @param bool $new_question_group
664
+	 * @throws EE_Error
665
+	 * @throws InvalidArgumentException
666
+	 * @throws InvalidDataTypeException
667
+	 * @throws InvalidInterfaceException
668
+	 */
669
+	protected function _insert_or_update_question_group($new_question_group = true)
670
+	{
671
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
672
+		$set_column_values = $this->_set_column_values_for($this->_question_group_model);
673
+
674
+		// make sure identifier is unique
675
+		$identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : '';
676
+		$where_values = ['QSG_identifier' => $set_column_values['QSG_identifier']];
677
+		if (! $new_question_group && isset($set_column_values['QSG_ID'])) {
678
+			$where_values['QSG_ID'] = ['!=', $set_column_values['QSG_ID']];
679
+		}
680
+		$identifier_exists = ! empty($identifier_value)
681
+			? $this->_question_group_model->count([$where_values]) > 0
682
+			: false;
683
+		if ($identifier_exists) {
684
+			$set_column_values['QSG_identifier'] .= uniqid('id', true);
685
+		}
686
+
687
+		if ($new_question_group) {
688
+			$QSG_ID = $this->_question_group_model->insert($set_column_values);
689
+			$success = $QSG_ID ? 1 : 0;
690
+			if ($success === 0) {
691
+				EE_Error::add_error(
692
+					esc_html__('Something went wrong saving the question group.', 'event_espresso'),
693
+					__FILE__,
694
+					__FUNCTION__,
695
+					__LINE__
696
+				);
697
+				$this->_redirect_after_action(
698
+					false,
699
+					'',
700
+					'',
701
+					array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
702
+					true
703
+				);
704
+			}
705
+		} else {
706
+			$QSG_ID = absint($this->_req_data['QSG_ID']);
707
+			unset($set_column_values['QSG_ID']);
708
+			$success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
709
+		}
710
+
711
+		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(
712
+			EEM_Attendee::system_question_phone
713
+		);
714
+		// update the existing related questions
715
+		// BUT FIRST...  delete the phone question from the Question_Group_Question
716
+		// if it is being added to this question group (therefore removed from the existing group)
717
+		if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
718
+			// delete where QST ID = system phone question ID and Question Group ID is NOT this group
719
+			EEM_Question_Group_Question::instance()->delete(
720
+				array(
721
+					array(
722
+						'QST_ID' => $phone_question_id,
723
+						'QSG_ID' => array('!=', $QSG_ID),
724
+					),
725
+				)
726
+			);
727
+		}
728
+		/** @type EE_Question_Group $question_group */
729
+		$question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
730
+		$questions = $question_group->questions();
731
+		// make sure system phone question is added to list of questions for this group
732
+		if (! isset($questions[ $phone_question_id ])) {
733
+			$questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
734
+		}
735
+
736
+		foreach ($questions as $question_ID => $question) {
737
+			// first we always check for order.
738
+			if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
739
+				// update question order
740
+				$question_group->update_question_order(
741
+					$question_ID,
742
+					$this->_req_data['question_orders'][ $question_ID ]
743
+				);
744
+			}
745
+
746
+			// then we always check if adding or removing.
747
+			if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
748
+				$question_group->add_question($question_ID);
749
+			} else {
750
+				// not found, remove it (but only if not a system question for the personal group
751
+				// with the exception of lname system question - we allow removal of it)
752
+				if (
753
+					in_array(
754
+						$question->system_ID(),
755
+						EEM_Question::instance()->required_system_questions_in_system_question_group(
756
+							$question_group->system_group()
757
+						)
758
+					)
759
+				) {
760
+					continue;
761
+				} else {
762
+					$question_group->remove_question($question_ID);
763
+				}
764
+			}
765
+		}
766
+		// save new related questions
767
+		if (isset($this->_req_data['questions'])) {
768
+			foreach ($this->_req_data['questions'] as $QST_ID) {
769
+				$question_group->add_question($QST_ID);
770
+				if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
771
+					$question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
772
+				}
773
+			}
774
+		}
775
+
776
+		if ($success !== false) {
777
+			$msg = $new_question_group
778
+				? sprintf(
779
+					esc_html__('The %s has been created', 'event_espresso'),
780
+					$this->_question_group_model->item_name()
781
+				)
782
+				: sprintf(
783
+					esc_html__(
784
+						'The %s has been updated',
785
+						'event_espresso'
786
+					),
787
+					$this->_question_group_model->item_name()
788
+				);
789
+			EE_Error::add_success($msg);
790
+		}
791
+		$this->_redirect_after_action(
792
+			false,
793
+			'',
794
+			'',
795
+			array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
796
+			true
797
+		);
798
+	}
799
+
800
+
801
+	/**
802
+	 * duplicates a question and all its question options and redirects to the new question.
803
+	 *
804
+	 * @return void
805
+	 * @throws EE_Error
806
+	 * @throws InvalidArgumentException
807
+	 * @throws ReflectionException
808
+	 * @throws InvalidDataTypeException
809
+	 * @throws InvalidInterfaceException
810
+	 */
811
+	public function _duplicate_question()
812
+	{
813
+		$question_ID = (int) $this->_req_data['QST_ID'];
814
+		$question = EEM_Question::instance()->get_one_by_ID($question_ID);
815
+		if ($question instanceof EE_Question) {
816
+			$new_question = $question->duplicate();
817
+			if ($new_question instanceof EE_Question) {
818
+				$this->_redirect_after_action(
819
+					true,
820
+					esc_html__('Question', 'event_espresso'),
821
+					esc_html__('Duplicated', 'event_espresso'),
822
+					array('action' => 'edit_question', 'QST_ID' => $new_question->ID()),
823
+					true
824
+				);
825
+			} else {
826
+				global $wpdb;
827
+				EE_Error::add_error(
828
+					sprintf(
829
+						esc_html__(
830
+							'Could not duplicate question with ID %1$d because: %2$s',
831
+							'event_espresso'
832
+						),
833
+						$question_ID,
834
+						$wpdb->last_error
835
+					),
836
+					__FILE__,
837
+					__FUNCTION__,
838
+					__LINE__
839
+				);
840
+				$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
841
+			}
842
+		} else {
843
+			EE_Error::add_error(
844
+				sprintf(
845
+					esc_html__(
846
+						'Could not duplicate question with ID %d because it didn\'t exist!',
847
+						'event_espresso'
848
+					),
849
+					$question_ID
850
+				),
851
+				__FILE__,
852
+				__FUNCTION__,
853
+				__LINE__
854
+			);
855
+			$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
856
+		}
857
+	}
858
+
859
+
860
+	/**
861
+	 * @param bool $trash
862
+	 * @throws EE_Error
863
+	 */
864
+	protected function _trash_or_restore_question_groups($trash = true)
865
+	{
866
+		$this->_trash_or_restore_items($this->_question_group_model, $trash);
867
+	}
868
+
869
+
870
+	/**
871
+	 *_trash_question
872
+	 *
873
+	 * @return void
874
+	 * @throws EE_Error
875
+	 */
876
+	protected function _trash_question()
877
+	{
878
+		$success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
879
+		$query_args = array('action' => 'default', 'status' => 'all');
880
+		$this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
881
+	}
882
+
883
+
884
+	/**
885
+	 * @param bool $trash
886
+	 * @throws EE_Error
887
+	 */
888
+	protected function _trash_or_restore_questions($trash = true)
889
+	{
890
+		$this->_trash_or_restore_items($this->_question_model, $trash);
891
+	}
892
+
893
+
894
+	/**
895
+	 * Internally used to delete or restore items, using the request data. Meant to be
896
+	 * flexible between question or question groups
897
+	 *
898
+	 * @param EEM_Soft_Delete_Base $model
899
+	 * @param boolean              $trash whether to trash or restore
900
+	 * @throws EE_Error
901
+	 */
902
+	private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
903
+	{
904
+
905
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
906
+
907
+		$success = 1;
908
+		// Checkboxes
909
+		// echo "trash $trash";
910
+		// var_dump($this->_req_data['checkbox']);die;
911
+		if (isset($this->_req_data['checkbox'])) {
912
+			if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
913
+				// if array has more than one element than success message should be plural
914
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
915
+				// cycle thru bulk action checkboxes
916
+				while (list($ID, $value) = each($this->_req_data['checkbox'])) {
917
+					if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
918
+						$success = 0;
919
+					}
920
+				}
921
+			} else {
922
+				// grab single id and delete
923
+				$ID = absint($this->_req_data['checkbox']);
924
+				if (! $model->delete_or_restore_by_ID($trash, $ID)) {
925
+					$success = 0;
926
+				}
927
+			}
928
+		} else {
929
+			// delete via trash link
930
+			// grab single id and delete
931
+			$ID = absint($this->_req_data[ $model->primary_key_name() ]);
932
+			if (! $model->delete_or_restore_by_ID($trash, $ID)) {
933
+				$success = 0;
934
+			}
935
+		}
936
+
937
+
938
+		$action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
939
+		// echo "action :$action";
940
+		// $action = 'questions' ? 'default' : $action;
941
+		if ($trash) {
942
+			$action_desc = 'trashed';
943
+			$status = 'trash';
944
+		} else {
945
+			$action_desc = 'restored';
946
+			$status = 'all';
947
+		}
948
+		$this->_redirect_after_action(
949
+			$success,
950
+			$model->item_name($success),
951
+			$action_desc,
952
+			array('action' => $action, 'status' => $status)
953
+		);
954
+	}
955
+
956
+
957
+	/**
958
+	 * @param            $per_page
959
+	 * @param int        $current_page
960
+	 * @param bool|false $count
961
+	 * @return EE_Soft_Delete_Base_Class[]|int
962
+	 * @throws EE_Error
963
+	 * @throws InvalidArgumentException
964
+	 * @throws InvalidDataTypeException
965
+	 * @throws InvalidInterfaceException
966
+	 */
967
+	public function get_trashed_questions($per_page, $current_page = 1, $count = false)
968
+	{
969
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
970
+
971
+		if ($count) {
972
+			// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
973
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
974
+			$results = $this->_question_model->count_deleted($where);
975
+		} else {
976
+			// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
977
+			$results = $this->_question_model->get_all_deleted($query_params);
978
+		}
979
+		return $results;
980
+	}
981
+
982
+
983
+	/**
984
+	 * @param            $per_page
985
+	 * @param int        $current_page
986
+	 * @param bool|false $count
987
+	 * @return EE_Soft_Delete_Base_Class[]|int
988
+	 * @throws EE_Error
989
+	 * @throws InvalidArgumentException
990
+	 * @throws InvalidDataTypeException
991
+	 * @throws InvalidInterfaceException
992
+	 */
993
+	public function get_question_groups($per_page, $current_page = 1, $count = false)
994
+	{
995
+		$questionGroupModel = EEM_Question_Group::instance();
996
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
997
+		if ($count) {
998
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
999
+			$results = $questionGroupModel->count($where);
1000
+		} else {
1001
+			$results = $questionGroupModel->get_all($query_params);
1002
+		}
1003
+		return $results;
1004
+	}
1005
+
1006
+
1007
+	/**
1008
+	 * @param      $per_page
1009
+	 * @param int  $current_page
1010
+	 * @param bool $count
1011
+	 * @return EE_Soft_Delete_Base_Class[]|int
1012
+	 * @throws EE_Error
1013
+	 * @throws InvalidArgumentException
1014
+	 * @throws InvalidDataTypeException
1015
+	 * @throws InvalidInterfaceException
1016
+	 */
1017
+	public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
1018
+	{
1019
+		$questionGroupModel = EEM_Question_Group::instance();
1020
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
1021
+		if ($count) {
1022
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
1023
+			$query_params['limit'] = null;
1024
+			$results = $questionGroupModel->count_deleted($where);
1025
+		} else {
1026
+			$results = $questionGroupModel->get_all_deleted($query_params);
1027
+		}
1028
+		return $results;
1029
+	}
1030
+
1031
+
1032
+	/**
1033
+	 * method for performing updates to question order
1034
+	 *
1035
+	 * @return void results array
1036
+	 * @throws EE_Error
1037
+	 * @throws InvalidArgumentException
1038
+	 * @throws InvalidDataTypeException
1039
+	 * @throws InvalidInterfaceException
1040
+	 */
1041
+	public function update_question_group_order()
1042
+	{
1043
+
1044
+		$success = esc_html__('Question group order was updated successfully.', 'event_espresso');
1045
+
1046
+		// grab our row IDs
1047
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
1048
+			? explode(',', rtrim($this->_req_data['row_ids'], ','))
1049
+			: array();
1050
+
1051
+		$perpage = ! empty($this->_req_data['perpage'])
1052
+			? (int) $this->_req_data['perpage']
1053
+			: null;
1054
+		$curpage = ! empty($this->_req_data['curpage'])
1055
+			? (int) $this->_req_data['curpage']
1056
+			: null;
1057
+
1058
+		if (! empty($row_ids)) {
1059
+			// figure out where we start the row_id count at for the current page.
1060
+			$qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1061
+
1062
+			$row_count = count($row_ids);
1063
+			for ($i = 0; $i < $row_count; $i++) {
1064
+				// Update the questions when re-ordering
1065
+				$updated = EEM_Question_Group::instance()->update(
1066
+					array('QSG_order' => $qsgcount),
1067
+					array(array('QSG_ID' => $row_ids[ $i ]))
1068
+				);
1069
+				if ($updated === false) {
1070
+					$success = false;
1071
+				}
1072
+				$qsgcount++;
1073
+			}
1074
+		} else {
1075
+			$success = false;
1076
+		}
1077
+
1078
+		$errors = ! $success
1079
+			? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
1080
+			: false;
1081
+
1082
+		echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
1083
+		die();
1084
+	}
1085
+
1086
+
1087
+
1088
+	/***************************************       REGISTRATION SETTINGS       ***************************************/
1089
+
1090
+
1091
+	/**
1092
+	 * @throws DomainException
1093
+	 * @throws EE_Error
1094
+	 * @throws InvalidArgumentException
1095
+	 * @throws InvalidDataTypeException
1096
+	 * @throws InvalidInterfaceException
1097
+	 */
1098
+	protected function _reg_form_settings()
1099
+	{
1100
+		$this->_template_args['values'] = $this->_yes_no_values;
1101
+		add_action(
1102
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1103
+			array($this, 'email_validation_settings_form'),
1104
+			2
1105
+		);
1106
+		add_action(
1107
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1108
+			array($this, 'copy_attendee_info_settings_form'),
1109
+			4
1110
+		);
1111
+		$this->_template_args = (array) apply_filters(
1112
+			'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
1113
+			$this->_template_args
1114
+		);
1115
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
1116
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1117
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1118
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1119
+			$this->_template_args,
1120
+			true
1121
+		);
1122
+		$this->display_admin_page_with_sidebar();
1123
+	}
1124
+
1125
+
1126
+	/**
1127
+	 * @return void
1128
+	 * @throws EE_Error
1129
+	 * @throws InvalidArgumentException
1130
+	 * @throws ReflectionException
1131
+	 * @throws InvalidDataTypeException
1132
+	 * @throws InvalidInterfaceException
1133
+	 */
1134
+	protected function _update_reg_form_settings()
1135
+	{
1136
+		EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
1137
+			EE_Registry::instance()->CFG->registration
1138
+		);
1139
+		EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form(
1140
+			EE_Registry::instance()->CFG->registration
1141
+		);
1142
+		EE_Registry::instance()->CFG->registration = apply_filters(
1143
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
1144
+			EE_Registry::instance()->CFG->registration
1145
+		);
1146
+		$success = $this->_update_espresso_configuration(
1147
+			esc_html__('Registration Form Options', 'event_espresso'),
1148
+			EE_Registry::instance()->CFG,
1149
+			__FILE__,
1150
+			__FUNCTION__,
1151
+			__LINE__
1152
+		);
1153
+		$this->_redirect_after_action(
1154
+			$success,
1155
+			esc_html__('Registration Form Options', 'event_espresso'),
1156
+			'updated',
1157
+			array('action' => 'view_reg_form_settings')
1158
+		);
1159
+	}
1160
+
1161
+
1162
+	/**
1163
+	 * @return void
1164
+	 * @throws EE_Error
1165
+	 * @throws InvalidArgumentException
1166
+	 * @throws InvalidDataTypeException
1167
+	 * @throws InvalidInterfaceException
1168
+	 */
1169
+	public function copy_attendee_info_settings_form()
1170
+	{
1171
+		echo wp_kses($this->_copy_attendee_info_settings_form()->get_html(), AllowedTags::getWithFormTags());
1172
+	}
1173
+
1174
+	/**
1175
+	 * _copy_attendee_info_settings_form
1176
+	 *
1177
+	 * @access protected
1178
+	 * @return EE_Form_Section_Proper
1179
+	 * @throws \EE_Error
1180
+	 */
1181
+	protected function _copy_attendee_info_settings_form()
1182
+	{
1183
+		return new EE_Form_Section_Proper(
1184
+			array(
1185
+				'name'            => 'copy_attendee_info_settings',
1186
+				'html_id'         => 'copy_attendee_info_settings',
1187
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1188
+				'subsections'     => apply_filters(
1189
+					'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections',
1190
+					array(
1191
+						'copy_attendee_info_hdr'   => new EE_Form_Section_HTML(
1192
+							EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso'))
1193
+						),
1194
+						'copy_attendee_info' => new EE_Yes_No_Input(
1195
+							array(
1196
+								'html_label_text' => esc_html__(
1197
+									'Allow copy #1 attendee info to extra attendees?',
1198
+									'event_espresso'
1199
+								),
1200
+								'html_help_text'  => esc_html__(
1201
+									'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.',
1202
+									'event_espresso'
1203
+								),
1204
+								'default'         => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(),
1205
+								'required'        => false,
1206
+								'display_html_label_text' => false,
1207
+							)
1208
+						),
1209
+					)
1210
+				),
1211
+			)
1212
+		);
1213
+	}
1214
+
1215
+	/**
1216
+	 * @param EE_Registration_Config $EE_Registration_Config
1217
+	 * @return EE_Registration_Config
1218
+	 * @throws EE_Error
1219
+	 * @throws InvalidArgumentException
1220
+	 * @throws ReflectionException
1221
+	 * @throws InvalidDataTypeException
1222
+	 * @throws InvalidInterfaceException
1223
+	 */
1224
+	public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config)
1225
+	{
1226
+		$prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo();
1227
+		try {
1228
+			$copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form();
1229
+			// if not displaying a form, then check for form submission
1230
+			if ($copy_attendee_info_settings_form->was_submitted()) {
1231
+				// capture form data
1232
+				$copy_attendee_info_settings_form->receive_form_submission();
1233
+				// validate form data
1234
+				if ($copy_attendee_info_settings_form->is_valid()) {
1235
+					// grab validated data from form
1236
+					$valid_data = $copy_attendee_info_settings_form->valid_data();
1237
+					if (isset($valid_data['copy_attendee_info'])) {
1238
+						$EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']);
1239
+					} else {
1240
+						EE_Error::add_error(
1241
+							esc_html__(
1242
+								'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.',
1243
+								'event_espresso'
1244
+							),
1245
+							__FILE__,
1246
+							__FUNCTION__,
1247
+							__LINE__
1248
+						);
1249
+					}
1250
+				} else {
1251
+					if ($copy_attendee_info_settings_form->submission_error_message() !== '') {
1252
+						EE_Error::add_error(
1253
+							$copy_attendee_info_settings_form->submission_error_message(),
1254
+							__FILE__,
1255
+							__FUNCTION__,
1256
+							__LINE__
1257
+						);
1258
+					}
1259
+				}
1260
+			}
1261
+		} catch (EE_Error $e) {
1262
+			$e->get_error();
1263
+		}
1264
+		return $EE_Registration_Config;
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 * @return void
1270
+	 * @throws EE_Error
1271
+	 * @throws InvalidArgumentException
1272
+	 * @throws InvalidDataTypeException
1273
+	 * @throws InvalidInterfaceException
1274
+	 */
1275
+	public function email_validation_settings_form()
1276
+	{
1277
+		echo wp_kses($this->_email_validation_settings_form()->get_html(), AllowedTags::getWithFormTags());
1278
+	}
1279
+
1280
+
1281
+	/**
1282
+	 * _email_validation_settings_form
1283
+	 *
1284
+	 * @access protected
1285
+	 * @return EE_Form_Section_Proper
1286
+	 * @throws \EE_Error
1287
+	 */
1288
+	protected function _email_validation_settings_form()
1289
+	{
1290
+		return new EE_Form_Section_Proper(
1291
+			array(
1292
+				'name'            => 'email_validation_settings',
1293
+				'html_id'         => 'email_validation_settings',
1294
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1295
+				'subsections'     => apply_filters(
1296
+					'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
1297
+					array(
1298
+						'email_validation_hdr'   => new EE_Form_Section_HTML(
1299
+							EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
1300
+						),
1301
+						'email_validation_level' => new EE_Select_Input(
1302
+							array(
1303
+								'basic'      => esc_html__('Basic', 'event_espresso'),
1304
+								'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
1305
+								'i18n'       => esc_html__('International', 'event_espresso'),
1306
+								'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
1307
+							),
1308
+							array(
1309
+								'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
1310
+													 . EEH_Template::get_help_tab_link('email_validation_info'),
1311
+								'html_help_text'  => esc_html__(
1312
+									'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.',
1313
+									'event_espresso'
1314
+								),
1315
+								'default'         => isset(
1316
+									EE_Registry::instance()->CFG->registration->email_validation_level
1317
+								)
1318
+									? EE_Registry::instance()->CFG->registration->email_validation_level
1319
+									: 'wp_default',
1320
+								'required'        => false,
1321
+							)
1322
+						),
1323
+					)
1324
+				),
1325
+			)
1326
+		);
1327
+	}
1328
+
1329
+
1330
+	/**
1331
+	 * @param EE_Registration_Config $EE_Registration_Config
1332
+	 * @return EE_Registration_Config
1333
+	 * @throws EE_Error
1334
+	 * @throws InvalidArgumentException
1335
+	 * @throws ReflectionException
1336
+	 * @throws InvalidDataTypeException
1337
+	 * @throws InvalidInterfaceException
1338
+	 */
1339
+	public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1340
+	{
1341
+		$prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1342
+		try {
1343
+			$email_validation_settings_form = $this->_email_validation_settings_form();
1344
+			// if not displaying a form, then check for form submission
1345
+			if ($email_validation_settings_form->was_submitted()) {
1346
+				// capture form data
1347
+				$email_validation_settings_form->receive_form_submission();
1348
+				// validate form data
1349
+				if ($email_validation_settings_form->is_valid()) {
1350
+					// grab validated data from form
1351
+					$valid_data = $email_validation_settings_form->valid_data();
1352
+					if (isset($valid_data['email_validation_level'])) {
1353
+						$email_validation_level = $valid_data['email_validation_level'];
1354
+						// now if they want to use international email addresses
1355
+						if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1356
+							// in case we need to reset their email validation level,
1357
+							// make sure that the previous value wasn't already set to one of the i18n options.
1358
+							if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1359
+								// if so, then reset it back to "basic" since that is the only other option that,
1360
+								// despite offering poor validation, supports i18n email addresses
1361
+								$prev_email_validation_level = 'basic';
1362
+							}
1363
+							// confirm our i18n email validation will work on the server
1364
+							if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1365
+								// or reset email validation level to previous value
1366
+								$email_validation_level = $prev_email_validation_level;
1367
+							}
1368
+						}
1369
+						$EE_Registration_Config->email_validation_level = $email_validation_level;
1370
+					} else {
1371
+						EE_Error::add_error(
1372
+							esc_html__(
1373
+								'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1374
+								'event_espresso'
1375
+							),
1376
+							__FILE__,
1377
+							__FUNCTION__,
1378
+							__LINE__
1379
+						);
1380
+					}
1381
+				} else {
1382
+					if ($email_validation_settings_form->submission_error_message() !== '') {
1383
+						EE_Error::add_error(
1384
+							$email_validation_settings_form->submission_error_message(),
1385
+							__FILE__,
1386
+							__FUNCTION__,
1387
+							__LINE__
1388
+						);
1389
+					}
1390
+				}
1391
+			}
1392
+		} catch (EE_Error $e) {
1393
+			$e->get_error();
1394
+		}
1395
+		return $EE_Registration_Config;
1396
+	}
1397
+
1398
+
1399
+	/**
1400
+	 * confirms that the server's PHP version has the PCRE module enabled,
1401
+	 * and that the PCRE version works with our i18n email validation
1402
+	 *
1403
+	 * @param EE_Registration_Config $EE_Registration_Config
1404
+	 * @param string                 $email_validation_level
1405
+	 * @return bool
1406
+	 */
1407
+	private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1408
+	{
1409
+		// first check that PCRE is enabled
1410
+		if (! defined('PREG_BAD_UTF8_ERROR')) {
1411
+			EE_Error::add_error(
1412
+				sprintf(
1413
+					esc_html__(
1414
+						'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.',
1415
+						'event_espresso'
1416
+					),
1417
+					'<br />'
1418
+				),
1419
+				__FILE__,
1420
+				__FUNCTION__,
1421
+				__LINE__
1422
+			);
1423
+			return false;
1424
+		} else {
1425
+			// PCRE support is enabled, but let's still
1426
+			// perform a test to see if the server will support it.
1427
+			// but first, save the updated validation level to the config,
1428
+			// so that the validation strategy picks it up.
1429
+			// this will get bumped back down if it doesn't work
1430
+			$EE_Registration_Config->email_validation_level = $email_validation_level;
1431
+			try {
1432
+				$email_validator = new EE_Email_Validation_Strategy();
1433
+				$i18n_email_address = apply_filters(
1434
+					'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1435
+					'jägerjü[email protected]'
1436
+				);
1437
+				$email_validator->validate($i18n_email_address);
1438
+			} catch (Exception $e) {
1439
+				EE_Error::add_error(
1440
+					sprintf(
1441
+						esc_html__(
1442
+							'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s',
1443
+							'event_espresso'
1444
+						),
1445
+						'<br />',
1446
+						'<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>'
1447
+					),
1448
+					__FILE__,
1449
+					__FUNCTION__,
1450
+					__LINE__
1451
+				);
1452
+				return false;
1453
+			}
1454
+		}
1455
+		return true;
1456
+	}
1457 1457
 }
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 1 patch
Indentation   +1357 added lines, -1357 removed lines patch added patch discarded remove patch
@@ -14,1367 +14,1367 @@
 block discarded – undo
14 14
  */
15 15
 class Extend_Events_Admin_Page extends Events_Admin_Page
16 16
 {
17
-    /**
18
-     * @var EE_Admin_Config
19
-     */
20
-    protected $admin_config;
21
-
22
-
23
-    /**
24
-     * Extend_Events_Admin_Page constructor.
25
-     *
26
-     * @param bool $routing
27
-     * @throws EE_Error
28
-     * @throws ReflectionException
29
-     */
30
-    public function __construct($routing = true)
31
-    {
32
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
33
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
34
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
35
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
36
-        }
37
-        parent::__construct($routing);
38
-        $this->admin_config = $this->loader->getShared('EE_Admin_Config');
39
-    }
40
-
41
-
42
-    /**
43
-     * Sets routes.
44
-     *
45
-     * @throws EE_Error
46
-     */
47
-    protected function _extend_page_config()
48
-    {
49
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
50
-        // is there a evt_id in the request?
51
-        $EVT_ID             = $this->request->getRequestParam('EVT_ID', 0, 'int');
52
-        $EVT_ID             = $this->request->getRequestParam('post', $EVT_ID, 'int');
53
-        $TKT_ID             = $this->request->getRequestParam('TKT_ID', 0, 'int');
54
-        $new_page_routes    = [
55
-            'duplicate_event'          => [
56
-                'func'       => '_duplicate_event',
57
-                'capability' => 'ee_edit_event',
58
-                'obj_id'     => $EVT_ID,
59
-                'noheader'   => true,
60
-            ],
61
-            'import_page'              => [
62
-                'func'       => '_import_page',
63
-                'capability' => 'import',
64
-            ],
65
-            'import'                   => [
66
-                'func'       => '_import_events',
67
-                'capability' => 'import',
68
-                'noheader'   => true,
69
-            ],
70
-            'import_events'            => [
71
-                'func'       => '_import_events',
72
-                'capability' => 'import',
73
-                'noheader'   => true,
74
-            ],
75
-            'export_events'            => [
76
-                'func'       => '_events_export',
77
-                'capability' => 'export',
78
-                'noheader'   => true,
79
-            ],
80
-            'export_categories'        => [
81
-                'func'       => '_categories_export',
82
-                'capability' => 'export',
83
-                'noheader'   => true,
84
-            ],
85
-            'sample_export_file'       => [
86
-                'func'       => '_sample_export_file',
87
-                'capability' => 'export',
88
-                'noheader'   => true,
89
-            ],
90
-            'update_template_settings' => [
91
-                'func'       => '_update_template_settings',
92
-                'capability' => 'manage_options',
93
-                'noheader'   => true,
94
-            ],
95
-            'ticket_list_table'        => [
96
-                'func'       => '_tickets_overview_list_table',
97
-                'capability' => 'ee_read_default_tickets',
98
-            ],
99
-        ];
100
-        $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
101
-        $this->_page_config['edit']['metaboxes'][]       = '_premium_event_editor_meta_boxes';
102
-        // don't load these meta boxes if using the advanced editor
103
-        if (
104
-            ! $this->admin_config->useAdvancedEditor()
105
-            || ! $this->feature->allowed('use_default_ticket_manager')
106
-        ) {
107
-            $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
108
-            $this->_page_config['edit']['qtips'][]       = 'EE_Event_Editor_Tips';
109
-
110
-            $legacy_editor_page_routes = [
111
-                'trash_ticket'    => [
112
-                    'func'       => '_trash_or_restore_ticket',
113
-                    'capability' => 'ee_delete_default_ticket',
114
-                    'obj_id'     => $TKT_ID,
115
-                    'noheader'   => true,
116
-                    'args'       => ['trash' => true],
117
-                ],
118
-                'trash_tickets'   => [
119
-                    'func'       => '_trash_or_restore_ticket',
120
-                    'capability' => 'ee_delete_default_tickets',
121
-                    'noheader'   => true,
122
-                    'args'       => ['trash' => true],
123
-                ],
124
-                'restore_ticket'  => [
125
-                    'func'       => '_trash_or_restore_ticket',
126
-                    'capability' => 'ee_delete_default_ticket',
127
-                    'obj_id'     => $TKT_ID,
128
-                    'noheader'   => true,
129
-                ],
130
-                'restore_tickets' => [
131
-                    'func'       => '_trash_or_restore_ticket',
132
-                    'capability' => 'ee_delete_default_tickets',
133
-                    'noheader'   => true,
134
-                ],
135
-                'delete_ticket'   => [
136
-                    'func'       => '_delete_ticket',
137
-                    'capability' => 'ee_delete_default_ticket',
138
-                    'obj_id'     => $TKT_ID,
139
-                    'noheader'   => true,
140
-                ],
141
-                'delete_tickets'  => [
142
-                    'func'       => '_delete_ticket',
143
-                    'capability' => 'ee_delete_default_tickets',
144
-                    'noheader'   => true,
145
-                ],
146
-            ];
147
-            $new_page_routes           = array_merge($new_page_routes, $legacy_editor_page_routes);
148
-        }
149
-
150
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
151
-        // partial route/config override
152
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
153
-        $this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
154
-        // add tickets tab but only if there are more than one default ticket!
155
-        $ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
156
-            [['TKT_is_default' => 1]],
157
-            'TKT_ID',
158
-            true
159
-        );
160
-        if ($ticket_count > 1) {
161
-            $new_page_config = [
162
-                'ticket_list_table' => [
163
-                    'nav'           => [
164
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
165
-                        'order' => 60,
166
-                    ],
167
-                    'list_table'    => 'Tickets_List_Table',
168
-                    'require_nonce' => false,
169
-                ],
170
-            ];
171
-        }
172
-        // template settings
173
-        $new_page_config['template_settings'] = [
174
-            'nav'           => [
175
-                'label' => esc_html__('Templates', 'event_espresso'),
176
-                'icon' => 'dashicons-layout',
177
-                'order' => 30,
178
-            ],
179
-            'metaboxes'     => array_merge(['_publish_post_box'], $this->_default_espresso_metaboxes),
180
-            'help_tabs'     => [
181
-                'general_settings_templates_help_tab' => [
182
-                    'title'    => esc_html__('Templates', 'event_espresso'),
183
-                    'filename' => 'general_settings_templates',
184
-                ],
185
-            ],
186
-            'require_nonce' => false,
187
-        ];
188
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
189
-        // add filters and actions
190
-        // modifying _views
191
-        add_filter(
192
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
193
-            [$this, 'add_additional_datetime_button'],
194
-            10,
195
-            2
196
-        );
197
-        add_filter(
198
-            'FHEE_event_datetime_metabox_clone_button_template',
199
-            [$this, 'add_datetime_clone_button'],
200
-            10,
201
-            2
202
-        );
203
-        add_filter(
204
-            'FHEE_event_datetime_metabox_timezones_template',
205
-            [$this, 'datetime_timezones_template'],
206
-            10,
207
-            2
208
-        );
209
-        // filters for event list table
210
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2);
211
-        add_filter(
212
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
213
-            [$this, 'extra_list_table_actions'],
214
-            10,
215
-            2
216
-        );
217
-        // legend item
218
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
219
-        add_action('admin_init', [$this, 'admin_init']);
220
-    }
221
-
222
-
223
-    /**
224
-     * admin_init
225
-     */
226
-    public function admin_init()
227
-    {
228
-        EE_Registry::$i18n_js_strings = array_merge(
229
-            EE_Registry::$i18n_js_strings,
230
-            [
231
-                'image_confirm'          => esc_html__(
232
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
233
-                    'event_espresso'
234
-                ),
235
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
236
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
237
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
238
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
239
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
240
-            ]
241
-        );
242
-    }
243
-
244
-
245
-    /**
246
-     * Add per page screen options to the default ticket list table view.
247
-     *
248
-     * @throws InvalidArgumentException
249
-     * @throws InvalidDataTypeException
250
-     * @throws InvalidInterfaceException
251
-     */
252
-    protected function _add_screen_options_ticket_list_table()
253
-    {
254
-        $this->_per_page_screen_option();
255
-    }
256
-
257
-
258
-    /**
259
-     * @param string $return
260
-     * @param int    $id
261
-     * @param string $new_title
262
-     * @param string $new_slug
263
-     * @return string
264
-     */
265
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
266
-    {
267
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
268
-        // make sure this is only when editing
269
-        if (! empty($id)) {
270
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
271
-                ['action' => 'duplicate_event', 'EVT_ID' => $id],
272
-                $this->_admin_base_url
273
-            );
274
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
275
-            $return .= '<a href="'
276
-                       . $href
277
-                       . '" title="'
278
-                       . $title
279
-                       . '" id="ee-duplicate-event-button" class="button button--small button--secondary"  value="duplicate_event">'
280
-                       . $title
281
-                       . '</a>';
282
-        }
283
-        return $return;
284
-    }
285
-
286
-
287
-    /**
288
-     * Set the list table views for the default ticket list table view.
289
-     */
290
-    public function _set_list_table_views_ticket_list_table()
291
-    {
292
-        $this->_views = [
293
-            'all'     => [
294
-                'slug'        => 'all',
295
-                'label'       => esc_html__('All', 'event_espresso'),
296
-                'count'       => 0,
297
-                'bulk_action' => [
298
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
299
-                ],
300
-            ],
301
-            'trashed' => [
302
-                'slug'        => 'trashed',
303
-                'label'       => esc_html__('Trash', 'event_espresso'),
304
-                'count'       => 0,
305
-                'bulk_action' => [
306
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
307
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
308
-                ],
309
-            ],
310
-        ];
311
-    }
312
-
313
-
314
-    /**
315
-     * Enqueue scripts and styles for the event editor.
316
-     */
317
-    public function load_scripts_styles_edit()
318
-    {
319
-        if (! $this->admin_config->useAdvancedEditor()) {
320
-            wp_register_script(
321
-                'ee-event-editor-heartbeat',
322
-                EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
323
-                ['ee_admin_js', 'heartbeat'],
324
-                EVENT_ESPRESSO_VERSION,
325
-                true
326
-            );
327
-            wp_enqueue_script('ee-accounting');
328
-            wp_enqueue_script('ee-event-editor-heartbeat');
329
-        }
330
-        wp_enqueue_script('event_editor_js');
331
-        // styles
332
-        wp_enqueue_style('espresso-ui-theme');
333
-    }
334
-
335
-
336
-    /**
337
-     * Returns template for the additional datetime.
338
-     *
339
-     * @param string $template
340
-     * @param array  $template_args
341
-     * @return string
342
-     * @throws DomainException
343
-     */
344
-    public function add_additional_datetime_button($template, $template_args)
345
-    {
346
-        return EEH_Template::display_template(
347
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
348
-            $template_args,
349
-            true
350
-        );
351
-    }
352
-
353
-
354
-    /**
355
-     * Returns the template for cloning a datetime.
356
-     *
357
-     * @param $template
358
-     * @param $template_args
359
-     * @return string
360
-     * @throws DomainException
361
-     */
362
-    public function add_datetime_clone_button($template, $template_args)
363
-    {
364
-        return EEH_Template::display_template(
365
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
366
-            $template_args,
367
-            true
368
-        );
369
-    }
370
-
371
-
372
-    /**
373
-     * Returns the template for datetime timezones.
374
-     *
375
-     * @param $template
376
-     * @param $template_args
377
-     * @return string
378
-     * @throws DomainException
379
-     */
380
-    public function datetime_timezones_template($template, $template_args)
381
-    {
382
-        return EEH_Template::display_template(
383
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
384
-            $template_args,
385
-            true
386
-        );
387
-    }
388
-
389
-
390
-    /**
391
-     * Sets the views for the default list table view.
392
-     *
393
-     * @throws EE_Error
394
-     */
395
-    protected function _set_list_table_views_default()
396
-    {
397
-        parent::_set_list_table_views_default();
398
-        $new_views    = [
399
-            'today' => [
400
-                'slug'        => 'today',
401
-                'label'       => esc_html__('Today', 'event_espresso'),
402
-                'count'       => $this->total_events_today(),
403
-                'bulk_action' => [
404
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
405
-                ],
406
-            ],
407
-            'month' => [
408
-                'slug'        => 'month',
409
-                'label'       => esc_html__('This Month', 'event_espresso'),
410
-                'count'       => $this->total_events_this_month(),
411
-                'bulk_action' => [
412
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
413
-                ],
414
-            ],
415
-        ];
416
-        $this->_views = array_merge($this->_views, $new_views);
417
-    }
418
-
419
-
420
-    /**
421
-     * Returns the extra action links for the default list table view.
422
-     *
423
-     * @param array    $action_links
424
-     * @param EE_Event $event
425
-     * @return array
426
-     * @throws EE_Error
427
-     * @throws ReflectionException
428
-     */
429
-    public function extra_list_table_actions(array $action_links, EE_Event $event)
430
-    {
431
-        if (
432
-            EE_Registry::instance()->CAP->current_user_can(
433
-                'ee_read_registrations',
434
-                'espresso_registrations_reports',
435
-                $event->ID()
436
-            )
437
-        ) {
438
-            $reports_link = EE_Admin_Page::add_query_args_and_nonce(
439
-                [
440
-                    'action' => 'reports',
441
-                    'EVT_ID' => $event->ID(),
442
-                ],
443
-                REG_ADMIN_URL
444
-            );
445
-
446
-            $action_links[]     = '
17
+	/**
18
+	 * @var EE_Admin_Config
19
+	 */
20
+	protected $admin_config;
21
+
22
+
23
+	/**
24
+	 * Extend_Events_Admin_Page constructor.
25
+	 *
26
+	 * @param bool $routing
27
+	 * @throws EE_Error
28
+	 * @throws ReflectionException
29
+	 */
30
+	public function __construct($routing = true)
31
+	{
32
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
33
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
34
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
35
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
36
+		}
37
+		parent::__construct($routing);
38
+		$this->admin_config = $this->loader->getShared('EE_Admin_Config');
39
+	}
40
+
41
+
42
+	/**
43
+	 * Sets routes.
44
+	 *
45
+	 * @throws EE_Error
46
+	 */
47
+	protected function _extend_page_config()
48
+	{
49
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
50
+		// is there a evt_id in the request?
51
+		$EVT_ID             = $this->request->getRequestParam('EVT_ID', 0, 'int');
52
+		$EVT_ID             = $this->request->getRequestParam('post', $EVT_ID, 'int');
53
+		$TKT_ID             = $this->request->getRequestParam('TKT_ID', 0, 'int');
54
+		$new_page_routes    = [
55
+			'duplicate_event'          => [
56
+				'func'       => '_duplicate_event',
57
+				'capability' => 'ee_edit_event',
58
+				'obj_id'     => $EVT_ID,
59
+				'noheader'   => true,
60
+			],
61
+			'import_page'              => [
62
+				'func'       => '_import_page',
63
+				'capability' => 'import',
64
+			],
65
+			'import'                   => [
66
+				'func'       => '_import_events',
67
+				'capability' => 'import',
68
+				'noheader'   => true,
69
+			],
70
+			'import_events'            => [
71
+				'func'       => '_import_events',
72
+				'capability' => 'import',
73
+				'noheader'   => true,
74
+			],
75
+			'export_events'            => [
76
+				'func'       => '_events_export',
77
+				'capability' => 'export',
78
+				'noheader'   => true,
79
+			],
80
+			'export_categories'        => [
81
+				'func'       => '_categories_export',
82
+				'capability' => 'export',
83
+				'noheader'   => true,
84
+			],
85
+			'sample_export_file'       => [
86
+				'func'       => '_sample_export_file',
87
+				'capability' => 'export',
88
+				'noheader'   => true,
89
+			],
90
+			'update_template_settings' => [
91
+				'func'       => '_update_template_settings',
92
+				'capability' => 'manage_options',
93
+				'noheader'   => true,
94
+			],
95
+			'ticket_list_table'        => [
96
+				'func'       => '_tickets_overview_list_table',
97
+				'capability' => 'ee_read_default_tickets',
98
+			],
99
+		];
100
+		$this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
101
+		$this->_page_config['edit']['metaboxes'][]       = '_premium_event_editor_meta_boxes';
102
+		// don't load these meta boxes if using the advanced editor
103
+		if (
104
+			! $this->admin_config->useAdvancedEditor()
105
+			|| ! $this->feature->allowed('use_default_ticket_manager')
106
+		) {
107
+			$this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
108
+			$this->_page_config['edit']['qtips'][]       = 'EE_Event_Editor_Tips';
109
+
110
+			$legacy_editor_page_routes = [
111
+				'trash_ticket'    => [
112
+					'func'       => '_trash_or_restore_ticket',
113
+					'capability' => 'ee_delete_default_ticket',
114
+					'obj_id'     => $TKT_ID,
115
+					'noheader'   => true,
116
+					'args'       => ['trash' => true],
117
+				],
118
+				'trash_tickets'   => [
119
+					'func'       => '_trash_or_restore_ticket',
120
+					'capability' => 'ee_delete_default_tickets',
121
+					'noheader'   => true,
122
+					'args'       => ['trash' => true],
123
+				],
124
+				'restore_ticket'  => [
125
+					'func'       => '_trash_or_restore_ticket',
126
+					'capability' => 'ee_delete_default_ticket',
127
+					'obj_id'     => $TKT_ID,
128
+					'noheader'   => true,
129
+				],
130
+				'restore_tickets' => [
131
+					'func'       => '_trash_or_restore_ticket',
132
+					'capability' => 'ee_delete_default_tickets',
133
+					'noheader'   => true,
134
+				],
135
+				'delete_ticket'   => [
136
+					'func'       => '_delete_ticket',
137
+					'capability' => 'ee_delete_default_ticket',
138
+					'obj_id'     => $TKT_ID,
139
+					'noheader'   => true,
140
+				],
141
+				'delete_tickets'  => [
142
+					'func'       => '_delete_ticket',
143
+					'capability' => 'ee_delete_default_tickets',
144
+					'noheader'   => true,
145
+				],
146
+			];
147
+			$new_page_routes           = array_merge($new_page_routes, $legacy_editor_page_routes);
148
+		}
149
+
150
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
151
+		// partial route/config override
152
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
153
+		$this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
154
+		// add tickets tab but only if there are more than one default ticket!
155
+		$ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
156
+			[['TKT_is_default' => 1]],
157
+			'TKT_ID',
158
+			true
159
+		);
160
+		if ($ticket_count > 1) {
161
+			$new_page_config = [
162
+				'ticket_list_table' => [
163
+					'nav'           => [
164
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
165
+						'order' => 60,
166
+					],
167
+					'list_table'    => 'Tickets_List_Table',
168
+					'require_nonce' => false,
169
+				],
170
+			];
171
+		}
172
+		// template settings
173
+		$new_page_config['template_settings'] = [
174
+			'nav'           => [
175
+				'label' => esc_html__('Templates', 'event_espresso'),
176
+				'icon' => 'dashicons-layout',
177
+				'order' => 30,
178
+			],
179
+			'metaboxes'     => array_merge(['_publish_post_box'], $this->_default_espresso_metaboxes),
180
+			'help_tabs'     => [
181
+				'general_settings_templates_help_tab' => [
182
+					'title'    => esc_html__('Templates', 'event_espresso'),
183
+					'filename' => 'general_settings_templates',
184
+				],
185
+			],
186
+			'require_nonce' => false,
187
+		];
188
+		$this->_page_config                   = array_merge($this->_page_config, $new_page_config);
189
+		// add filters and actions
190
+		// modifying _views
191
+		add_filter(
192
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
193
+			[$this, 'add_additional_datetime_button'],
194
+			10,
195
+			2
196
+		);
197
+		add_filter(
198
+			'FHEE_event_datetime_metabox_clone_button_template',
199
+			[$this, 'add_datetime_clone_button'],
200
+			10,
201
+			2
202
+		);
203
+		add_filter(
204
+			'FHEE_event_datetime_metabox_timezones_template',
205
+			[$this, 'datetime_timezones_template'],
206
+			10,
207
+			2
208
+		);
209
+		// filters for event list table
210
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2);
211
+		add_filter(
212
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
213
+			[$this, 'extra_list_table_actions'],
214
+			10,
215
+			2
216
+		);
217
+		// legend item
218
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
219
+		add_action('admin_init', [$this, 'admin_init']);
220
+	}
221
+
222
+
223
+	/**
224
+	 * admin_init
225
+	 */
226
+	public function admin_init()
227
+	{
228
+		EE_Registry::$i18n_js_strings = array_merge(
229
+			EE_Registry::$i18n_js_strings,
230
+			[
231
+				'image_confirm'          => esc_html__(
232
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
233
+					'event_espresso'
234
+				),
235
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
236
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
237
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
238
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
239
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
240
+			]
241
+		);
242
+	}
243
+
244
+
245
+	/**
246
+	 * Add per page screen options to the default ticket list table view.
247
+	 *
248
+	 * @throws InvalidArgumentException
249
+	 * @throws InvalidDataTypeException
250
+	 * @throws InvalidInterfaceException
251
+	 */
252
+	protected function _add_screen_options_ticket_list_table()
253
+	{
254
+		$this->_per_page_screen_option();
255
+	}
256
+
257
+
258
+	/**
259
+	 * @param string $return
260
+	 * @param int    $id
261
+	 * @param string $new_title
262
+	 * @param string $new_slug
263
+	 * @return string
264
+	 */
265
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
266
+	{
267
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
268
+		// make sure this is only when editing
269
+		if (! empty($id)) {
270
+			$href   = EE_Admin_Page::add_query_args_and_nonce(
271
+				['action' => 'duplicate_event', 'EVT_ID' => $id],
272
+				$this->_admin_base_url
273
+			);
274
+			$title  = esc_attr__('Duplicate Event', 'event_espresso');
275
+			$return .= '<a href="'
276
+					   . $href
277
+					   . '" title="'
278
+					   . $title
279
+					   . '" id="ee-duplicate-event-button" class="button button--small button--secondary"  value="duplicate_event">'
280
+					   . $title
281
+					   . '</a>';
282
+		}
283
+		return $return;
284
+	}
285
+
286
+
287
+	/**
288
+	 * Set the list table views for the default ticket list table view.
289
+	 */
290
+	public function _set_list_table_views_ticket_list_table()
291
+	{
292
+		$this->_views = [
293
+			'all'     => [
294
+				'slug'        => 'all',
295
+				'label'       => esc_html__('All', 'event_espresso'),
296
+				'count'       => 0,
297
+				'bulk_action' => [
298
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
299
+				],
300
+			],
301
+			'trashed' => [
302
+				'slug'        => 'trashed',
303
+				'label'       => esc_html__('Trash', 'event_espresso'),
304
+				'count'       => 0,
305
+				'bulk_action' => [
306
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
307
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
308
+				],
309
+			],
310
+		];
311
+	}
312
+
313
+
314
+	/**
315
+	 * Enqueue scripts and styles for the event editor.
316
+	 */
317
+	public function load_scripts_styles_edit()
318
+	{
319
+		if (! $this->admin_config->useAdvancedEditor()) {
320
+			wp_register_script(
321
+				'ee-event-editor-heartbeat',
322
+				EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
323
+				['ee_admin_js', 'heartbeat'],
324
+				EVENT_ESPRESSO_VERSION,
325
+				true
326
+			);
327
+			wp_enqueue_script('ee-accounting');
328
+			wp_enqueue_script('ee-event-editor-heartbeat');
329
+		}
330
+		wp_enqueue_script('event_editor_js');
331
+		// styles
332
+		wp_enqueue_style('espresso-ui-theme');
333
+	}
334
+
335
+
336
+	/**
337
+	 * Returns template for the additional datetime.
338
+	 *
339
+	 * @param string $template
340
+	 * @param array  $template_args
341
+	 * @return string
342
+	 * @throws DomainException
343
+	 */
344
+	public function add_additional_datetime_button($template, $template_args)
345
+	{
346
+		return EEH_Template::display_template(
347
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
348
+			$template_args,
349
+			true
350
+		);
351
+	}
352
+
353
+
354
+	/**
355
+	 * Returns the template for cloning a datetime.
356
+	 *
357
+	 * @param $template
358
+	 * @param $template_args
359
+	 * @return string
360
+	 * @throws DomainException
361
+	 */
362
+	public function add_datetime_clone_button($template, $template_args)
363
+	{
364
+		return EEH_Template::display_template(
365
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
366
+			$template_args,
367
+			true
368
+		);
369
+	}
370
+
371
+
372
+	/**
373
+	 * Returns the template for datetime timezones.
374
+	 *
375
+	 * @param $template
376
+	 * @param $template_args
377
+	 * @return string
378
+	 * @throws DomainException
379
+	 */
380
+	public function datetime_timezones_template($template, $template_args)
381
+	{
382
+		return EEH_Template::display_template(
383
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
384
+			$template_args,
385
+			true
386
+		);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Sets the views for the default list table view.
392
+	 *
393
+	 * @throws EE_Error
394
+	 */
395
+	protected function _set_list_table_views_default()
396
+	{
397
+		parent::_set_list_table_views_default();
398
+		$new_views    = [
399
+			'today' => [
400
+				'slug'        => 'today',
401
+				'label'       => esc_html__('Today', 'event_espresso'),
402
+				'count'       => $this->total_events_today(),
403
+				'bulk_action' => [
404
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
405
+				],
406
+			],
407
+			'month' => [
408
+				'slug'        => 'month',
409
+				'label'       => esc_html__('This Month', 'event_espresso'),
410
+				'count'       => $this->total_events_this_month(),
411
+				'bulk_action' => [
412
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
413
+				],
414
+			],
415
+		];
416
+		$this->_views = array_merge($this->_views, $new_views);
417
+	}
418
+
419
+
420
+	/**
421
+	 * Returns the extra action links for the default list table view.
422
+	 *
423
+	 * @param array    $action_links
424
+	 * @param EE_Event $event
425
+	 * @return array
426
+	 * @throws EE_Error
427
+	 * @throws ReflectionException
428
+	 */
429
+	public function extra_list_table_actions(array $action_links, EE_Event $event)
430
+	{
431
+		if (
432
+			EE_Registry::instance()->CAP->current_user_can(
433
+				'ee_read_registrations',
434
+				'espresso_registrations_reports',
435
+				$event->ID()
436
+			)
437
+		) {
438
+			$reports_link = EE_Admin_Page::add_query_args_and_nonce(
439
+				[
440
+					'action' => 'reports',
441
+					'EVT_ID' => $event->ID(),
442
+				],
443
+				REG_ADMIN_URL
444
+			);
445
+
446
+			$action_links[]     = '
447 447
                 <a href="' . $reports_link . '" 
448 448
                     aria-label="' . esc_attr__('View Report', 'event_espresso') . '" 
449 449
                     class="ee-aria-tooltip button button--icon-only"
450 450
                 >
451 451
                     <span class="dashicons dashicons-chart-bar"></span>
452 452
                 </a>';
453
-        }
454
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
455
-            EE_Registry::instance()->load_helper('MSG_Template');
456
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
457
-                'see_notifications_for',
458
-                null,
459
-                ['EVT_ID' => $event->ID()]
460
-            );
461
-        }
462
-        return $action_links;
463
-    }
464
-
465
-
466
-    /**
467
-     * @param $items
468
-     * @return mixed
469
-     */
470
-    public function additional_legend_items($items)
471
-    {
472
-        if (
473
-            EE_Registry::instance()->CAP->current_user_can(
474
-                'ee_read_registrations',
475
-                'espresso_registrations_reports'
476
-            )
477
-        ) {
478
-            $items['reports'] = [
479
-                'class' => 'dashicons dashicons-chart-bar',
480
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
481
-            ];
482
-        }
483
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
484
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
485
-            // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
486
-            // (can only use numeric offsets when treating strings as arrays)
487
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
488
-                $items['view_related_messages'] = [
489
-                    'class' => $related_for_icon['css_class'],
490
-                    'desc'  => $related_for_icon['label'],
491
-                ];
492
-            }
493
-        }
494
-        return $items;
495
-    }
496
-
497
-
498
-    /**
499
-     * This is the callback method for the duplicate event route
500
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
501
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
502
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
503
-     * After duplication the redirect is to the new event edit page.
504
-     *
505
-     * @return void
506
-     * @throws EE_Error If EE_Event is not available with given ID
507
-     * @throws ReflectionException
508
-     * @access protected
509
-     */
510
-    protected function _duplicate_event()
511
-    {
512
-        // first make sure the ID for the event is in the request.
513
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
514
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
515
-        if (! $EVT_ID) {
516
-            EE_Error::add_error(
517
-                esc_html__(
518
-                    'In order to duplicate an event an Event ID is required.  None was given.',
519
-                    'event_espresso'
520
-                ),
521
-                __FILE__,
522
-                __FUNCTION__,
523
-                __LINE__
524
-            );
525
-            $this->_redirect_after_action(false, '', '', [], true);
526
-            return;
527
-        }
528
-        // k we've got EVT_ID so let's use that to get the event we'll duplicate
529
-        $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
530
-        if (! $orig_event instanceof EE_Event) {
531
-            throw new EE_Error(
532
-                sprintf(
533
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
534
-                    $EVT_ID
535
-                )
536
-            );
537
-        }
538
-        // k now let's clone the $orig_event before getting relations
539
-        $new_event = clone $orig_event;
540
-        // original datetimes
541
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
542
-        // other original relations
543
-        $orig_ven = $orig_event->get_many_related('Venue');
544
-        // reset the ID and modify other details to make it clear this is a dupe
545
-        $new_event->set('EVT_ID', 0);
546
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
547
-        $new_event->set('EVT_name', $new_name);
548
-        $new_event->set(
549
-            'EVT_slug',
550
-            wp_unique_post_slug(
551
-                sanitize_title($orig_event->name()),
552
-                0,
553
-                'publish',
554
-                'espresso_events',
555
-                0
556
-            )
557
-        );
558
-        $new_event->set('status', 'draft');
559
-        // duplicate discussion settings
560
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
561
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
562
-        // save the new event
563
-        $new_event->save();
564
-        // venues
565
-        foreach ($orig_ven as $ven) {
566
-            $new_event->_add_relation_to($ven, 'Venue');
567
-        }
568
-        $new_event->save();
569
-        // now we need to get the question group relations and handle that
570
-        // first primary question groups
571
-        $orig_primary_qgs = $orig_event->get_many_related(
572
-            'Question_Group',
573
-            [['Event_Question_Group.EQG_primary' => true]]
574
-        );
575
-        if (! empty($orig_primary_qgs)) {
576
-            foreach ($orig_primary_qgs as $obj) {
577
-                if ($obj instanceof EE_Question_Group) {
578
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
579
-                }
580
-            }
581
-        }
582
-        // next additional attendee question groups
583
-        $orig_additional_qgs = $orig_event->get_many_related(
584
-            'Question_Group',
585
-            [['Event_Question_Group.EQG_additional' => true]]
586
-        );
587
-        if (! empty($orig_additional_qgs)) {
588
-            foreach ($orig_additional_qgs as $obj) {
589
-                if ($obj instanceof EE_Question_Group) {
590
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
591
-                }
592
-            }
593
-        }
594
-
595
-        $new_event->save();
596
-
597
-        // k now that we have the new event saved we can loop through the datetimes and start adding relations.
598
-        $cloned_tickets = [];
599
-        foreach ($orig_datetimes as $orig_dtt) {
600
-            if (! $orig_dtt instanceof EE_Datetime) {
601
-                continue;
602
-            }
603
-            $new_dtt      = clone $orig_dtt;
604
-            $orig_tickets = $orig_dtt->tickets();
605
-            // save new dtt then add to event
606
-            $new_dtt->set('DTT_ID', 0);
607
-            $new_dtt->set('DTT_sold', 0);
608
-            $new_dtt->set_reserved(0);
609
-            $new_dtt->save();
610
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
611
-            $new_event->save();
612
-            // now let's get the ticket relations setup.
613
-            foreach ((array) $orig_tickets as $orig_ticket) {
614
-                // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
615
-                if (! $orig_ticket instanceof EE_Ticket) {
616
-                    continue;
617
-                }
618
-                // is this ticket archived?  If it is then let's skip
619
-                if ($orig_ticket->get('TKT_deleted')) {
620
-                    continue;
621
-                }
622
-                // does this original ticket already exist in the clone_tickets cache?
623
-                //  If so we'll just use the new ticket from it.
624
-                if (isset($cloned_tickets[ $orig_ticket->ID() ])) {
625
-                    $new_ticket = $cloned_tickets[ $orig_ticket->ID() ];
626
-                } else {
627
-                    $new_ticket = clone $orig_ticket;
628
-                    // get relations on the $orig_ticket that we need to setup.
629
-                    $orig_prices = $orig_ticket->prices();
630
-                    $new_ticket->set('TKT_ID', 0);
631
-                    $new_ticket->set('TKT_sold', 0);
632
-                    $new_ticket->set('TKT_reserved', 0);
633
-                    $new_ticket->save(); // make sure new ticket has ID.
634
-                    // price relations on new ticket need to be setup.
635
-                    foreach ($orig_prices as $orig_price) {
636
-                        $new_price = clone $orig_price;
637
-                        $new_price->set('PRC_ID', 0);
638
-                        $new_price->save();
639
-                        $new_ticket->_add_relation_to($new_price, 'Price');
640
-                        $new_ticket->save();
641
-                    }
642
-
643
-                    do_action(
644
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
645
-                        $orig_ticket,
646
-                        $new_ticket,
647
-                        $orig_prices,
648
-                        $orig_event,
649
-                        $orig_dtt,
650
-                        $new_dtt
651
-                    );
652
-                }
653
-                // k now we can add the new ticket as a relation to the new datetime
654
-                // and make sure its added to our cached $cloned_tickets array
655
-                // for use with later datetimes that have the same ticket.
656
-                $new_dtt->_add_relation_to($new_ticket, 'Ticket');
657
-                $new_dtt->save();
658
-                $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket;
659
-            }
660
-        }
661
-        // clone taxonomy information
662
-        $taxonomies_to_clone_with = apply_filters(
663
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
664
-            ['espresso_event_categories', 'espresso_event_type', 'post_tag']
665
-        );
666
-        // get terms for original event (notice)
667
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
668
-        // loop through terms and add them to new event.
669
-        foreach ($orig_terms as $term) {
670
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
671
-        }
672
-
673
-        // duplicate other core WP_Post items for this event.
674
-        // post thumbnail (feature image).
675
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
676
-        if ($feature_image_id) {
677
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
678
-        }
679
-
680
-        // duplicate page_template setting
681
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
682
-        if ($page_template) {
683
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
684
-        }
685
-
686
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
687
-        // now let's redirect to the edit page for this duplicated event if we have a new event id.
688
-        if ($new_event->ID()) {
689
-            $redirect_args = [
690
-                'post'   => $new_event->ID(),
691
-                'action' => 'edit',
692
-            ];
693
-            EE_Error::add_success(
694
-                esc_html__(
695
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
696
-                    'event_espresso'
697
-                )
698
-            );
699
-        } else {
700
-            $redirect_args = [
701
-                'action' => 'default',
702
-            ];
703
-            EE_Error::add_error(
704
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
705
-                __FILE__,
706
-                __FUNCTION__,
707
-                __LINE__
708
-            );
709
-        }
710
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
711
-    }
712
-
713
-
714
-    /**
715
-     * Generates output for the import page.
716
-     *
717
-     * @throws EE_Error
718
-     */
719
-    protected function _import_page()
720
-    {
721
-        $title                                      = esc_html__('Import', 'event_espresso');
722
-        $intro                                      = esc_html__(
723
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
724
-            'event_espresso'
725
-        );
726
-
727
-        $form_url = EVENTS_ADMIN_URL;
728
-        $action   = 'import_events';
729
-        $type     = 'csv';
730
-
731
-        $this->_template_args['form'] = EE_Import::instance()->upload_form(
732
-            $title,
733
-            $intro,
734
-            $form_url,
735
-            $action,
736
-            $type
737
-        );
738
-
739
-        $this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
740
-            ['action' => 'sample_export_file'],
741
-            $this->_admin_base_url
742
-        );
743
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
744
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
745
-            $this->_template_args,
746
-            true
747
-        );
748
-        $this->display_admin_page_with_sidebar();
749
-    }
750
-
751
-
752
-    /**
753
-     * _import_events
754
-     * This handles displaying the screen and running imports for importing events.
755
-     *
756
-     * @return void
757
-     * @throws EE_Error
758
-     */
759
-    protected function _import_events()
760
-    {
761
-        require_once(EE_CLASSES . 'EE_Import.class.php');
762
-        $success = EE_Import::instance()->import();
763
-        $this->_redirect_after_action(
764
-            $success,
765
-            esc_html__('Import File', 'event_espresso'),
766
-            'ran',
767
-            ['action' => 'import_page'],
768
-            true
769
-        );
770
-    }
771
-
772
-
773
-    /**
774
-     * _events_export
775
-     * Will export all (or just the given event) to a Excel compatible file.
776
-     *
777
-     * @access protected
778
-     * @return void
779
-     */
780
-    protected function _events_export()
781
-    {
782
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
783
-        $EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int');
784
-        $this->request->mergeRequestParams(
785
-            [
786
-                'export' => 'report',
787
-                'action' => 'all_event_data',
788
-                'EVT_ID' => $EVT_ID,
789
-            ]
790
-        );
791
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
792
-            require_once(EE_CLASSES . 'EE_Export.class.php');
793
-            $EE_Export = EE_Export::instance($this->request->requestParams());
794
-            $EE_Export->export();
795
-        }
796
-    }
797
-
798
-
799
-    /**
800
-     * handle category exports()
801
-     *
802
-     * @return void
803
-     */
804
-    protected function _categories_export()
805
-    {
806
-        $EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
807
-        $this->request->mergeRequestParams(
808
-            [
809
-                'export' => 'report',
810
-                'action' => 'categories',
811
-                'EVT_ID' => $EVT_ID,
812
-            ]
813
-        );
814
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
815
-            require_once(EE_CLASSES . 'EE_Export.class.php');
816
-            $EE_Export = EE_Export::instance($this->request->requestParams());
817
-            $EE_Export->export();
818
-        }
819
-    }
820
-
821
-
822
-    /**
823
-     * Creates a sample CSV file for importing
824
-     */
825
-    protected function _sample_export_file()
826
-    {
827
-        $EE_Export = EE_Export::instance();
828
-        if ($EE_Export instanceof EE_Export) {
829
-            $EE_Export->export();
830
-        }
831
-    }
832
-
833
-
834
-    /*************        Template Settings        *************/
835
-    /**
836
-     * Generates template settings page output
837
-     *
838
-     * @throws DomainException
839
-     * @throws EE_Error
840
-     * @throws InvalidArgumentException
841
-     * @throws InvalidDataTypeException
842
-     * @throws InvalidInterfaceException
843
-     */
844
-    protected function _template_settings()
845
-    {
846
-        $this->_template_args['values'] = $this->_yes_no_values;
847
-        /**
848
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
849
-         * from General_Settings_Admin_Page to here.
850
-         */
851
-        $this->_template_args = apply_filters(
852
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
853
-            $this->_template_args
854
-        );
855
-        $this->_set_add_edit_form_tags('update_template_settings');
856
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
857
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
858
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
859
-            $this->_template_args,
860
-            true
861
-        );
862
-        $this->display_admin_page_with_sidebar();
863
-    }
864
-
865
-
866
-    /**
867
-     * Handler for updating template settings.
868
-     *
869
-     * @throws EE_Error
870
-     */
871
-    protected function _update_template_settings()
872
-    {
873
-        /**
874
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
875
-         * from General_Settings_Admin_Page to here.
876
-         */
877
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
878
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
879
-            EE_Registry::instance()->CFG->template_settings,
880
-            $this->request->requestParams()
881
-        );
882
-        // update custom post type slugs and detect if we need to flush rewrite rules
883
-        $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
884
-
885
-        $event_cpt_slug = $this->request->getRequestParam('event_cpt_slug');
886
-
887
-        EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug
888
-            ? EEH_URL::slugify($event_cpt_slug, 'events')
889
-            : EE_Registry::instance()->CFG->core->event_cpt_slug;
890
-
891
-        $what    = esc_html__('Template Settings', 'event_espresso');
892
-        $success = $this->_update_espresso_configuration(
893
-            $what,
894
-            EE_Registry::instance()->CFG->template_settings,
895
-            __FILE__,
896
-            __FUNCTION__,
897
-            __LINE__
898
-        );
899
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
900
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
901
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
902
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
903
-            );
904
-            $rewrite_rules->flush();
905
-        }
906
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
907
-    }
908
-
909
-
910
-    /**
911
-     * _premium_event_editor_meta_boxes
912
-     * add all metaboxes related to the event_editor
913
-     *
914
-     * @access protected
915
-     * @return void
916
-     * @throws EE_Error
917
-     * @throws ReflectionException
918
-     */
919
-    protected function _premium_event_editor_meta_boxes()
920
-    {
921
-        $this->verify_cpt_object();
922
-        // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
923
-        if (
924
-            ! $this->admin_config->useAdvancedEditor()
925
-            || ! $this->feature->allowed('use_reg_options_meta_box')
926
-        ) {
927
-            $this->addMetaBox(
928
-                'espresso_event_editor_event_options',
929
-                esc_html__('Event Registration Options', 'event_espresso'),
930
-                [$this, 'registration_options_meta_box'],
931
-                $this->page_slug,
932
-                'side',
933
-                'core'
934
-            );
935
-        }
936
-    }
937
-
938
-
939
-    /**
940
-     * override caf metabox
941
-     *
942
-     * @return void
943
-     * @throws EE_Error
944
-     * @throws ReflectionException
945
-     */
946
-    public function registration_options_meta_box()
947
-    {
948
-        $yes_no_values = [
949
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
950
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
951
-        ];
952
-
953
-        $default_reg_status_values = EEM_Registration::reg_status_array(
954
-            [
955
-                EEM_Registration::status_id_cancelled,
956
-                EEM_Registration::status_id_declined,
957
-                EEM_Registration::status_id_incomplete,
958
-                EEM_Registration::status_id_wait_list,
959
-            ],
960
-            true
961
-        );
962
-
963
-        $template_args['active_status']    = $this->_cpt_model_obj->pretty_active_status(false);
964
-        $template_args['_event']           = $this->_cpt_model_obj;
965
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
966
-
967
-        $template_args['default_registration_status']     = EEH_Form_Fields::select_input(
968
-            'default_reg_status',
969
-            $default_reg_status_values,
970
-            $this->_cpt_model_obj->default_registration_status()
971
-        );
972
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
973
-            'display_desc',
974
-            $yes_no_values,
975
-            $this->_cpt_model_obj->display_description()
976
-        );
977
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
978
-            'display_ticket_selector',
979
-            $yes_no_values,
980
-            $this->_cpt_model_obj->display_ticket_selector(),
981
-            '',
982
-            '',
983
-            false
984
-        );
985
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
986
-            'EVT_default_registration_status',
987
-            $default_reg_status_values,
988
-            $this->_cpt_model_obj->default_registration_status()
989
-        );
990
-        $template_args['additional_registration_options'] = apply_filters(
991
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
992
-            '',
993
-            $template_args,
994
-            $yes_no_values,
995
-            $default_reg_status_values
996
-        );
997
-        EEH_Template::display_template(
998
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
999
-            $template_args
1000
-        );
1001
-    }
1002
-
1003
-
1004
-
1005
-    /**
1006
-     * wp_list_table_mods for caf
1007
-     * ============================
1008
-     */
1009
-    /**
1010
-     * hook into list table filters and provide filters for caffeinated list table
1011
-     *
1012
-     * @param array $old_filters    any existing filters present
1013
-     * @param array $list_table_obj the list table object
1014
-     * @return array                  new filters
1015
-     * @throws EE_Error
1016
-     * @throws ReflectionException
1017
-     */
1018
-    public function list_table_filters($old_filters, $list_table_obj)
1019
-    {
1020
-        $filters = [];
1021
-        // first month/year filters
1022
-        $filters[] = $this->espresso_event_months_dropdown();
1023
-        $status    = $this->request->getRequestParam('status');
1024
-        // active status dropdown
1025
-        if ($status !== 'draft') {
1026
-            $filters[] = $this->active_status_dropdown($this->request->getRequestParam('active_status'));
1027
-            $filters[] = $this->venuesDropdown($this->request->getRequestParam('venue'));
1028
-        }
1029
-        // category filter
1030
-        $filters[] = $this->category_dropdown();
1031
-        return array_merge($old_filters, $filters);
1032
-    }
1033
-
1034
-
1035
-    /**
1036
-     * espresso_event_months_dropdown
1037
-     *
1038
-     * @access public
1039
-     * @return string                dropdown listing month/year selections for events.
1040
-     * @throws EE_Error
1041
-     */
1042
-    public function espresso_event_months_dropdown()
1043
-    {
1044
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
1045
-        // Note we need to include any other filters that are set!
1046
-        return EEH_Form_Fields::generate_event_months_dropdown(
1047
-            $this->request->getRequestParam('month_range'),
1048
-            $this->request->getRequestParam('status'),
1049
-            $this->request->getRequestParam('EVT_CAT', 0, 'int'),
1050
-            $this->request->getRequestParam('active_status')
1051
-        );
1052
-    }
1053
-
1054
-
1055
-    /**
1056
-     * returns a list of "active" statuses on the event
1057
-     *
1058
-     * @param string $current_value whatever the current active status is
1059
-     * @return string
1060
-     */
1061
-    public function active_status_dropdown($current_value = '')
1062
-    {
1063
-        $select_name = 'active_status';
1064
-        $values      = [
1065
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1066
-            'active'   => esc_html__('Active', 'event_espresso'),
1067
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1068
-            'expired'  => esc_html__('Expired', 'event_espresso'),
1069
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
1070
-        ];
1071
-
1072
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value);
1073
-    }
1074
-
1075
-
1076
-    /**
1077
-     * returns a list of "venues"
1078
-     *
1079
-     * @param string $current_value whatever the current active status is
1080
-     * @return string
1081
-     * @throws EE_Error
1082
-     * @throws ReflectionException
1083
-     */
1084
-    protected function venuesDropdown($current_value = '')
1085
-    {
1086
-        $values = ['' => esc_html__('All Venues', 'event_espresso')];
1087
-        // populate the list of venues.
1088
-        $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1089
-
1090
-        foreach ($venues as $venue) {
1091
-            $values[ $venue->ID() ] = $venue->name();
1092
-        }
1093
-
1094
-        return EEH_Form_Fields::select_input('venue', $values, $current_value);
1095
-    }
1096
-
1097
-
1098
-    /**
1099
-     * output a dropdown of the categories for the category filter on the event admin list table
1100
-     *
1101
-     * @access  public
1102
-     * @return string html
1103
-     * @throws EE_Error
1104
-     * @throws ReflectionException
1105
-     */
1106
-    public function category_dropdown()
1107
-    {
1108
-        return EEH_Form_Fields::generate_event_category_dropdown(
1109
-            $this->request->getRequestParam('EVT_CAT', -1, 'int')
1110
-        );
1111
-    }
1112
-
1113
-
1114
-    /**
1115
-     * get total number of events today
1116
-     *
1117
-     * @access public
1118
-     * @return int
1119
-     * @throws EE_Error
1120
-     * @throws InvalidArgumentException
1121
-     * @throws InvalidDataTypeException
1122
-     * @throws InvalidInterfaceException
1123
-     */
1124
-    public function total_events_today()
1125
-    {
1126
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1127
-            'DTT_EVT_start',
1128
-            date('Y-m-d') . ' 00:00:00',
1129
-            'Y-m-d H:i:s',
1130
-            'UTC'
1131
-        );
1132
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1133
-            'DTT_EVT_start',
1134
-            date('Y-m-d') . ' 23:59:59',
1135
-            'Y-m-d H:i:s',
1136
-            'UTC'
1137
-        );
1138
-        $where = [
1139
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1140
-        ];
1141
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1142
-    }
1143
-
1144
-
1145
-    /**
1146
-     * get total number of events this month
1147
-     *
1148
-     * @access public
1149
-     * @return int
1150
-     * @throws EE_Error
1151
-     * @throws InvalidArgumentException
1152
-     * @throws InvalidDataTypeException
1153
-     * @throws InvalidInterfaceException
1154
-     */
1155
-    public function total_events_this_month()
1156
-    {
1157
-        // Dates
1158
-        $this_year_r     = date('Y');
1159
-        $this_month_r    = date('m');
1160
-        $days_this_month = date('t');
1161
-        $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1162
-            'DTT_EVT_start',
1163
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1164
-            'Y-m-d H:i:s',
1165
-            'UTC'
1166
-        );
1167
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1168
-            'DTT_EVT_start',
1169
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1170
-            'Y-m-d H:i:s',
1171
-            'UTC'
1172
-        );
1173
-        $where           = [
1174
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1175
-        ];
1176
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1177
-    }
1178
-
1179
-
1180
-    /** DEFAULT TICKETS STUFF **/
1181
-
1182
-    /**
1183
-     * Output default tickets list table view.
1184
-     *
1185
-     * @throws EE_Error
1186
-     */
1187
-    public function _tickets_overview_list_table()
1188
-    {
1189
-        if (
1190
-            $this->admin_config->useAdvancedEditor()
1191
-            && $this->feature->allowed('use_default_ticket_manager')
1192
-        ) {
1193
-            // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
1194
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1195
-                EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php',
1196
-                [],
1197
-                true
1198
-            );
1199
-            $this->display_admin_page_with_no_sidebar();
1200
-        } else {
1201
-            $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1202
-            $this->display_admin_list_table_page_with_no_sidebar();
1203
-        }
1204
-    }
1205
-
1206
-
1207
-    /**
1208
-     * @param int  $per_page
1209
-     * @param bool $count
1210
-     * @param bool $trashed
1211
-     * @return EE_Soft_Delete_Base_Class[]|int
1212
-     * @throws EE_Error
1213
-     */
1214
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1215
-    {
1216
-        $orderby = $this->request->getRequestParam('orderby', 'TKT_name');
1217
-        $order   = $this->request->getRequestParam('order', 'ASC');
1218
-        switch ($orderby) {
1219
-            case 'TKT_name':
1220
-                $orderby = ['TKT_name' => $order];
1221
-                break;
1222
-            case 'TKT_price':
1223
-                $orderby = ['TKT_price' => $order];
1224
-                break;
1225
-            case 'TKT_uses':
1226
-                $orderby = ['TKT_uses' => $order];
1227
-                break;
1228
-            case 'TKT_min':
1229
-                $orderby = ['TKT_min' => $order];
1230
-                break;
1231
-            case 'TKT_max':
1232
-                $orderby = ['TKT_max' => $order];
1233
-                break;
1234
-            case 'TKT_qty':
1235
-                $orderby = ['TKT_qty' => $order];
1236
-                break;
1237
-        }
1238
-
1239
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
1240
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1241
-        $offset       = ($current_page - 1) * $per_page;
1242
-
1243
-        $where = [
1244
-            'TKT_is_default' => 1,
1245
-            'TKT_deleted'    => $trashed,
1246
-        ];
1247
-
1248
-        $search_term = $this->request->getRequestParam('s');
1249
-        if ($search_term) {
1250
-            $search_term = '%' . $search_term . '%';
1251
-            $where['OR'] = [
1252
-                'TKT_name'        => ['LIKE', $search_term],
1253
-                'TKT_description' => ['LIKE', $search_term],
1254
-            ];
1255
-        }
1256
-
1257
-        return $count
1258
-            ? EEM_Ticket::instance()->count_deleted_and_undeleted([$where])
1259
-            : EEM_Ticket::instance()->get_all_deleted_and_undeleted(
1260
-                [
1261
-                    $where,
1262
-                    'order_by' => $orderby,
1263
-                    'limit'    => [$offset, $per_page],
1264
-                    'group_by' => 'TKT_ID',
1265
-                ]
1266
-            );
1267
-    }
1268
-
1269
-
1270
-    /**
1271
-     * @param bool $trash
1272
-     * @throws EE_Error
1273
-     * @throws InvalidArgumentException
1274
-     * @throws InvalidDataTypeException
1275
-     * @throws InvalidInterfaceException
1276
-     */
1277
-    protected function _trash_or_restore_ticket($trash = false)
1278
-    {
1279
-        $success = 1;
1280
-        $TKT     = EEM_Ticket::instance();
1281
-        // checkboxes?
1282
-        $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1283
-        if (! empty($checkboxes)) {
1284
-            // if array has more than one element then success message should be plural
1285
-            $success = count($checkboxes) > 1 ? 2 : 1;
1286
-            // cycle thru the boxes
1287
-            while (list($TKT_ID, $value) = each($checkboxes)) {
1288
-                if ($trash) {
1289
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1290
-                        $success = 0;
1291
-                    }
1292
-                } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1293
-                    $success = 0;
1294
-                }
1295
-            }
1296
-        } else {
1297
-            // grab single id and trash
1298
-            $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1299
-            if ($trash) {
1300
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1301
-                    $success = 0;
1302
-                }
1303
-            } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1304
-                $success = 0;
1305
-            }
1306
-        }
1307
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1308
-        $query_args  = [
1309
-            'action' => 'ticket_list_table',
1310
-            'status' => $trash ? '' : 'trashed',
1311
-        ];
1312
-        $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1313
-    }
1314
-
1315
-
1316
-    /**
1317
-     * Handles trashing default ticket.
1318
-     *
1319
-     * @throws EE_Error
1320
-     * @throws ReflectionException
1321
-     */
1322
-    protected function _delete_ticket()
1323
-    {
1324
-        $success = 1;
1325
-        // checkboxes?
1326
-        $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1327
-        if (! empty($checkboxes)) {
1328
-            // if array has more than one element then success message should be plural
1329
-            $success = count($checkboxes) > 1 ? 2 : 1;
1330
-            // cycle thru the boxes
1331
-            while (list($TKT_ID, $value) = each($checkboxes)) {
1332
-                // delete
1333
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1334
-                    $success = 0;
1335
-                }
1336
-            }
1337
-        } else {
1338
-            // grab single id and trash
1339
-            $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1340
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1341
-                $success = 0;
1342
-            }
1343
-        }
1344
-        $action_desc = 'deleted';
1345
-        $query_args  = [
1346
-            'action' => 'ticket_list_table',
1347
-            'status' => 'trashed',
1348
-        ];
1349
-        // fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1350
-        if (
1351
-            EEM_Ticket::instance()->count_deleted_and_undeleted(
1352
-                [['TKT_is_default' => 1]],
1353
-                'TKT_ID',
1354
-                true
1355
-            )
1356
-        ) {
1357
-            $query_args = [];
1358
-        }
1359
-        $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1360
-    }
1361
-
1362
-
1363
-    /**
1364
-     * @param int $TKT_ID
1365
-     * @return bool|int
1366
-     * @throws EE_Error
1367
-     * @throws ReflectionException
1368
-     */
1369
-    protected function _delete_the_ticket($TKT_ID)
1370
-    {
1371
-        $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1372
-        if (! $ticket instanceof EE_Ticket) {
1373
-            return false;
1374
-        }
1375
-        $ticket->_remove_relations('Datetime');
1376
-        // delete all related prices first
1377
-        $ticket->delete_related_permanently('Price');
1378
-        return $ticket->delete_permanently();
1379
-    }
453
+		}
454
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
455
+			EE_Registry::instance()->load_helper('MSG_Template');
456
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
457
+				'see_notifications_for',
458
+				null,
459
+				['EVT_ID' => $event->ID()]
460
+			);
461
+		}
462
+		return $action_links;
463
+	}
464
+
465
+
466
+	/**
467
+	 * @param $items
468
+	 * @return mixed
469
+	 */
470
+	public function additional_legend_items($items)
471
+	{
472
+		if (
473
+			EE_Registry::instance()->CAP->current_user_can(
474
+				'ee_read_registrations',
475
+				'espresso_registrations_reports'
476
+			)
477
+		) {
478
+			$items['reports'] = [
479
+				'class' => 'dashicons dashicons-chart-bar',
480
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
481
+			];
482
+		}
483
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
484
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
485
+			// $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
486
+			// (can only use numeric offsets when treating strings as arrays)
487
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
488
+				$items['view_related_messages'] = [
489
+					'class' => $related_for_icon['css_class'],
490
+					'desc'  => $related_for_icon['label'],
491
+				];
492
+			}
493
+		}
494
+		return $items;
495
+	}
496
+
497
+
498
+	/**
499
+	 * This is the callback method for the duplicate event route
500
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
501
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
502
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
503
+	 * After duplication the redirect is to the new event edit page.
504
+	 *
505
+	 * @return void
506
+	 * @throws EE_Error If EE_Event is not available with given ID
507
+	 * @throws ReflectionException
508
+	 * @access protected
509
+	 */
510
+	protected function _duplicate_event()
511
+	{
512
+		// first make sure the ID for the event is in the request.
513
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
514
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
515
+		if (! $EVT_ID) {
516
+			EE_Error::add_error(
517
+				esc_html__(
518
+					'In order to duplicate an event an Event ID is required.  None was given.',
519
+					'event_espresso'
520
+				),
521
+				__FILE__,
522
+				__FUNCTION__,
523
+				__LINE__
524
+			);
525
+			$this->_redirect_after_action(false, '', '', [], true);
526
+			return;
527
+		}
528
+		// k we've got EVT_ID so let's use that to get the event we'll duplicate
529
+		$orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
530
+		if (! $orig_event instanceof EE_Event) {
531
+			throw new EE_Error(
532
+				sprintf(
533
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
534
+					$EVT_ID
535
+				)
536
+			);
537
+		}
538
+		// k now let's clone the $orig_event before getting relations
539
+		$new_event = clone $orig_event;
540
+		// original datetimes
541
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
542
+		// other original relations
543
+		$orig_ven = $orig_event->get_many_related('Venue');
544
+		// reset the ID and modify other details to make it clear this is a dupe
545
+		$new_event->set('EVT_ID', 0);
546
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
547
+		$new_event->set('EVT_name', $new_name);
548
+		$new_event->set(
549
+			'EVT_slug',
550
+			wp_unique_post_slug(
551
+				sanitize_title($orig_event->name()),
552
+				0,
553
+				'publish',
554
+				'espresso_events',
555
+				0
556
+			)
557
+		);
558
+		$new_event->set('status', 'draft');
559
+		// duplicate discussion settings
560
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
561
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
562
+		// save the new event
563
+		$new_event->save();
564
+		// venues
565
+		foreach ($orig_ven as $ven) {
566
+			$new_event->_add_relation_to($ven, 'Venue');
567
+		}
568
+		$new_event->save();
569
+		// now we need to get the question group relations and handle that
570
+		// first primary question groups
571
+		$orig_primary_qgs = $orig_event->get_many_related(
572
+			'Question_Group',
573
+			[['Event_Question_Group.EQG_primary' => true]]
574
+		);
575
+		if (! empty($orig_primary_qgs)) {
576
+			foreach ($orig_primary_qgs as $obj) {
577
+				if ($obj instanceof EE_Question_Group) {
578
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
579
+				}
580
+			}
581
+		}
582
+		// next additional attendee question groups
583
+		$orig_additional_qgs = $orig_event->get_many_related(
584
+			'Question_Group',
585
+			[['Event_Question_Group.EQG_additional' => true]]
586
+		);
587
+		if (! empty($orig_additional_qgs)) {
588
+			foreach ($orig_additional_qgs as $obj) {
589
+				if ($obj instanceof EE_Question_Group) {
590
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
591
+				}
592
+			}
593
+		}
594
+
595
+		$new_event->save();
596
+
597
+		// k now that we have the new event saved we can loop through the datetimes and start adding relations.
598
+		$cloned_tickets = [];
599
+		foreach ($orig_datetimes as $orig_dtt) {
600
+			if (! $orig_dtt instanceof EE_Datetime) {
601
+				continue;
602
+			}
603
+			$new_dtt      = clone $orig_dtt;
604
+			$orig_tickets = $orig_dtt->tickets();
605
+			// save new dtt then add to event
606
+			$new_dtt->set('DTT_ID', 0);
607
+			$new_dtt->set('DTT_sold', 0);
608
+			$new_dtt->set_reserved(0);
609
+			$new_dtt->save();
610
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
611
+			$new_event->save();
612
+			// now let's get the ticket relations setup.
613
+			foreach ((array) $orig_tickets as $orig_ticket) {
614
+				// it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
615
+				if (! $orig_ticket instanceof EE_Ticket) {
616
+					continue;
617
+				}
618
+				// is this ticket archived?  If it is then let's skip
619
+				if ($orig_ticket->get('TKT_deleted')) {
620
+					continue;
621
+				}
622
+				// does this original ticket already exist in the clone_tickets cache?
623
+				//  If so we'll just use the new ticket from it.
624
+				if (isset($cloned_tickets[ $orig_ticket->ID() ])) {
625
+					$new_ticket = $cloned_tickets[ $orig_ticket->ID() ];
626
+				} else {
627
+					$new_ticket = clone $orig_ticket;
628
+					// get relations on the $orig_ticket that we need to setup.
629
+					$orig_prices = $orig_ticket->prices();
630
+					$new_ticket->set('TKT_ID', 0);
631
+					$new_ticket->set('TKT_sold', 0);
632
+					$new_ticket->set('TKT_reserved', 0);
633
+					$new_ticket->save(); // make sure new ticket has ID.
634
+					// price relations on new ticket need to be setup.
635
+					foreach ($orig_prices as $orig_price) {
636
+						$new_price = clone $orig_price;
637
+						$new_price->set('PRC_ID', 0);
638
+						$new_price->save();
639
+						$new_ticket->_add_relation_to($new_price, 'Price');
640
+						$new_ticket->save();
641
+					}
642
+
643
+					do_action(
644
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
645
+						$orig_ticket,
646
+						$new_ticket,
647
+						$orig_prices,
648
+						$orig_event,
649
+						$orig_dtt,
650
+						$new_dtt
651
+					);
652
+				}
653
+				// k now we can add the new ticket as a relation to the new datetime
654
+				// and make sure its added to our cached $cloned_tickets array
655
+				// for use with later datetimes that have the same ticket.
656
+				$new_dtt->_add_relation_to($new_ticket, 'Ticket');
657
+				$new_dtt->save();
658
+				$cloned_tickets[ $orig_ticket->ID() ] = $new_ticket;
659
+			}
660
+		}
661
+		// clone taxonomy information
662
+		$taxonomies_to_clone_with = apply_filters(
663
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
664
+			['espresso_event_categories', 'espresso_event_type', 'post_tag']
665
+		);
666
+		// get terms for original event (notice)
667
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
668
+		// loop through terms and add them to new event.
669
+		foreach ($orig_terms as $term) {
670
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
671
+		}
672
+
673
+		// duplicate other core WP_Post items for this event.
674
+		// post thumbnail (feature image).
675
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
676
+		if ($feature_image_id) {
677
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
678
+		}
679
+
680
+		// duplicate page_template setting
681
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
682
+		if ($page_template) {
683
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
684
+		}
685
+
686
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
687
+		// now let's redirect to the edit page for this duplicated event if we have a new event id.
688
+		if ($new_event->ID()) {
689
+			$redirect_args = [
690
+				'post'   => $new_event->ID(),
691
+				'action' => 'edit',
692
+			];
693
+			EE_Error::add_success(
694
+				esc_html__(
695
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
696
+					'event_espresso'
697
+				)
698
+			);
699
+		} else {
700
+			$redirect_args = [
701
+				'action' => 'default',
702
+			];
703
+			EE_Error::add_error(
704
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
705
+				__FILE__,
706
+				__FUNCTION__,
707
+				__LINE__
708
+			);
709
+		}
710
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
711
+	}
712
+
713
+
714
+	/**
715
+	 * Generates output for the import page.
716
+	 *
717
+	 * @throws EE_Error
718
+	 */
719
+	protected function _import_page()
720
+	{
721
+		$title                                      = esc_html__('Import', 'event_espresso');
722
+		$intro                                      = esc_html__(
723
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
724
+			'event_espresso'
725
+		);
726
+
727
+		$form_url = EVENTS_ADMIN_URL;
728
+		$action   = 'import_events';
729
+		$type     = 'csv';
730
+
731
+		$this->_template_args['form'] = EE_Import::instance()->upload_form(
732
+			$title,
733
+			$intro,
734
+			$form_url,
735
+			$action,
736
+			$type
737
+		);
738
+
739
+		$this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
740
+			['action' => 'sample_export_file'],
741
+			$this->_admin_base_url
742
+		);
743
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
744
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
745
+			$this->_template_args,
746
+			true
747
+		);
748
+		$this->display_admin_page_with_sidebar();
749
+	}
750
+
751
+
752
+	/**
753
+	 * _import_events
754
+	 * This handles displaying the screen and running imports for importing events.
755
+	 *
756
+	 * @return void
757
+	 * @throws EE_Error
758
+	 */
759
+	protected function _import_events()
760
+	{
761
+		require_once(EE_CLASSES . 'EE_Import.class.php');
762
+		$success = EE_Import::instance()->import();
763
+		$this->_redirect_after_action(
764
+			$success,
765
+			esc_html__('Import File', 'event_espresso'),
766
+			'ran',
767
+			['action' => 'import_page'],
768
+			true
769
+		);
770
+	}
771
+
772
+
773
+	/**
774
+	 * _events_export
775
+	 * Will export all (or just the given event) to a Excel compatible file.
776
+	 *
777
+	 * @access protected
778
+	 * @return void
779
+	 */
780
+	protected function _events_export()
781
+	{
782
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
783
+		$EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int');
784
+		$this->request->mergeRequestParams(
785
+			[
786
+				'export' => 'report',
787
+				'action' => 'all_event_data',
788
+				'EVT_ID' => $EVT_ID,
789
+			]
790
+		);
791
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
792
+			require_once(EE_CLASSES . 'EE_Export.class.php');
793
+			$EE_Export = EE_Export::instance($this->request->requestParams());
794
+			$EE_Export->export();
795
+		}
796
+	}
797
+
798
+
799
+	/**
800
+	 * handle category exports()
801
+	 *
802
+	 * @return void
803
+	 */
804
+	protected function _categories_export()
805
+	{
806
+		$EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
807
+		$this->request->mergeRequestParams(
808
+			[
809
+				'export' => 'report',
810
+				'action' => 'categories',
811
+				'EVT_ID' => $EVT_ID,
812
+			]
813
+		);
814
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
815
+			require_once(EE_CLASSES . 'EE_Export.class.php');
816
+			$EE_Export = EE_Export::instance($this->request->requestParams());
817
+			$EE_Export->export();
818
+		}
819
+	}
820
+
821
+
822
+	/**
823
+	 * Creates a sample CSV file for importing
824
+	 */
825
+	protected function _sample_export_file()
826
+	{
827
+		$EE_Export = EE_Export::instance();
828
+		if ($EE_Export instanceof EE_Export) {
829
+			$EE_Export->export();
830
+		}
831
+	}
832
+
833
+
834
+	/*************        Template Settings        *************/
835
+	/**
836
+	 * Generates template settings page output
837
+	 *
838
+	 * @throws DomainException
839
+	 * @throws EE_Error
840
+	 * @throws InvalidArgumentException
841
+	 * @throws InvalidDataTypeException
842
+	 * @throws InvalidInterfaceException
843
+	 */
844
+	protected function _template_settings()
845
+	{
846
+		$this->_template_args['values'] = $this->_yes_no_values;
847
+		/**
848
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
849
+		 * from General_Settings_Admin_Page to here.
850
+		 */
851
+		$this->_template_args = apply_filters(
852
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
853
+			$this->_template_args
854
+		);
855
+		$this->_set_add_edit_form_tags('update_template_settings');
856
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
857
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
858
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
859
+			$this->_template_args,
860
+			true
861
+		);
862
+		$this->display_admin_page_with_sidebar();
863
+	}
864
+
865
+
866
+	/**
867
+	 * Handler for updating template settings.
868
+	 *
869
+	 * @throws EE_Error
870
+	 */
871
+	protected function _update_template_settings()
872
+	{
873
+		/**
874
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
875
+		 * from General_Settings_Admin_Page to here.
876
+		 */
877
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
878
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
879
+			EE_Registry::instance()->CFG->template_settings,
880
+			$this->request->requestParams()
881
+		);
882
+		// update custom post type slugs and detect if we need to flush rewrite rules
883
+		$old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
884
+
885
+		$event_cpt_slug = $this->request->getRequestParam('event_cpt_slug');
886
+
887
+		EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug
888
+			? EEH_URL::slugify($event_cpt_slug, 'events')
889
+			: EE_Registry::instance()->CFG->core->event_cpt_slug;
890
+
891
+		$what    = esc_html__('Template Settings', 'event_espresso');
892
+		$success = $this->_update_espresso_configuration(
893
+			$what,
894
+			EE_Registry::instance()->CFG->template_settings,
895
+			__FILE__,
896
+			__FUNCTION__,
897
+			__LINE__
898
+		);
899
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
900
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
901
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
902
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
903
+			);
904
+			$rewrite_rules->flush();
905
+		}
906
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
907
+	}
908
+
909
+
910
+	/**
911
+	 * _premium_event_editor_meta_boxes
912
+	 * add all metaboxes related to the event_editor
913
+	 *
914
+	 * @access protected
915
+	 * @return void
916
+	 * @throws EE_Error
917
+	 * @throws ReflectionException
918
+	 */
919
+	protected function _premium_event_editor_meta_boxes()
920
+	{
921
+		$this->verify_cpt_object();
922
+		// check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
923
+		if (
924
+			! $this->admin_config->useAdvancedEditor()
925
+			|| ! $this->feature->allowed('use_reg_options_meta_box')
926
+		) {
927
+			$this->addMetaBox(
928
+				'espresso_event_editor_event_options',
929
+				esc_html__('Event Registration Options', 'event_espresso'),
930
+				[$this, 'registration_options_meta_box'],
931
+				$this->page_slug,
932
+				'side',
933
+				'core'
934
+			);
935
+		}
936
+	}
937
+
938
+
939
+	/**
940
+	 * override caf metabox
941
+	 *
942
+	 * @return void
943
+	 * @throws EE_Error
944
+	 * @throws ReflectionException
945
+	 */
946
+	public function registration_options_meta_box()
947
+	{
948
+		$yes_no_values = [
949
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
950
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
951
+		];
952
+
953
+		$default_reg_status_values = EEM_Registration::reg_status_array(
954
+			[
955
+				EEM_Registration::status_id_cancelled,
956
+				EEM_Registration::status_id_declined,
957
+				EEM_Registration::status_id_incomplete,
958
+				EEM_Registration::status_id_wait_list,
959
+			],
960
+			true
961
+		);
962
+
963
+		$template_args['active_status']    = $this->_cpt_model_obj->pretty_active_status(false);
964
+		$template_args['_event']           = $this->_cpt_model_obj;
965
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
966
+
967
+		$template_args['default_registration_status']     = EEH_Form_Fields::select_input(
968
+			'default_reg_status',
969
+			$default_reg_status_values,
970
+			$this->_cpt_model_obj->default_registration_status()
971
+		);
972
+		$template_args['display_description']             = EEH_Form_Fields::select_input(
973
+			'display_desc',
974
+			$yes_no_values,
975
+			$this->_cpt_model_obj->display_description()
976
+		);
977
+		$template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
978
+			'display_ticket_selector',
979
+			$yes_no_values,
980
+			$this->_cpt_model_obj->display_ticket_selector(),
981
+			'',
982
+			'',
983
+			false
984
+		);
985
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
986
+			'EVT_default_registration_status',
987
+			$default_reg_status_values,
988
+			$this->_cpt_model_obj->default_registration_status()
989
+		);
990
+		$template_args['additional_registration_options'] = apply_filters(
991
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
992
+			'',
993
+			$template_args,
994
+			$yes_no_values,
995
+			$default_reg_status_values
996
+		);
997
+		EEH_Template::display_template(
998
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
999
+			$template_args
1000
+		);
1001
+	}
1002
+
1003
+
1004
+
1005
+	/**
1006
+	 * wp_list_table_mods for caf
1007
+	 * ============================
1008
+	 */
1009
+	/**
1010
+	 * hook into list table filters and provide filters for caffeinated list table
1011
+	 *
1012
+	 * @param array $old_filters    any existing filters present
1013
+	 * @param array $list_table_obj the list table object
1014
+	 * @return array                  new filters
1015
+	 * @throws EE_Error
1016
+	 * @throws ReflectionException
1017
+	 */
1018
+	public function list_table_filters($old_filters, $list_table_obj)
1019
+	{
1020
+		$filters = [];
1021
+		// first month/year filters
1022
+		$filters[] = $this->espresso_event_months_dropdown();
1023
+		$status    = $this->request->getRequestParam('status');
1024
+		// active status dropdown
1025
+		if ($status !== 'draft') {
1026
+			$filters[] = $this->active_status_dropdown($this->request->getRequestParam('active_status'));
1027
+			$filters[] = $this->venuesDropdown($this->request->getRequestParam('venue'));
1028
+		}
1029
+		// category filter
1030
+		$filters[] = $this->category_dropdown();
1031
+		return array_merge($old_filters, $filters);
1032
+	}
1033
+
1034
+
1035
+	/**
1036
+	 * espresso_event_months_dropdown
1037
+	 *
1038
+	 * @access public
1039
+	 * @return string                dropdown listing month/year selections for events.
1040
+	 * @throws EE_Error
1041
+	 */
1042
+	public function espresso_event_months_dropdown()
1043
+	{
1044
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
1045
+		// Note we need to include any other filters that are set!
1046
+		return EEH_Form_Fields::generate_event_months_dropdown(
1047
+			$this->request->getRequestParam('month_range'),
1048
+			$this->request->getRequestParam('status'),
1049
+			$this->request->getRequestParam('EVT_CAT', 0, 'int'),
1050
+			$this->request->getRequestParam('active_status')
1051
+		);
1052
+	}
1053
+
1054
+
1055
+	/**
1056
+	 * returns a list of "active" statuses on the event
1057
+	 *
1058
+	 * @param string $current_value whatever the current active status is
1059
+	 * @return string
1060
+	 */
1061
+	public function active_status_dropdown($current_value = '')
1062
+	{
1063
+		$select_name = 'active_status';
1064
+		$values      = [
1065
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1066
+			'active'   => esc_html__('Active', 'event_espresso'),
1067
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1068
+			'expired'  => esc_html__('Expired', 'event_espresso'),
1069
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
1070
+		];
1071
+
1072
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value);
1073
+	}
1074
+
1075
+
1076
+	/**
1077
+	 * returns a list of "venues"
1078
+	 *
1079
+	 * @param string $current_value whatever the current active status is
1080
+	 * @return string
1081
+	 * @throws EE_Error
1082
+	 * @throws ReflectionException
1083
+	 */
1084
+	protected function venuesDropdown($current_value = '')
1085
+	{
1086
+		$values = ['' => esc_html__('All Venues', 'event_espresso')];
1087
+		// populate the list of venues.
1088
+		$venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1089
+
1090
+		foreach ($venues as $venue) {
1091
+			$values[ $venue->ID() ] = $venue->name();
1092
+		}
1093
+
1094
+		return EEH_Form_Fields::select_input('venue', $values, $current_value);
1095
+	}
1096
+
1097
+
1098
+	/**
1099
+	 * output a dropdown of the categories for the category filter on the event admin list table
1100
+	 *
1101
+	 * @access  public
1102
+	 * @return string html
1103
+	 * @throws EE_Error
1104
+	 * @throws ReflectionException
1105
+	 */
1106
+	public function category_dropdown()
1107
+	{
1108
+		return EEH_Form_Fields::generate_event_category_dropdown(
1109
+			$this->request->getRequestParam('EVT_CAT', -1, 'int')
1110
+		);
1111
+	}
1112
+
1113
+
1114
+	/**
1115
+	 * get total number of events today
1116
+	 *
1117
+	 * @access public
1118
+	 * @return int
1119
+	 * @throws EE_Error
1120
+	 * @throws InvalidArgumentException
1121
+	 * @throws InvalidDataTypeException
1122
+	 * @throws InvalidInterfaceException
1123
+	 */
1124
+	public function total_events_today()
1125
+	{
1126
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1127
+			'DTT_EVT_start',
1128
+			date('Y-m-d') . ' 00:00:00',
1129
+			'Y-m-d H:i:s',
1130
+			'UTC'
1131
+		);
1132
+		$end   = EEM_Datetime::instance()->convert_datetime_for_query(
1133
+			'DTT_EVT_start',
1134
+			date('Y-m-d') . ' 23:59:59',
1135
+			'Y-m-d H:i:s',
1136
+			'UTC'
1137
+		);
1138
+		$where = [
1139
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1140
+		];
1141
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1142
+	}
1143
+
1144
+
1145
+	/**
1146
+	 * get total number of events this month
1147
+	 *
1148
+	 * @access public
1149
+	 * @return int
1150
+	 * @throws EE_Error
1151
+	 * @throws InvalidArgumentException
1152
+	 * @throws InvalidDataTypeException
1153
+	 * @throws InvalidInterfaceException
1154
+	 */
1155
+	public function total_events_this_month()
1156
+	{
1157
+		// Dates
1158
+		$this_year_r     = date('Y');
1159
+		$this_month_r    = date('m');
1160
+		$days_this_month = date('t');
1161
+		$start           = EEM_Datetime::instance()->convert_datetime_for_query(
1162
+			'DTT_EVT_start',
1163
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1164
+			'Y-m-d H:i:s',
1165
+			'UTC'
1166
+		);
1167
+		$end             = EEM_Datetime::instance()->convert_datetime_for_query(
1168
+			'DTT_EVT_start',
1169
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1170
+			'Y-m-d H:i:s',
1171
+			'UTC'
1172
+		);
1173
+		$where           = [
1174
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1175
+		];
1176
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1177
+	}
1178
+
1179
+
1180
+	/** DEFAULT TICKETS STUFF **/
1181
+
1182
+	/**
1183
+	 * Output default tickets list table view.
1184
+	 *
1185
+	 * @throws EE_Error
1186
+	 */
1187
+	public function _tickets_overview_list_table()
1188
+	{
1189
+		if (
1190
+			$this->admin_config->useAdvancedEditor()
1191
+			&& $this->feature->allowed('use_default_ticket_manager')
1192
+		) {
1193
+			// check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
1194
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1195
+				EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php',
1196
+				[],
1197
+				true
1198
+			);
1199
+			$this->display_admin_page_with_no_sidebar();
1200
+		} else {
1201
+			$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1202
+			$this->display_admin_list_table_page_with_no_sidebar();
1203
+		}
1204
+	}
1205
+
1206
+
1207
+	/**
1208
+	 * @param int  $per_page
1209
+	 * @param bool $count
1210
+	 * @param bool $trashed
1211
+	 * @return EE_Soft_Delete_Base_Class[]|int
1212
+	 * @throws EE_Error
1213
+	 */
1214
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1215
+	{
1216
+		$orderby = $this->request->getRequestParam('orderby', 'TKT_name');
1217
+		$order   = $this->request->getRequestParam('order', 'ASC');
1218
+		switch ($orderby) {
1219
+			case 'TKT_name':
1220
+				$orderby = ['TKT_name' => $order];
1221
+				break;
1222
+			case 'TKT_price':
1223
+				$orderby = ['TKT_price' => $order];
1224
+				break;
1225
+			case 'TKT_uses':
1226
+				$orderby = ['TKT_uses' => $order];
1227
+				break;
1228
+			case 'TKT_min':
1229
+				$orderby = ['TKT_min' => $order];
1230
+				break;
1231
+			case 'TKT_max':
1232
+				$orderby = ['TKT_max' => $order];
1233
+				break;
1234
+			case 'TKT_qty':
1235
+				$orderby = ['TKT_qty' => $order];
1236
+				break;
1237
+		}
1238
+
1239
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
1240
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1241
+		$offset       = ($current_page - 1) * $per_page;
1242
+
1243
+		$where = [
1244
+			'TKT_is_default' => 1,
1245
+			'TKT_deleted'    => $trashed,
1246
+		];
1247
+
1248
+		$search_term = $this->request->getRequestParam('s');
1249
+		if ($search_term) {
1250
+			$search_term = '%' . $search_term . '%';
1251
+			$where['OR'] = [
1252
+				'TKT_name'        => ['LIKE', $search_term],
1253
+				'TKT_description' => ['LIKE', $search_term],
1254
+			];
1255
+		}
1256
+
1257
+		return $count
1258
+			? EEM_Ticket::instance()->count_deleted_and_undeleted([$where])
1259
+			: EEM_Ticket::instance()->get_all_deleted_and_undeleted(
1260
+				[
1261
+					$where,
1262
+					'order_by' => $orderby,
1263
+					'limit'    => [$offset, $per_page],
1264
+					'group_by' => 'TKT_ID',
1265
+				]
1266
+			);
1267
+	}
1268
+
1269
+
1270
+	/**
1271
+	 * @param bool $trash
1272
+	 * @throws EE_Error
1273
+	 * @throws InvalidArgumentException
1274
+	 * @throws InvalidDataTypeException
1275
+	 * @throws InvalidInterfaceException
1276
+	 */
1277
+	protected function _trash_or_restore_ticket($trash = false)
1278
+	{
1279
+		$success = 1;
1280
+		$TKT     = EEM_Ticket::instance();
1281
+		// checkboxes?
1282
+		$checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1283
+		if (! empty($checkboxes)) {
1284
+			// if array has more than one element then success message should be plural
1285
+			$success = count($checkboxes) > 1 ? 2 : 1;
1286
+			// cycle thru the boxes
1287
+			while (list($TKT_ID, $value) = each($checkboxes)) {
1288
+				if ($trash) {
1289
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1290
+						$success = 0;
1291
+					}
1292
+				} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1293
+					$success = 0;
1294
+				}
1295
+			}
1296
+		} else {
1297
+			// grab single id and trash
1298
+			$TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1299
+			if ($trash) {
1300
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1301
+					$success = 0;
1302
+				}
1303
+			} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1304
+				$success = 0;
1305
+			}
1306
+		}
1307
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1308
+		$query_args  = [
1309
+			'action' => 'ticket_list_table',
1310
+			'status' => $trash ? '' : 'trashed',
1311
+		];
1312
+		$this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1313
+	}
1314
+
1315
+
1316
+	/**
1317
+	 * Handles trashing default ticket.
1318
+	 *
1319
+	 * @throws EE_Error
1320
+	 * @throws ReflectionException
1321
+	 */
1322
+	protected function _delete_ticket()
1323
+	{
1324
+		$success = 1;
1325
+		// checkboxes?
1326
+		$checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1327
+		if (! empty($checkboxes)) {
1328
+			// if array has more than one element then success message should be plural
1329
+			$success = count($checkboxes) > 1 ? 2 : 1;
1330
+			// cycle thru the boxes
1331
+			while (list($TKT_ID, $value) = each($checkboxes)) {
1332
+				// delete
1333
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1334
+					$success = 0;
1335
+				}
1336
+			}
1337
+		} else {
1338
+			// grab single id and trash
1339
+			$TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1340
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1341
+				$success = 0;
1342
+			}
1343
+		}
1344
+		$action_desc = 'deleted';
1345
+		$query_args  = [
1346
+			'action' => 'ticket_list_table',
1347
+			'status' => 'trashed',
1348
+		];
1349
+		// fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1350
+		if (
1351
+			EEM_Ticket::instance()->count_deleted_and_undeleted(
1352
+				[['TKT_is_default' => 1]],
1353
+				'TKT_ID',
1354
+				true
1355
+			)
1356
+		) {
1357
+			$query_args = [];
1358
+		}
1359
+		$this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1360
+	}
1361
+
1362
+
1363
+	/**
1364
+	 * @param int $TKT_ID
1365
+	 * @return bool|int
1366
+	 * @throws EE_Error
1367
+	 * @throws ReflectionException
1368
+	 */
1369
+	protected function _delete_the_ticket($TKT_ID)
1370
+	{
1371
+		$ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1372
+		if (! $ticket instanceof EE_Ticket) {
1373
+			return false;
1374
+		}
1375
+		$ticket->_remove_relations('Datetime');
1376
+		// delete all related prices first
1377
+		$ticket->delete_related_permanently('Price');
1378
+		return $ticket->delete_permanently();
1379
+	}
1380 1380
 }
Please login to merge, or discard this patch.
caffeinated/admin/extend/messages/Extend_Messages_Admin_Page.core.php 1 patch
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -16,191 +16,191 @@
 block discarded – undo
16 16
  */
17 17
 class Extend_Messages_Admin_Page extends Messages_Admin_Page
18 18
 {
19
-    public function __construct($routing = true)
20
-    {
21
-        parent::__construct($routing);
22
-        if (! defined('EE_MSG_CAF_ASSETS_PATH')) {
23
-            define('EE_MSG_CAF_ASSETS_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/assets/');
24
-            define('EE_MSG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/');
25
-            define('EE_MSG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/');
26
-            define('EE_MSG_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/templates/');
27
-        }
28
-    }
29
-
30
-    protected function _extend_page_config()
31
-    {
32
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'messages';
33
-        $this->_page_routes['custom_mtps'] = array(
34
-            'func'       => '_ee_custom_messages_overview_list_table',
35
-            'capability' => 'ee_read_messages',
36
-        );
37
-        $this->_page_config['custom_mtps'] = array(
38
-            'nav'           => array(
39
-                'label' => esc_html__('Custom Message Templates', 'event_espresso'),
40
-                'icon' => 'dashicons-art',
41
-                'order' => 30,
42
-            ),
43
-            'list_table'    => 'Custom_Messages_Template_List_Table',
44
-            'help_tabs'     => array(
45
-                'message_overview_message_types_help_tab' => array(
46
-                    'title'    => esc_html__('Message Types', 'event_espresso'),
47
-                    'filename' => 'messages_overview_types',
48
-                ),
49
-                'messages_overview_messengers_help_tab'   => array(
50
-                    'title'    => esc_html__('Messengers', 'event_espresso'),
51
-                    'filename' => 'messages_overview_messengers',
52
-                ),
53
-                'messages_overview_other_help_tab'        => array(
54
-                    'title'    => esc_html__('Messages Other', 'event_espresso'),
55
-                    'filename' => 'messages_overview_other',
56
-                ),
57
-            ),
58
-            'require_nonce' => false,
59
-        );
60
-
61
-        add_action('current_screen', array($this, 'dynamic_screen_hooks'), 10);
62
-    }
63
-
64
-
65
-    /**
66
-     * Callback for current_screen action
67
-     * This is used for any filters and/or actions that require the dynamic screen hook_prefix to be correct.
68
-     *
69
-     * @since 4.5.0
70
-     *
71
-     * @return void
72
-     */
73
-    public function dynamic_screen_hooks()
74
-    {
75
-        global $admin_page_hooks;
76
-
77
-        if (! empty($admin_page_hooks['espresso_events'])) {
78
-            // we're on a EE specific page... good stuff!
79
-            $hook_prefix = $admin_page_hooks['espresso_events'];
80
-            $filter_ref = $hook_prefix . '_page_' . $this->page_slug;
81
-            add_filter('FHEE_manage_' . $filter_ref . '_columns', array($this, 'add_custom_mtps_columns'), 10, 2);
82
-            add_action(
83
-                'AHEE__EE_Admin_List_Table__column_actions__' . $filter_ref,
84
-                array($this, 'custom_mtp_create_button_column'),
85
-                10,
86
-                2
87
-            );
88
-        }
89
-    }
90
-
91
-
92
-    /**
93
-     * This is the callback for the FHEE__manage_event-espresso_page_espresso_messages_columns to register the
94
-     * caffeinated columns for the global message templates list table.
95
-     *
96
-     * @since 4.3.2
97
-     *
98
-     * @param array  $columns   Original defined list of columns
99
-     * @param string $screen_id The unique screen id for the page.
100
-     */
101
-    public function add_custom_mtps_columns($columns, $screen_id)
102
-    {
103
-        if ($screen_id !== 'espresso_messages_global_mtps') {
104
-            return $columns;
105
-        }
106
-
107
-        $columns['actions'] = '';
108
-        return $columns;
109
-    }
110
-
111
-
112
-    /**
113
-     * Callback for FHEE__EE_Admin_List_Table__column_actions__event-espresso_page_espresso_messages action that allows
114
-     * for adding the content for the registered "action" column.
115
-     *
116
-     * @since 4.3.2
117
-     *
118
-     * @param EE_Base_Class
119
-     * @param string $screen_id Unique screen id for the page
120
-     *
121
-     * @return string html content for the page.
122
-     */
123
-    public function custom_mtp_create_button_column($item, $screen_id)
124
-    {
125
-        if (
126
-            $screen_id !== 'espresso_messages_global_mtps' || ! EE_Registry::instance()->CAP->current_user_can(
127
-                'ee_edit_messages',
128
-                'espresso_messages_add_new_message_template'
129
-            )
130
-        ) {
131
-            return '';
132
-        }
133
-
134
-        // first we consider whether this template has override set.  If it does then that means no custom templates can be created from this template as a base.  So let's just skip the button creation.
135
-        if ($item->get('MTP_is_override')) {
136
-            return '';
137
-        }
138
-
139
-
140
-        $create_args = array(
141
-            'GRP_ID'       => $item->ID(),
142
-            'messenger'    => $item->messenger(),
143
-            'message_type' => $item->message_type(),
144
-            'action'       => 'add_new_message_template',
145
-        );
146
-        $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
147
-        echo sprintf(
148
-            '<a href="%s" class="button button--secondary button--small">%s</a>',
149
-            $create_link,
150
-            esc_html__('Create Custom', 'event_espresso')
151
-        );
152
-    }
153
-
154
-
155
-    protected function _add_screen_options_custom_mtps()
156
-    {
157
-        $page_title = $this->_admin_page_title;
158
-        $this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso');
159
-        $this->_per_page_screen_option();
160
-        $this->_admin_page_title = $page_title;
161
-    }
162
-
163
-
164
-    /**
165
-     * set views array for Custom Templates list table
166
-     *
167
-     * @access public
168
-     * @return void
169
-     */
170
-    public function _set_list_table_views_custom_mtps()
171
-    {
172
-        $this->_views = array(
173
-            'in_use' => array(
174
-                'slug'        => 'in_use',
175
-                'label'       => esc_html__('In Use', 'event_espresso'),
176
-                'count'       => 0,
177
-                'bulk_action' => array(
178
-                    'trash_message_template' => esc_html__('Move to Trash', 'event_espresso'),
179
-                ),
180
-            ),
181
-        );
182
-        if (
183
-            EE_Registry::instance()->CAP->current_user_can(
184
-                'ee_delete_messages',
185
-                'espresso_messages_trash_message_template'
186
-            )
187
-        ) {
188
-            $this->_views['trashed'] = array(
189
-                'slug'        => 'trashed',
190
-                'label'       => esc_html__('Trash', 'event_espresso'),
191
-                'count'       => 0,
192
-                'bulk_action' => array(
193
-                    'restore_message_template' => esc_html__('Restore From Trash', 'event_espresso'),
194
-                    'delete_message_template'  => esc_html__('Delete Permanently', 'event_espresso'),
195
-                ),
196
-            );
197
-        }
198
-    }
199
-
200
-
201
-    protected function _ee_custom_messages_overview_list_table()
202
-    {
203
-        $this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso');
204
-        $this->display_admin_list_table_page_with_no_sidebar();
205
-    }
19
+	public function __construct($routing = true)
20
+	{
21
+		parent::__construct($routing);
22
+		if (! defined('EE_MSG_CAF_ASSETS_PATH')) {
23
+			define('EE_MSG_CAF_ASSETS_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/assets/');
24
+			define('EE_MSG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/');
25
+			define('EE_MSG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/');
26
+			define('EE_MSG_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/templates/');
27
+		}
28
+	}
29
+
30
+	protected function _extend_page_config()
31
+	{
32
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'messages';
33
+		$this->_page_routes['custom_mtps'] = array(
34
+			'func'       => '_ee_custom_messages_overview_list_table',
35
+			'capability' => 'ee_read_messages',
36
+		);
37
+		$this->_page_config['custom_mtps'] = array(
38
+			'nav'           => array(
39
+				'label' => esc_html__('Custom Message Templates', 'event_espresso'),
40
+				'icon' => 'dashicons-art',
41
+				'order' => 30,
42
+			),
43
+			'list_table'    => 'Custom_Messages_Template_List_Table',
44
+			'help_tabs'     => array(
45
+				'message_overview_message_types_help_tab' => array(
46
+					'title'    => esc_html__('Message Types', 'event_espresso'),
47
+					'filename' => 'messages_overview_types',
48
+				),
49
+				'messages_overview_messengers_help_tab'   => array(
50
+					'title'    => esc_html__('Messengers', 'event_espresso'),
51
+					'filename' => 'messages_overview_messengers',
52
+				),
53
+				'messages_overview_other_help_tab'        => array(
54
+					'title'    => esc_html__('Messages Other', 'event_espresso'),
55
+					'filename' => 'messages_overview_other',
56
+				),
57
+			),
58
+			'require_nonce' => false,
59
+		);
60
+
61
+		add_action('current_screen', array($this, 'dynamic_screen_hooks'), 10);
62
+	}
63
+
64
+
65
+	/**
66
+	 * Callback for current_screen action
67
+	 * This is used for any filters and/or actions that require the dynamic screen hook_prefix to be correct.
68
+	 *
69
+	 * @since 4.5.0
70
+	 *
71
+	 * @return void
72
+	 */
73
+	public function dynamic_screen_hooks()
74
+	{
75
+		global $admin_page_hooks;
76
+
77
+		if (! empty($admin_page_hooks['espresso_events'])) {
78
+			// we're on a EE specific page... good stuff!
79
+			$hook_prefix = $admin_page_hooks['espresso_events'];
80
+			$filter_ref = $hook_prefix . '_page_' . $this->page_slug;
81
+			add_filter('FHEE_manage_' . $filter_ref . '_columns', array($this, 'add_custom_mtps_columns'), 10, 2);
82
+			add_action(
83
+				'AHEE__EE_Admin_List_Table__column_actions__' . $filter_ref,
84
+				array($this, 'custom_mtp_create_button_column'),
85
+				10,
86
+				2
87
+			);
88
+		}
89
+	}
90
+
91
+
92
+	/**
93
+	 * This is the callback for the FHEE__manage_event-espresso_page_espresso_messages_columns to register the
94
+	 * caffeinated columns for the global message templates list table.
95
+	 *
96
+	 * @since 4.3.2
97
+	 *
98
+	 * @param array  $columns   Original defined list of columns
99
+	 * @param string $screen_id The unique screen id for the page.
100
+	 */
101
+	public function add_custom_mtps_columns($columns, $screen_id)
102
+	{
103
+		if ($screen_id !== 'espresso_messages_global_mtps') {
104
+			return $columns;
105
+		}
106
+
107
+		$columns['actions'] = '';
108
+		return $columns;
109
+	}
110
+
111
+
112
+	/**
113
+	 * Callback for FHEE__EE_Admin_List_Table__column_actions__event-espresso_page_espresso_messages action that allows
114
+	 * for adding the content for the registered "action" column.
115
+	 *
116
+	 * @since 4.3.2
117
+	 *
118
+	 * @param EE_Base_Class
119
+	 * @param string $screen_id Unique screen id for the page
120
+	 *
121
+	 * @return string html content for the page.
122
+	 */
123
+	public function custom_mtp_create_button_column($item, $screen_id)
124
+	{
125
+		if (
126
+			$screen_id !== 'espresso_messages_global_mtps' || ! EE_Registry::instance()->CAP->current_user_can(
127
+				'ee_edit_messages',
128
+				'espresso_messages_add_new_message_template'
129
+			)
130
+		) {
131
+			return '';
132
+		}
133
+
134
+		// first we consider whether this template has override set.  If it does then that means no custom templates can be created from this template as a base.  So let's just skip the button creation.
135
+		if ($item->get('MTP_is_override')) {
136
+			return '';
137
+		}
138
+
139
+
140
+		$create_args = array(
141
+			'GRP_ID'       => $item->ID(),
142
+			'messenger'    => $item->messenger(),
143
+			'message_type' => $item->message_type(),
144
+			'action'       => 'add_new_message_template',
145
+		);
146
+		$create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
147
+		echo sprintf(
148
+			'<a href="%s" class="button button--secondary button--small">%s</a>',
149
+			$create_link,
150
+			esc_html__('Create Custom', 'event_espresso')
151
+		);
152
+	}
153
+
154
+
155
+	protected function _add_screen_options_custom_mtps()
156
+	{
157
+		$page_title = $this->_admin_page_title;
158
+		$this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso');
159
+		$this->_per_page_screen_option();
160
+		$this->_admin_page_title = $page_title;
161
+	}
162
+
163
+
164
+	/**
165
+	 * set views array for Custom Templates list table
166
+	 *
167
+	 * @access public
168
+	 * @return void
169
+	 */
170
+	public function _set_list_table_views_custom_mtps()
171
+	{
172
+		$this->_views = array(
173
+			'in_use' => array(
174
+				'slug'        => 'in_use',
175
+				'label'       => esc_html__('In Use', 'event_espresso'),
176
+				'count'       => 0,
177
+				'bulk_action' => array(
178
+					'trash_message_template' => esc_html__('Move to Trash', 'event_espresso'),
179
+				),
180
+			),
181
+		);
182
+		if (
183
+			EE_Registry::instance()->CAP->current_user_can(
184
+				'ee_delete_messages',
185
+				'espresso_messages_trash_message_template'
186
+			)
187
+		) {
188
+			$this->_views['trashed'] = array(
189
+				'slug'        => 'trashed',
190
+				'label'       => esc_html__('Trash', 'event_espresso'),
191
+				'count'       => 0,
192
+				'bulk_action' => array(
193
+					'restore_message_template' => esc_html__('Restore From Trash', 'event_espresso'),
194
+					'delete_message_template'  => esc_html__('Delete Permanently', 'event_espresso'),
195
+				),
196
+			);
197
+		}
198
+	}
199
+
200
+
201
+	protected function _ee_custom_messages_overview_list_table()
202
+	{
203
+		$this->_admin_page_title = esc_html__('Custom Message Templates', 'event_espresso');
204
+		$this->display_admin_list_table_page_with_no_sidebar();
205
+	}
206 206
 }
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 1 patch
Indentation   +1231 added lines, -1231 removed lines patch added patch discarded remove patch
@@ -14,1289 +14,1289 @@
 block discarded – undo
14 14
  */
15 15
 class Extend_Registrations_Admin_Page extends Registrations_Admin_Page
16 16
 {
17
-    /**
18
-     * This is used to hold the reports template data which is setup early in the request.
19
-     *
20
-     * @type array
21
-     */
22
-    protected $_reports_template_data = array();
17
+	/**
18
+	 * This is used to hold the reports template data which is setup early in the request.
19
+	 *
20
+	 * @type array
21
+	 */
22
+	protected $_reports_template_data = array();
23 23
 
24 24
 
25
-    /**
26
-     * Extend_Registrations_Admin_Page constructor.
27
-     *
28
-     * @param bool $routing
29
-     */
30
-    public function __construct($routing = true)
31
-    {
32
-        parent::__construct($routing);
33
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
34
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
35
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
36
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
37
-        }
38
-    }
25
+	/**
26
+	 * Extend_Registrations_Admin_Page constructor.
27
+	 *
28
+	 * @param bool $routing
29
+	 */
30
+	public function __construct($routing = true)
31
+	{
32
+		parent::__construct($routing);
33
+		if (! defined('REG_CAF_TEMPLATE_PATH')) {
34
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
35
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
36
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
37
+		}
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * Extending page configuration.
43
-     */
44
-    protected function _extend_page_config()
45
-    {
46
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
47
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
48
-            ? $this->_req_data['_REG_ID']
49
-            : 0;
50
-        $new_page_routes = array(
51
-            'reports'                      => array(
52
-                'func'       => '_registration_reports',
53
-                'capability' => 'ee_read_registrations',
54
-            ),
55
-            'registration_checkins'        => array(
56
-                'func'       => '_registration_checkin_list_table',
57
-                'capability' => 'ee_read_checkins',
58
-            ),
59
-            'newsletter_selected_send'     => array(
60
-                'func'       => '_newsletter_selected_send',
61
-                'noheader'   => true,
62
-                'capability' => 'ee_send_message',
63
-            ),
64
-            'delete_checkin_rows'          => array(
65
-                'func'       => '_delete_checkin_rows',
66
-                'noheader'   => true,
67
-                'capability' => 'ee_delete_checkins',
68
-            ),
69
-            'delete_checkin_row'           => array(
70
-                'func'       => '_delete_checkin_row',
71
-                'noheader'   => true,
72
-                'capability' => 'ee_delete_checkin',
73
-                'obj_id'     => $reg_id,
74
-            ),
75
-            'toggle_checkin_status'        => array(
76
-                'func'       => '_toggle_checkin_status',
77
-                'noheader'   => true,
78
-                'capability' => 'ee_edit_checkin',
79
-                'obj_id'     => $reg_id,
80
-            ),
81
-            'toggle_checkin_status_bulk'   => array(
82
-                'func'       => '_toggle_checkin_status',
83
-                'noheader'   => true,
84
-                'capability' => 'ee_edit_checkins',
85
-            ),
86
-            'event_registrations'          => array(
87
-                'func'       => '_event_registrations_list_table',
88
-                'capability' => 'ee_read_checkins',
89
-            ),
90
-            'registrations_checkin_report' => array(
91
-                'func'       => '_registrations_checkin_report',
92
-                'noheader'   => true,
93
-                'capability' => 'ee_read_registrations',
94
-            ),
95
-        );
96
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
97
-        $new_page_config = array(
98
-            'reports'               => array(
99
-                'nav'           => array(
100
-                    'label' => esc_html__('Reports', 'event_espresso'),
101
-                    'icon' => 'dashicons-chart-bar',
102
-                    'order' => 30,
103
-                ),
104
-                'help_tabs'     => array(
105
-                    'registrations_reports_help_tab' => array(
106
-                        'title'    => esc_html__('Registration Reports', 'event_espresso'),
107
-                        'filename' => 'registrations_reports',
108
-                    ),
109
-                ),
110
-                'require_nonce' => false,
111
-            ),
112
-            'event_registrations'   => array(
113
-                'nav'           => array(
114
-                    'label'      => esc_html__('Event Check-In', 'event_espresso'),
115
-                    'icon' => 'dashicons-yes-alt',
116
-                    'order'      => 10,
117
-                    'persistent' => true,
118
-                ),
119
-                'help_tabs'     => array(
120
-                    'registrations_event_checkin_help_tab'                       => array(
121
-                        'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
122
-                        'filename' => 'registrations_event_checkin',
123
-                    ),
124
-                    'registrations_event_checkin_table_column_headings_help_tab' => array(
125
-                        'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
126
-                        'filename' => 'registrations_event_checkin_table_column_headings',
127
-                    ),
128
-                    'registrations_event_checkin_filters_help_tab'               => array(
129
-                        'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
130
-                        'filename' => 'registrations_event_checkin_filters',
131
-                    ),
132
-                    'registrations_event_checkin_views_help_tab'                 => array(
133
-                        'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
134
-                        'filename' => 'registrations_event_checkin_views',
135
-                    ),
136
-                    'registrations_event_checkin_other_help_tab'                 => array(
137
-                        'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
138
-                        'filename' => 'registrations_event_checkin_other',
139
-                    ),
140
-                ),
141
-                'list_table'    => 'EE_Event_Registrations_List_Table',
142
-                'metaboxes'     => array(),
143
-                'require_nonce' => false,
144
-            ),
145
-            'registration_checkins' => array(
146
-                'nav'           => array(
147
-                    'label'      => esc_html__('Check-In Records', 'event_espresso'),
148
-                    'icon' => 'dashicons-list-view',
149
-                    'order'      => 15,
150
-                    'persistent' => false,
151
-                    'url'        => '',
152
-                ),
153
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
154
-                'metaboxes'     => array(),
155
-                'require_nonce' => false,
156
-            ),
157
-        );
158
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
159
-        $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
160
-        $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
161
-    }
41
+	/**
42
+	 * Extending page configuration.
43
+	 */
44
+	protected function _extend_page_config()
45
+	{
46
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
47
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
48
+			? $this->_req_data['_REG_ID']
49
+			: 0;
50
+		$new_page_routes = array(
51
+			'reports'                      => array(
52
+				'func'       => '_registration_reports',
53
+				'capability' => 'ee_read_registrations',
54
+			),
55
+			'registration_checkins'        => array(
56
+				'func'       => '_registration_checkin_list_table',
57
+				'capability' => 'ee_read_checkins',
58
+			),
59
+			'newsletter_selected_send'     => array(
60
+				'func'       => '_newsletter_selected_send',
61
+				'noheader'   => true,
62
+				'capability' => 'ee_send_message',
63
+			),
64
+			'delete_checkin_rows'          => array(
65
+				'func'       => '_delete_checkin_rows',
66
+				'noheader'   => true,
67
+				'capability' => 'ee_delete_checkins',
68
+			),
69
+			'delete_checkin_row'           => array(
70
+				'func'       => '_delete_checkin_row',
71
+				'noheader'   => true,
72
+				'capability' => 'ee_delete_checkin',
73
+				'obj_id'     => $reg_id,
74
+			),
75
+			'toggle_checkin_status'        => array(
76
+				'func'       => '_toggle_checkin_status',
77
+				'noheader'   => true,
78
+				'capability' => 'ee_edit_checkin',
79
+				'obj_id'     => $reg_id,
80
+			),
81
+			'toggle_checkin_status_bulk'   => array(
82
+				'func'       => '_toggle_checkin_status',
83
+				'noheader'   => true,
84
+				'capability' => 'ee_edit_checkins',
85
+			),
86
+			'event_registrations'          => array(
87
+				'func'       => '_event_registrations_list_table',
88
+				'capability' => 'ee_read_checkins',
89
+			),
90
+			'registrations_checkin_report' => array(
91
+				'func'       => '_registrations_checkin_report',
92
+				'noheader'   => true,
93
+				'capability' => 'ee_read_registrations',
94
+			),
95
+		);
96
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
97
+		$new_page_config = array(
98
+			'reports'               => array(
99
+				'nav'           => array(
100
+					'label' => esc_html__('Reports', 'event_espresso'),
101
+					'icon' => 'dashicons-chart-bar',
102
+					'order' => 30,
103
+				),
104
+				'help_tabs'     => array(
105
+					'registrations_reports_help_tab' => array(
106
+						'title'    => esc_html__('Registration Reports', 'event_espresso'),
107
+						'filename' => 'registrations_reports',
108
+					),
109
+				),
110
+				'require_nonce' => false,
111
+			),
112
+			'event_registrations'   => array(
113
+				'nav'           => array(
114
+					'label'      => esc_html__('Event Check-In', 'event_espresso'),
115
+					'icon' => 'dashicons-yes-alt',
116
+					'order'      => 10,
117
+					'persistent' => true,
118
+				),
119
+				'help_tabs'     => array(
120
+					'registrations_event_checkin_help_tab'                       => array(
121
+						'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
122
+						'filename' => 'registrations_event_checkin',
123
+					),
124
+					'registrations_event_checkin_table_column_headings_help_tab' => array(
125
+						'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
126
+						'filename' => 'registrations_event_checkin_table_column_headings',
127
+					),
128
+					'registrations_event_checkin_filters_help_tab'               => array(
129
+						'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
130
+						'filename' => 'registrations_event_checkin_filters',
131
+					),
132
+					'registrations_event_checkin_views_help_tab'                 => array(
133
+						'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
134
+						'filename' => 'registrations_event_checkin_views',
135
+					),
136
+					'registrations_event_checkin_other_help_tab'                 => array(
137
+						'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
138
+						'filename' => 'registrations_event_checkin_other',
139
+					),
140
+				),
141
+				'list_table'    => 'EE_Event_Registrations_List_Table',
142
+				'metaboxes'     => array(),
143
+				'require_nonce' => false,
144
+			),
145
+			'registration_checkins' => array(
146
+				'nav'           => array(
147
+					'label'      => esc_html__('Check-In Records', 'event_espresso'),
148
+					'icon' => 'dashicons-list-view',
149
+					'order'      => 15,
150
+					'persistent' => false,
151
+					'url'        => '',
152
+				),
153
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
154
+				'metaboxes'     => array(),
155
+				'require_nonce' => false,
156
+			),
157
+		);
158
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
159
+		$this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
160
+		$this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
161
+	}
162 162
 
163 163
 
164
-    /**
165
-     * Ajax hooks for all routes in this page.
166
-     */
167
-    protected function _ajax_hooks()
168
-    {
169
-        parent::_ajax_hooks();
170
-        add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
171
-    }
164
+	/**
165
+	 * Ajax hooks for all routes in this page.
166
+	 */
167
+	protected function _ajax_hooks()
168
+	{
169
+		parent::_ajax_hooks();
170
+		add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
171
+	}
172 172
 
173 173
 
174
-    /**
175
-     * Global scripts for all routes in this page.
176
-     */
177
-    public function load_scripts_styles()
178
-    {
179
-        parent::load_scripts_styles();
180
-        // if newsletter message type is active then let's add filter and load js for it.
181
-        if (EEH_MSG_Template::is_mt_active('newsletter')) {
182
-            // enqueue newsletter js
183
-            wp_enqueue_script(
184
-                'ee-newsletter-trigger',
185
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
186
-                array('ee-dialog'),
187
-                EVENT_ESPRESSO_VERSION,
188
-                true
189
-            );
190
-            wp_enqueue_style(
191
-                'ee-newsletter-trigger-css',
192
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
193
-                array(),
194
-                EVENT_ESPRESSO_VERSION
195
-            );
196
-            // hook in buttons for newsletter message type trigger.
197
-            add_action(
198
-                'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
199
-                array($this, 'add_newsletter_action_buttons'),
200
-                10
201
-            );
202
-        }
203
-    }
174
+	/**
175
+	 * Global scripts for all routes in this page.
176
+	 */
177
+	public function load_scripts_styles()
178
+	{
179
+		parent::load_scripts_styles();
180
+		// if newsletter message type is active then let's add filter and load js for it.
181
+		if (EEH_MSG_Template::is_mt_active('newsletter')) {
182
+			// enqueue newsletter js
183
+			wp_enqueue_script(
184
+				'ee-newsletter-trigger',
185
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
186
+				array('ee-dialog'),
187
+				EVENT_ESPRESSO_VERSION,
188
+				true
189
+			);
190
+			wp_enqueue_style(
191
+				'ee-newsletter-trigger-css',
192
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
193
+				array(),
194
+				EVENT_ESPRESSO_VERSION
195
+			);
196
+			// hook in buttons for newsletter message type trigger.
197
+			add_action(
198
+				'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
199
+				array($this, 'add_newsletter_action_buttons'),
200
+				10
201
+			);
202
+		}
203
+	}
204 204
 
205 205
 
206
-    /**
207
-     * Scripts and styles for just the reports route.
208
-     */
209
-    public function load_scripts_styles_reports()
210
-    {
211
-        wp_register_script(
212
-            'ee-reg-reports-js',
213
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
214
-            array('google-charts'),
215
-            EVENT_ESPRESSO_VERSION,
216
-            true
217
-        );
218
-        wp_enqueue_script('ee-reg-reports-js');
219
-        $this->_registration_reports_js_setup();
220
-    }
206
+	/**
207
+	 * Scripts and styles for just the reports route.
208
+	 */
209
+	public function load_scripts_styles_reports()
210
+	{
211
+		wp_register_script(
212
+			'ee-reg-reports-js',
213
+			REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
214
+			array('google-charts'),
215
+			EVENT_ESPRESSO_VERSION,
216
+			true
217
+		);
218
+		wp_enqueue_script('ee-reg-reports-js');
219
+		$this->_registration_reports_js_setup();
220
+	}
221 221
 
222 222
 
223
-    /**
224
-     * Register screen options for event_registrations route.
225
-     */
226
-    protected function _add_screen_options_event_registrations()
227
-    {
228
-        $this->_per_page_screen_option();
229
-    }
223
+	/**
224
+	 * Register screen options for event_registrations route.
225
+	 */
226
+	protected function _add_screen_options_event_registrations()
227
+	{
228
+		$this->_per_page_screen_option();
229
+	}
230 230
 
231 231
 
232
-    /**
233
-     * Register screen options for registration_checkins route
234
-     */
235
-    protected function _add_screen_options_registration_checkins()
236
-    {
237
-        $page_title = $this->_admin_page_title;
238
-        $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
239
-        $this->_per_page_screen_option();
240
-        $this->_admin_page_title = $page_title;
241
-    }
232
+	/**
233
+	 * Register screen options for registration_checkins route
234
+	 */
235
+	protected function _add_screen_options_registration_checkins()
236
+	{
237
+		$page_title = $this->_admin_page_title;
238
+		$this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
239
+		$this->_per_page_screen_option();
240
+		$this->_admin_page_title = $page_title;
241
+	}
242 242
 
243 243
 
244
-    /**
245
-     * Set views property for event_registrations route.
246
-     */
247
-    protected function _set_list_table_views_event_registrations()
248
-    {
249
-        $this->_views = array(
250
-            'all' => array(
251
-                'slug'        => 'all',
252
-                'label'       => esc_html__('All', 'event_espresso'),
253
-                'count'       => 0,
254
-                'bulk_action' => ! isset($this->_req_data['event_id'])
255
-                    ? array()
256
-                    : array(
257
-                        'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
258
-                    ),
259
-            ),
260
-        );
261
-    }
244
+	/**
245
+	 * Set views property for event_registrations route.
246
+	 */
247
+	protected function _set_list_table_views_event_registrations()
248
+	{
249
+		$this->_views = array(
250
+			'all' => array(
251
+				'slug'        => 'all',
252
+				'label'       => esc_html__('All', 'event_espresso'),
253
+				'count'       => 0,
254
+				'bulk_action' => ! isset($this->_req_data['event_id'])
255
+					? array()
256
+					: array(
257
+						'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
258
+					),
259
+			),
260
+		);
261
+	}
262 262
 
263 263
 
264
-    /**
265
-     * Set views property for registration_checkins route.
266
-     */
267
-    protected function _set_list_table_views_registration_checkins()
268
-    {
269
-        $this->_views = array(
270
-            'all' => array(
271
-                'slug'        => 'all',
272
-                'label'       => esc_html__('All', 'event_espresso'),
273
-                'count'       => 0,
274
-                'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
275
-            ),
276
-        );
277
-    }
264
+	/**
265
+	 * Set views property for registration_checkins route.
266
+	 */
267
+	protected function _set_list_table_views_registration_checkins()
268
+	{
269
+		$this->_views = array(
270
+			'all' => array(
271
+				'slug'        => 'all',
272
+				'label'       => esc_html__('All', 'event_espresso'),
273
+				'count'       => 0,
274
+				'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
275
+			),
276
+		);
277
+	}
278 278
 
279 279
 
280
-    /**
281
-     * callback for ajax action.
282
-     *
283
-     * @since 4.3.0
284
-     * @return void (JSON)
285
-     * @throws EE_Error
286
-     * @throws InvalidArgumentException
287
-     * @throws InvalidDataTypeException
288
-     * @throws InvalidInterfaceException
289
-     */
290
-    public function get_newsletter_form_content()
291
-    {
292
-        // do a nonce check cause we're not coming in from an normal route here.
293
-        $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
294
-            $this->_req_data['get_newsletter_form_content_nonce']
295
-        ) : '';
296
-        $nonce_ref = 'get_newsletter_form_content_nonce';
297
-        $this->_verify_nonce($nonce, $nonce_ref);
298
-        // let's get the mtp for the incoming MTP_ ID
299
-        if (! isset($this->_req_data['GRP_ID'])) {
300
-            EE_Error::add_error(
301
-                esc_html__(
302
-                    'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
303
-                    'event_espresso'
304
-                ),
305
-                __FILE__,
306
-                __FUNCTION__,
307
-                __LINE__
308
-            );
309
-            $this->_template_args['success'] = false;
310
-            $this->_template_args['error'] = true;
311
-            $this->_return_json();
312
-        }
313
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
314
-        if (! $MTPG instanceof EE_Message_Template_Group) {
315
-            EE_Error::add_error(
316
-                sprintf(
317
-                    esc_html__(
318
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
319
-                        'event_espresso'
320
-                    ),
321
-                    $this->_req_data['GRP_ID']
322
-                ),
323
-                __FILE__,
324
-                __FUNCTION__,
325
-                __LINE__
326
-            );
327
-            $this->_template_args['success'] = false;
328
-            $this->_template_args['error'] = true;
329
-            $this->_return_json();
330
-        }
331
-        $MTPs = $MTPG->context_templates();
332
-        $MTPs = $MTPs['attendee'];
333
-        $template_fields = array();
334
-        /** @var EE_Message_Template $MTP */
335
-        foreach ($MTPs as $MTP) {
336
-            $field = $MTP->get('MTP_template_field');
337
-            if ($field === 'content') {
338
-                $content = $MTP->get('MTP_content');
339
-                if (! empty($content['newsletter_content'])) {
340
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
341
-                }
342
-                continue;
343
-            }
344
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
345
-        }
346
-        $this->_template_args['success'] = true;
347
-        $this->_template_args['error'] = false;
348
-        $this->_template_args['data'] = array(
349
-            'batch_message_from'    => isset($template_fields['from'])
350
-                ? $template_fields['from']
351
-                : '',
352
-            'batch_message_subject' => isset($template_fields['subject'])
353
-                ? $template_fields['subject']
354
-                : '',
355
-            'batch_message_content' => isset($template_fields['newsletter_content'])
356
-                ? $template_fields['newsletter_content']
357
-                : '',
358
-        );
359
-        $this->_return_json();
360
-    }
280
+	/**
281
+	 * callback for ajax action.
282
+	 *
283
+	 * @since 4.3.0
284
+	 * @return void (JSON)
285
+	 * @throws EE_Error
286
+	 * @throws InvalidArgumentException
287
+	 * @throws InvalidDataTypeException
288
+	 * @throws InvalidInterfaceException
289
+	 */
290
+	public function get_newsletter_form_content()
291
+	{
292
+		// do a nonce check cause we're not coming in from an normal route here.
293
+		$nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
294
+			$this->_req_data['get_newsletter_form_content_nonce']
295
+		) : '';
296
+		$nonce_ref = 'get_newsletter_form_content_nonce';
297
+		$this->_verify_nonce($nonce, $nonce_ref);
298
+		// let's get the mtp for the incoming MTP_ ID
299
+		if (! isset($this->_req_data['GRP_ID'])) {
300
+			EE_Error::add_error(
301
+				esc_html__(
302
+					'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
303
+					'event_espresso'
304
+				),
305
+				__FILE__,
306
+				__FUNCTION__,
307
+				__LINE__
308
+			);
309
+			$this->_template_args['success'] = false;
310
+			$this->_template_args['error'] = true;
311
+			$this->_return_json();
312
+		}
313
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
314
+		if (! $MTPG instanceof EE_Message_Template_Group) {
315
+			EE_Error::add_error(
316
+				sprintf(
317
+					esc_html__(
318
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
319
+						'event_espresso'
320
+					),
321
+					$this->_req_data['GRP_ID']
322
+				),
323
+				__FILE__,
324
+				__FUNCTION__,
325
+				__LINE__
326
+			);
327
+			$this->_template_args['success'] = false;
328
+			$this->_template_args['error'] = true;
329
+			$this->_return_json();
330
+		}
331
+		$MTPs = $MTPG->context_templates();
332
+		$MTPs = $MTPs['attendee'];
333
+		$template_fields = array();
334
+		/** @var EE_Message_Template $MTP */
335
+		foreach ($MTPs as $MTP) {
336
+			$field = $MTP->get('MTP_template_field');
337
+			if ($field === 'content') {
338
+				$content = $MTP->get('MTP_content');
339
+				if (! empty($content['newsletter_content'])) {
340
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
341
+				}
342
+				continue;
343
+			}
344
+			$template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
345
+		}
346
+		$this->_template_args['success'] = true;
347
+		$this->_template_args['error'] = false;
348
+		$this->_template_args['data'] = array(
349
+			'batch_message_from'    => isset($template_fields['from'])
350
+				? $template_fields['from']
351
+				: '',
352
+			'batch_message_subject' => isset($template_fields['subject'])
353
+				? $template_fields['subject']
354
+				: '',
355
+			'batch_message_content' => isset($template_fields['newsletter_content'])
356
+				? $template_fields['newsletter_content']
357
+				: '',
358
+		);
359
+		$this->_return_json();
360
+	}
361 361
 
362 362
 
363
-    /**
364
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
365
-     *
366
-     * @since 4.3.0
367
-     * @param EE_Admin_List_Table $list_table
368
-     * @return void
369
-     * @throws InvalidArgumentException
370
-     * @throws InvalidDataTypeException
371
-     * @throws InvalidInterfaceException
372
-     */
373
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
374
-    {
375
-        if (
376
-            ! EE_Registry::instance()->CAP->current_user_can(
377
-                'ee_send_message',
378
-                'espresso_registrations_newsletter_selected_send'
379
-            )
380
-        ) {
381
-            return;
382
-        }
383
-        $routes_to_add_to = array(
384
-            'contact_list',
385
-            'event_registrations',
386
-            'default',
387
-        );
388
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
389
-            if (
390
-                ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
391
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
392
-            ) {
393
-                echo '';
394
-            } else {
395
-                $button_text = sprintf(
396
-                    esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
397
-                    '<span class="send-selected-newsletter-count">0</span>'
398
-                );
399
-                echo '<button id="selected-batch-send-trigger" class="button button--secondary">'
400
-                     . '<span class="dashicons dashicons-email "></span>'
401
-                     . $button_text
402
-                     . '</button>';
403
-                add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
404
-            }
405
-        }
406
-    }
363
+	/**
364
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
365
+	 *
366
+	 * @since 4.3.0
367
+	 * @param EE_Admin_List_Table $list_table
368
+	 * @return void
369
+	 * @throws InvalidArgumentException
370
+	 * @throws InvalidDataTypeException
371
+	 * @throws InvalidInterfaceException
372
+	 */
373
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
374
+	{
375
+		if (
376
+			! EE_Registry::instance()->CAP->current_user_can(
377
+				'ee_send_message',
378
+				'espresso_registrations_newsletter_selected_send'
379
+			)
380
+		) {
381
+			return;
382
+		}
383
+		$routes_to_add_to = array(
384
+			'contact_list',
385
+			'event_registrations',
386
+			'default',
387
+		);
388
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
389
+			if (
390
+				($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
391
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
392
+			) {
393
+				echo '';
394
+			} else {
395
+				$button_text = sprintf(
396
+					esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
397
+					'<span class="send-selected-newsletter-count">0</span>'
398
+				);
399
+				echo '<button id="selected-batch-send-trigger" class="button button--secondary">'
400
+					 . '<span class="dashicons dashicons-email "></span>'
401
+					 . $button_text
402
+					 . '</button>';
403
+				add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
404
+			}
405
+		}
406
+	}
407 407
 
408 408
 
409
-    /**
410
-     * @throws DomainException
411
-     * @throws EE_Error
412
-     * @throws InvalidArgumentException
413
-     * @throws InvalidDataTypeException
414
-     * @throws InvalidInterfaceException
415
-     */
416
-    public function newsletter_send_form_skeleton()
417
-    {
418
-        $list_table = $this->_list_table_object;
419
-        $codes = array();
420
-        // need to templates for the newsletter message type for the template selector.
421
-        $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
422
-        $mtps = EEM_Message_Template_Group::instance()->get_all(
423
-            array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
424
-        );
425
-        foreach ($mtps as $mtp) {
426
-            $name = $mtp->name();
427
-            $values[] = array(
428
-                'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
429
-                'id'   => $mtp->ID(),
430
-            );
431
-        }
432
-        // need to get a list of shortcodes that are available for the newsletter message type.
433
-        $shortcodes = EEH_MSG_Template::get_shortcodes(
434
-            'newsletter',
435
-            'email',
436
-            array(),
437
-            'attendee',
438
-            false
439
-        );
440
-        foreach ($shortcodes as $field => $shortcode_array) {
441
-            $available_shortcodes = array();
442
-            foreach ($shortcode_array as $shortcode => $shortcode_details) {
443
-                $field_id = $field === '[NEWSLETTER_CONTENT]'
444
-                    ? 'content'
445
-                    : $field;
446
-                $field_id = 'batch-message-' . strtolower($field_id);
447
-                $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
448
-                                          . $shortcode
449
-                                          . '" data-linked-input-id="' . $field_id . '">'
450
-                                          . $shortcode
451
-                                          . '</span>';
452
-            }
453
-            $codes[ $field ] = implode(', ', $available_shortcodes);
454
-        }
455
-        $shortcodes = $codes;
456
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
457
-        $form_template_args = array(
458
-            'form_action'       => admin_url('admin.php?page=espresso_registrations'),
459
-            'form_route'        => 'newsletter_selected_send',
460
-            'form_nonce_name'   => 'newsletter_selected_send_nonce',
461
-            'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
462
-            'redirect_back_to'  => $this->_req_action,
463
-            'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
464
-            'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
465
-            'shortcodes'        => $shortcodes,
466
-            'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
467
-        );
468
-        EEH_Template::display_template($form_template, $form_template_args);
469
-    }
409
+	/**
410
+	 * @throws DomainException
411
+	 * @throws EE_Error
412
+	 * @throws InvalidArgumentException
413
+	 * @throws InvalidDataTypeException
414
+	 * @throws InvalidInterfaceException
415
+	 */
416
+	public function newsletter_send_form_skeleton()
417
+	{
418
+		$list_table = $this->_list_table_object;
419
+		$codes = array();
420
+		// need to templates for the newsletter message type for the template selector.
421
+		$values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
422
+		$mtps = EEM_Message_Template_Group::instance()->get_all(
423
+			array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
424
+		);
425
+		foreach ($mtps as $mtp) {
426
+			$name = $mtp->name();
427
+			$values[] = array(
428
+				'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
429
+				'id'   => $mtp->ID(),
430
+			);
431
+		}
432
+		// need to get a list of shortcodes that are available for the newsletter message type.
433
+		$shortcodes = EEH_MSG_Template::get_shortcodes(
434
+			'newsletter',
435
+			'email',
436
+			array(),
437
+			'attendee',
438
+			false
439
+		);
440
+		foreach ($shortcodes as $field => $shortcode_array) {
441
+			$available_shortcodes = array();
442
+			foreach ($shortcode_array as $shortcode => $shortcode_details) {
443
+				$field_id = $field === '[NEWSLETTER_CONTENT]'
444
+					? 'content'
445
+					: $field;
446
+				$field_id = 'batch-message-' . strtolower($field_id);
447
+				$available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
448
+										  . $shortcode
449
+										  . '" data-linked-input-id="' . $field_id . '">'
450
+										  . $shortcode
451
+										  . '</span>';
452
+			}
453
+			$codes[ $field ] = implode(', ', $available_shortcodes);
454
+		}
455
+		$shortcodes = $codes;
456
+		$form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
457
+		$form_template_args = array(
458
+			'form_action'       => admin_url('admin.php?page=espresso_registrations'),
459
+			'form_route'        => 'newsletter_selected_send',
460
+			'form_nonce_name'   => 'newsletter_selected_send_nonce',
461
+			'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
462
+			'redirect_back_to'  => $this->_req_action,
463
+			'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
464
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
465
+			'shortcodes'        => $shortcodes,
466
+			'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
467
+		);
468
+		EEH_Template::display_template($form_template, $form_template_args);
469
+	}
470 470
 
471 471
 
472
-    /**
473
-     * Handles sending selected registrations/contacts a newsletter.
474
-     *
475
-     * @since  4.3.0
476
-     * @return void
477
-     * @throws EE_Error
478
-     * @throws InvalidArgumentException
479
-     * @throws InvalidDataTypeException
480
-     * @throws InvalidInterfaceException
481
-     */
482
-    protected function _newsletter_selected_send()
483
-    {
484
-        $success = true;
485
-        // first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
486
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
487
-            EE_Error::add_error(
488
-                esc_html__(
489
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
490
-                    'event_espresso'
491
-                ),
492
-                __FILE__,
493
-                __FUNCTION__,
494
-                __LINE__
495
-            );
496
-            $success = false;
497
-        }
498
-        if ($success) {
499
-            // update Message template in case there are any changes
500
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
501
-                $this->_req_data['newsletter_mtp_selected']
502
-            );
503
-            $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
504
-                ? $Message_Template_Group->context_templates()
505
-                : array();
506
-            if (empty($Message_Templates)) {
507
-                EE_Error::add_error(
508
-                    esc_html__(
509
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
510
-                        'event_espresso'
511
-                    ),
512
-                    __FILE__,
513
-                    __FUNCTION__,
514
-                    __LINE__
515
-                );
516
-            }
517
-            // let's just update the specific fields
518
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
519
-                if ($Message_Template instanceof EE_Message_Template) {
520
-                    $field = $Message_Template->get('MTP_template_field');
521
-                    $content = $Message_Template->get('MTP_content');
522
-                    $new_content = $content;
523
-                    switch ($field) {
524
-                        case 'from':
525
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
526
-                                ? $this->_req_data['batch_message']['from']
527
-                                : $content;
528
-                            break;
529
-                        case 'subject':
530
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
531
-                                ? $this->_req_data['batch_message']['subject']
532
-                                : $content;
533
-                            break;
534
-                        case 'content':
535
-                            $new_content = $content;
536
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
537
-                                ? $this->_req_data['batch_message']['content']
538
-                                : $content['newsletter_content'];
539
-                            break;
540
-                        default:
541
-                            // continue the foreach loop, we don't want to set $new_content nor save.
542
-                            continue 2;
543
-                    }
544
-                    $Message_Template->set('MTP_content', $new_content);
545
-                    $Message_Template->save();
546
-                }
547
-            }
548
-            // great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
549
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
550
-                ? $this->_req_data['batch_message']['id_type']
551
-                : 'registration';
552
-            // id_type will affect how we assemble the ids.
553
-            $ids = ! empty($this->_req_data['batch_message']['ids'])
554
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
555
-                : array();
556
-            $registrations_used_for_contact_data = array();
557
-            // using switch because eventually we'll have other contexts that will be used for generating messages.
558
-            switch ($id_type) {
559
-                case 'registration':
560
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
561
-                        array(
562
-                            array(
563
-                                'REG_ID' => array('IN', $ids),
564
-                            ),
565
-                        )
566
-                    );
567
-                    break;
568
-                case 'contact':
569
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
570
-                                                                           ->get_latest_registration_for_each_of_given_contacts(
571
-                                                                               $ids
572
-                                                                           );
573
-                    break;
574
-            }
575
-            do_action_ref_array(
576
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
577
-                array(
578
-                    $registrations_used_for_contact_data,
579
-                    $Message_Template_Group->ID(),
580
-                )
581
-            );
582
-            // kept for backward compat, internally we no longer use this action.
583
-            // @deprecated 4.8.36.rc.002
584
-            $contacts = $id_type === 'registration'
585
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
586
-                : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
587
-            do_action_ref_array(
588
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
589
-                array(
590
-                    $contacts,
591
-                    $Message_Template_Group->ID(),
592
-                )
593
-            );
594
-        }
595
-        $query_args = array(
596
-            'action' => ! empty($this->_req_data['redirect_back_to'])
597
-                ? $this->_req_data['redirect_back_to']
598
-                : 'default',
599
-        );
600
-        $this->_redirect_after_action(false, '', '', $query_args, true);
601
-    }
472
+	/**
473
+	 * Handles sending selected registrations/contacts a newsletter.
474
+	 *
475
+	 * @since  4.3.0
476
+	 * @return void
477
+	 * @throws EE_Error
478
+	 * @throws InvalidArgumentException
479
+	 * @throws InvalidDataTypeException
480
+	 * @throws InvalidInterfaceException
481
+	 */
482
+	protected function _newsletter_selected_send()
483
+	{
484
+		$success = true;
485
+		// first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
486
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
487
+			EE_Error::add_error(
488
+				esc_html__(
489
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
490
+					'event_espresso'
491
+				),
492
+				__FILE__,
493
+				__FUNCTION__,
494
+				__LINE__
495
+			);
496
+			$success = false;
497
+		}
498
+		if ($success) {
499
+			// update Message template in case there are any changes
500
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
501
+				$this->_req_data['newsletter_mtp_selected']
502
+			);
503
+			$Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
504
+				? $Message_Template_Group->context_templates()
505
+				: array();
506
+			if (empty($Message_Templates)) {
507
+				EE_Error::add_error(
508
+					esc_html__(
509
+						'Unable to retrieve message template fields from the db. Messages not sent.',
510
+						'event_espresso'
511
+					),
512
+					__FILE__,
513
+					__FUNCTION__,
514
+					__LINE__
515
+				);
516
+			}
517
+			// let's just update the specific fields
518
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
519
+				if ($Message_Template instanceof EE_Message_Template) {
520
+					$field = $Message_Template->get('MTP_template_field');
521
+					$content = $Message_Template->get('MTP_content');
522
+					$new_content = $content;
523
+					switch ($field) {
524
+						case 'from':
525
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
526
+								? $this->_req_data['batch_message']['from']
527
+								: $content;
528
+							break;
529
+						case 'subject':
530
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
531
+								? $this->_req_data['batch_message']['subject']
532
+								: $content;
533
+							break;
534
+						case 'content':
535
+							$new_content = $content;
536
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
537
+								? $this->_req_data['batch_message']['content']
538
+								: $content['newsletter_content'];
539
+							break;
540
+						default:
541
+							// continue the foreach loop, we don't want to set $new_content nor save.
542
+							continue 2;
543
+					}
544
+					$Message_Template->set('MTP_content', $new_content);
545
+					$Message_Template->save();
546
+				}
547
+			}
548
+			// great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
549
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
550
+				? $this->_req_data['batch_message']['id_type']
551
+				: 'registration';
552
+			// id_type will affect how we assemble the ids.
553
+			$ids = ! empty($this->_req_data['batch_message']['ids'])
554
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
555
+				: array();
556
+			$registrations_used_for_contact_data = array();
557
+			// using switch because eventually we'll have other contexts that will be used for generating messages.
558
+			switch ($id_type) {
559
+				case 'registration':
560
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
561
+						array(
562
+							array(
563
+								'REG_ID' => array('IN', $ids),
564
+							),
565
+						)
566
+					);
567
+					break;
568
+				case 'contact':
569
+					$registrations_used_for_contact_data = EEM_Registration::instance()
570
+																		   ->get_latest_registration_for_each_of_given_contacts(
571
+																			   $ids
572
+																		   );
573
+					break;
574
+			}
575
+			do_action_ref_array(
576
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
577
+				array(
578
+					$registrations_used_for_contact_data,
579
+					$Message_Template_Group->ID(),
580
+				)
581
+			);
582
+			// kept for backward compat, internally we no longer use this action.
583
+			// @deprecated 4.8.36.rc.002
584
+			$contacts = $id_type === 'registration'
585
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
586
+				: EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
587
+			do_action_ref_array(
588
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
589
+				array(
590
+					$contacts,
591
+					$Message_Template_Group->ID(),
592
+				)
593
+			);
594
+		}
595
+		$query_args = array(
596
+			'action' => ! empty($this->_req_data['redirect_back_to'])
597
+				? $this->_req_data['redirect_back_to']
598
+				: 'default',
599
+		);
600
+		$this->_redirect_after_action(false, '', '', $query_args, true);
601
+	}
602 602
 
603 603
 
604
-    /**
605
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
606
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
607
-     */
608
-    protected function _registration_reports_js_setup()
609
-    {
610
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
611
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
612
-    }
604
+	/**
605
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
606
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
607
+	 */
608
+	protected function _registration_reports_js_setup()
609
+	{
610
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
611
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
612
+	}
613 613
 
614 614
 
615
-    /**
616
-     *        generates Business Reports regarding Registrations
617
-     *
618
-     * @access protected
619
-     * @return void
620
-     * @throws DomainException
621
-     */
622
-    protected function _registration_reports()
623
-    {
624
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
625
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
626
-            $template_path,
627
-            $this->_reports_template_data,
628
-            true
629
-        );
630
-        // the final template wrapper
631
-        $this->display_admin_page_with_no_sidebar();
632
-    }
615
+	/**
616
+	 *        generates Business Reports regarding Registrations
617
+	 *
618
+	 * @access protected
619
+	 * @return void
620
+	 * @throws DomainException
621
+	 */
622
+	protected function _registration_reports()
623
+	{
624
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
625
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
626
+			$template_path,
627
+			$this->_reports_template_data,
628
+			true
629
+		);
630
+		// the final template wrapper
631
+		$this->display_admin_page_with_no_sidebar();
632
+	}
633 633
 
634 634
 
635
-    /**
636
-     * Generates Business Report showing total registrations per day.
637
-     *
638
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
639
-     * @return string
640
-     * @throws EE_Error
641
-     * @throws InvalidArgumentException
642
-     * @throws InvalidDataTypeException
643
-     * @throws InvalidInterfaceException
644
-     */
645
-    private function _registrations_per_day_report($period = '-1 month')
646
-    {
647
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
648
-        $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
649
-        $results = (array) $results;
650
-        $regs = array();
651
-        $subtitle = '';
652
-        if ($results) {
653
-            $column_titles = array();
654
-            $tracker = 0;
655
-            foreach ($results as $result) {
656
-                $report_column_values = array();
657
-                foreach ($result as $property_name => $property_value) {
658
-                    $property_value = $property_name === 'Registration_REG_date' ? $property_value
659
-                        : (int) $property_value;
660
-                    $report_column_values[] = $property_value;
661
-                    if ($tracker === 0) {
662
-                        if ($property_name === 'Registration_REG_date') {
663
-                            $column_titles[] = esc_html__(
664
-                                'Date (only days with registrations are shown)',
665
-                                'event_espresso'
666
-                            );
667
-                        } else {
668
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
669
-                        }
670
-                    }
671
-                }
672
-                $tracker++;
673
-                $regs[] = $report_column_values;
674
-            }
675
-            // make sure the column_titles is pushed to the beginning of the array
676
-            array_unshift($regs, $column_titles);
677
-            // setup the date range.
678
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
679
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
680
-            $ending_date = new DateTime("now", $DateTimeZone);
681
-            $subtitle = sprintf(
682
-                wp_strip_all_tags(
683
-                    _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
684
-                ),
685
-                $beginning_date->format('Y-m-d'),
686
-                $ending_date->format('Y-m-d')
687
-            );
688
-        }
689
-        $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso'));
690
-        $report_params = array(
691
-            'title'     => $report_title,
692
-            'subtitle'  => $subtitle,
693
-            'id'        => $report_ID,
694
-            'regs'      => $regs,
695
-            'noResults' => empty($regs),
696
-            'noRegsMsg' => sprintf(
697
-                wp_strip_all_tags(
698
-                    __(
699
-                        '%sThere are currently no registration records in the last month for this report.%s',
700
-                        'event_espresso'
701
-                    )
702
-                ),
703
-                '<h2>' . $report_title . '</h2><p>',
704
-                '</p>'
705
-            ),
706
-        );
707
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
708
-        return $report_ID;
709
-    }
635
+	/**
636
+	 * Generates Business Report showing total registrations per day.
637
+	 *
638
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
639
+	 * @return string
640
+	 * @throws EE_Error
641
+	 * @throws InvalidArgumentException
642
+	 * @throws InvalidDataTypeException
643
+	 * @throws InvalidInterfaceException
644
+	 */
645
+	private function _registrations_per_day_report($period = '-1 month')
646
+	{
647
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
648
+		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
649
+		$results = (array) $results;
650
+		$regs = array();
651
+		$subtitle = '';
652
+		if ($results) {
653
+			$column_titles = array();
654
+			$tracker = 0;
655
+			foreach ($results as $result) {
656
+				$report_column_values = array();
657
+				foreach ($result as $property_name => $property_value) {
658
+					$property_value = $property_name === 'Registration_REG_date' ? $property_value
659
+						: (int) $property_value;
660
+					$report_column_values[] = $property_value;
661
+					if ($tracker === 0) {
662
+						if ($property_name === 'Registration_REG_date') {
663
+							$column_titles[] = esc_html__(
664
+								'Date (only days with registrations are shown)',
665
+								'event_espresso'
666
+							);
667
+						} else {
668
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
669
+						}
670
+					}
671
+				}
672
+				$tracker++;
673
+				$regs[] = $report_column_values;
674
+			}
675
+			// make sure the column_titles is pushed to the beginning of the array
676
+			array_unshift($regs, $column_titles);
677
+			// setup the date range.
678
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
679
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
680
+			$ending_date = new DateTime("now", $DateTimeZone);
681
+			$subtitle = sprintf(
682
+				wp_strip_all_tags(
683
+					_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
684
+				),
685
+				$beginning_date->format('Y-m-d'),
686
+				$ending_date->format('Y-m-d')
687
+			);
688
+		}
689
+		$report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso'));
690
+		$report_params = array(
691
+			'title'     => $report_title,
692
+			'subtitle'  => $subtitle,
693
+			'id'        => $report_ID,
694
+			'regs'      => $regs,
695
+			'noResults' => empty($regs),
696
+			'noRegsMsg' => sprintf(
697
+				wp_strip_all_tags(
698
+					__(
699
+						'%sThere are currently no registration records in the last month for this report.%s',
700
+						'event_espresso'
701
+					)
702
+				),
703
+				'<h2>' . $report_title . '</h2><p>',
704
+				'</p>'
705
+			),
706
+		);
707
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
708
+		return $report_ID;
709
+	}
710 710
 
711 711
 
712
-    /**
713
-     * Generates Business Report showing total registrations per event.
714
-     *
715
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
716
-     * @return string
717
-     * @throws EE_Error
718
-     * @throws InvalidArgumentException
719
-     * @throws InvalidDataTypeException
720
-     * @throws InvalidInterfaceException
721
-     */
722
-    private function _registrations_per_event_report($period = '-1 month')
723
-    {
724
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
725
-        $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
726
-        $results = (array) $results;
727
-        $regs = array();
728
-        $subtitle = '';
729
-        if ($results) {
730
-            $column_titles = array();
731
-            $tracker = 0;
732
-            foreach ($results as $result) {
733
-                $report_column_values = array();
734
-                foreach ($result as $property_name => $property_value) {
735
-                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
736
-                        $property_value,
737
-                        4,
738
-                        '...'
739
-                    ) : (int) $property_value;
740
-                    $report_column_values[] = $property_value;
741
-                    if ($tracker === 0) {
742
-                        if ($property_name === 'Registration_Event') {
743
-                            $column_titles[] = esc_html__('Event', 'event_espresso');
744
-                        } else {
745
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
746
-                        }
747
-                    }
748
-                }
749
-                $tracker++;
750
-                $regs[] = $report_column_values;
751
-            }
752
-            // make sure the column_titles is pushed to the beginning of the array
753
-            array_unshift($regs, $column_titles);
754
-            // setup the date range.
755
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
756
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
757
-            $ending_date = new DateTime("now", $DateTimeZone);
758
-            $subtitle = sprintf(
759
-                wp_strip_all_tags(
760
-                    _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
761
-                ),
762
-                $beginning_date->format('Y-m-d'),
763
-                $ending_date->format('Y-m-d')
764
-            );
765
-        }
766
-        $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso'));
767
-        $report_params = array(
768
-            'title'     => $report_title,
769
-            'subtitle'  => $subtitle,
770
-            'id'        => $report_ID,
771
-            'regs'      => $regs,
772
-            'noResults' => empty($regs),
773
-            'noRegsMsg' => sprintf(
774
-                wp_strip_all_tags(
775
-                    __(
776
-                        '%sThere are currently no registration records in the last month for this report.%s',
777
-                        'event_espresso'
778
-                    )
779
-                ),
780
-                '<h2>' . $report_title . '</h2><p>',
781
-                '</p>'
782
-            ),
783
-        );
784
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
785
-        return $report_ID;
786
-    }
712
+	/**
713
+	 * Generates Business Report showing total registrations per event.
714
+	 *
715
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
716
+	 * @return string
717
+	 * @throws EE_Error
718
+	 * @throws InvalidArgumentException
719
+	 * @throws InvalidDataTypeException
720
+	 * @throws InvalidInterfaceException
721
+	 */
722
+	private function _registrations_per_event_report($period = '-1 month')
723
+	{
724
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
725
+		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
726
+		$results = (array) $results;
727
+		$regs = array();
728
+		$subtitle = '';
729
+		if ($results) {
730
+			$column_titles = array();
731
+			$tracker = 0;
732
+			foreach ($results as $result) {
733
+				$report_column_values = array();
734
+				foreach ($result as $property_name => $property_value) {
735
+					$property_value = $property_name === 'Registration_Event' ? wp_trim_words(
736
+						$property_value,
737
+						4,
738
+						'...'
739
+					) : (int) $property_value;
740
+					$report_column_values[] = $property_value;
741
+					if ($tracker === 0) {
742
+						if ($property_name === 'Registration_Event') {
743
+							$column_titles[] = esc_html__('Event', 'event_espresso');
744
+						} else {
745
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
746
+						}
747
+					}
748
+				}
749
+				$tracker++;
750
+				$regs[] = $report_column_values;
751
+			}
752
+			// make sure the column_titles is pushed to the beginning of the array
753
+			array_unshift($regs, $column_titles);
754
+			// setup the date range.
755
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
756
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
757
+			$ending_date = new DateTime("now", $DateTimeZone);
758
+			$subtitle = sprintf(
759
+				wp_strip_all_tags(
760
+					_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
761
+				),
762
+				$beginning_date->format('Y-m-d'),
763
+				$ending_date->format('Y-m-d')
764
+			);
765
+		}
766
+		$report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso'));
767
+		$report_params = array(
768
+			'title'     => $report_title,
769
+			'subtitle'  => $subtitle,
770
+			'id'        => $report_ID,
771
+			'regs'      => $regs,
772
+			'noResults' => empty($regs),
773
+			'noRegsMsg' => sprintf(
774
+				wp_strip_all_tags(
775
+					__(
776
+						'%sThere are currently no registration records in the last month for this report.%s',
777
+						'event_espresso'
778
+					)
779
+				),
780
+				'<h2>' . $report_title . '</h2><p>',
781
+				'</p>'
782
+			),
783
+		);
784
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
785
+		return $report_ID;
786
+	}
787 787
 
788 788
 
789
-    /**
790
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
791
-     *
792
-     * @access protected
793
-     * @return void
794
-     * @throws EE_Error
795
-     * @throws InvalidArgumentException
796
-     * @throws InvalidDataTypeException
797
-     * @throws InvalidInterfaceException
798
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
799
-     */
800
-    protected function _registration_checkin_list_table()
801
-    {
802
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
803
-        $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
804
-        /** @var EE_Registration $registration */
805
-        $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
806
-        if (! $registration instanceof EE_Registration) {
807
-            throw new EE_Error(
808
-                sprintf(
809
-                    esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
810
-                    $reg_id
811
-                )
812
-            );
813
-        }
814
-        $attendee = $registration->attendee();
815
-        $this->_admin_page_title .= $this->get_action_link_or_button(
816
-            'new_registration',
817
-            'add-registrant',
818
-            array('event_id' => $registration->event_ID()),
819
-            'add-new-h2'
820
-        );
821
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
822
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
823
-        $legend_items = array(
824
-            'checkin'  => array(
825
-                'class' => $checked_in->cssClasses(),
826
-                'desc'  => $checked_in->legendLabel(),
827
-            ),
828
-            'checkout' => array(
829
-                'class' => $checked_out->cssClasses(),
830
-                'desc'  => $checked_out->legendLabel(),
831
-            ),
832
-        );
833
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
834
-        $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
835
-        /** @var EE_Datetime $datetime */
836
-        $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
837
-        $datetime_label = '';
838
-        if ($datetime instanceof EE_Datetime) {
839
-            $datetime_label = $datetime->get_dtt_display_name(true);
840
-            $datetime_label .= ! empty($datetime_label)
841
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
842
-                : $datetime->get_dtt_display_name();
843
-        }
844
-        $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
845
-            ? EE_Admin_Page::add_query_args_and_nonce(
846
-                array(
847
-                    'action'   => 'event_registrations',
848
-                    'event_id' => $registration->event_ID(),
849
-                    'DTT_ID'   => $dtt_id,
850
-                ),
851
-                $this->_admin_base_url
852
-            )
853
-            : '';
854
-        $datetime_link = ! empty($datetime_link)
855
-            ? '<a href="' . $datetime_link . '">'
856
-              . '<span id="checkin-dtt">'
857
-              . $datetime_label
858
-              . '</span></a>'
859
-            : $datetime_label;
860
-        $attendee_name = $attendee instanceof EE_Attendee
861
-            ? $attendee->full_name()
862
-            : '';
863
-        $attendee_link = $attendee instanceof EE_Attendee
864
-            ? $attendee->get_admin_details_link()
865
-            : '';
866
-        $attendee_link = ! empty($attendee_link)
867
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
868
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
869
-              . '<span id="checkin-attendee-name">'
870
-              . $attendee_name
871
-              . '</span></a>'
872
-            : '';
873
-        $event_link = $registration->event() instanceof EE_Event
874
-            ? $registration->event()->get_admin_details_link()
875
-            : '';
876
-        $event_link = ! empty($event_link)
877
-            ? '<a href="' . $event_link . '"'
878
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
879
-              . '<span id="checkin-event-name">'
880
-              . $registration->event_name()
881
-              . '</span>'
882
-              . '</a>'
883
-            : '';
884
-        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
885
-            ? '<h2>' . sprintf(
886
-                esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
887
-                $attendee_link,
888
-                $datetime_link,
889
-                $event_link
890
-            ) . '</h2>'
891
-            : '';
892
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
893
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
894
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
895
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
896
-        $this->display_admin_list_table_page_with_no_sidebar();
897
-    }
789
+	/**
790
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
791
+	 *
792
+	 * @access protected
793
+	 * @return void
794
+	 * @throws EE_Error
795
+	 * @throws InvalidArgumentException
796
+	 * @throws InvalidDataTypeException
797
+	 * @throws InvalidInterfaceException
798
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
799
+	 */
800
+	protected function _registration_checkin_list_table()
801
+	{
802
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
803
+		$reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
804
+		/** @var EE_Registration $registration */
805
+		$registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
806
+		if (! $registration instanceof EE_Registration) {
807
+			throw new EE_Error(
808
+				sprintf(
809
+					esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
810
+					$reg_id
811
+				)
812
+			);
813
+		}
814
+		$attendee = $registration->attendee();
815
+		$this->_admin_page_title .= $this->get_action_link_or_button(
816
+			'new_registration',
817
+			'add-registrant',
818
+			array('event_id' => $registration->event_ID()),
819
+			'add-new-h2'
820
+		);
821
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
822
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
823
+		$legend_items = array(
824
+			'checkin'  => array(
825
+				'class' => $checked_in->cssClasses(),
826
+				'desc'  => $checked_in->legendLabel(),
827
+			),
828
+			'checkout' => array(
829
+				'class' => $checked_out->cssClasses(),
830
+				'desc'  => $checked_out->legendLabel(),
831
+			),
832
+		);
833
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
834
+		$dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
835
+		/** @var EE_Datetime $datetime */
836
+		$datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
837
+		$datetime_label = '';
838
+		if ($datetime instanceof EE_Datetime) {
839
+			$datetime_label = $datetime->get_dtt_display_name(true);
840
+			$datetime_label .= ! empty($datetime_label)
841
+				? ' (' . $datetime->get_dtt_display_name() . ')'
842
+				: $datetime->get_dtt_display_name();
843
+		}
844
+		$datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
845
+			? EE_Admin_Page::add_query_args_and_nonce(
846
+				array(
847
+					'action'   => 'event_registrations',
848
+					'event_id' => $registration->event_ID(),
849
+					'DTT_ID'   => $dtt_id,
850
+				),
851
+				$this->_admin_base_url
852
+			)
853
+			: '';
854
+		$datetime_link = ! empty($datetime_link)
855
+			? '<a href="' . $datetime_link . '">'
856
+			  . '<span id="checkin-dtt">'
857
+			  . $datetime_label
858
+			  . '</span></a>'
859
+			: $datetime_label;
860
+		$attendee_name = $attendee instanceof EE_Attendee
861
+			? $attendee->full_name()
862
+			: '';
863
+		$attendee_link = $attendee instanceof EE_Attendee
864
+			? $attendee->get_admin_details_link()
865
+			: '';
866
+		$attendee_link = ! empty($attendee_link)
867
+			? '<a href="' . $attendee->get_admin_details_link() . '"'
868
+			  . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
869
+			  . '<span id="checkin-attendee-name">'
870
+			  . $attendee_name
871
+			  . '</span></a>'
872
+			: '';
873
+		$event_link = $registration->event() instanceof EE_Event
874
+			? $registration->event()->get_admin_details_link()
875
+			: '';
876
+		$event_link = ! empty($event_link)
877
+			? '<a href="' . $event_link . '"'
878
+			  . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
879
+			  . '<span id="checkin-event-name">'
880
+			  . $registration->event_name()
881
+			  . '</span>'
882
+			  . '</a>'
883
+			: '';
884
+		$this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
885
+			? '<h2>' . sprintf(
886
+				esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
887
+				$attendee_link,
888
+				$datetime_link,
889
+				$event_link
890
+			) . '</h2>'
891
+			: '';
892
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
893
+			? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
894
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
895
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
896
+		$this->display_admin_list_table_page_with_no_sidebar();
897
+	}
898 898
 
899 899
 
900
-    /**
901
-     * toggle the Check-in status for the given registration (coming from ajax)
902
-     *
903
-     * @return void (JSON)
904
-     * @throws EE_Error
905
-     * @throws InvalidArgumentException
906
-     * @throws InvalidDataTypeException
907
-     * @throws InvalidInterfaceException
908
-     */
909
-    public function toggle_checkin_status()
910
-    {
911
-        // first make sure we have the necessary data
912
-        if (! isset($this->_req_data['_regid'])) {
913
-            EE_Error::add_error(
914
-                esc_html__(
915
-                    'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
916
-                    'event_espresso'
917
-                ),
918
-                __FILE__,
919
-                __FUNCTION__,
920
-                __LINE__
921
-            );
922
-            $this->_template_args['success'] = false;
923
-            $this->_template_args['error'] = true;
924
-            $this->_return_json();
925
-        };
926
-        // do a nonce check cause we're not coming in from an normal route here.
927
-        $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
928
-            : '';
929
-        $nonce_ref = 'checkin_nonce';
930
-        $this->_verify_nonce($nonce, $nonce_ref);
931
-        // beautiful! Made it this far so let's get the status.
932
-        $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
933
-        // setup new class to return via ajax
934
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
935
-        $this->_template_args['success'] = true;
936
-        $this->_return_json();
937
-    }
900
+	/**
901
+	 * toggle the Check-in status for the given registration (coming from ajax)
902
+	 *
903
+	 * @return void (JSON)
904
+	 * @throws EE_Error
905
+	 * @throws InvalidArgumentException
906
+	 * @throws InvalidDataTypeException
907
+	 * @throws InvalidInterfaceException
908
+	 */
909
+	public function toggle_checkin_status()
910
+	{
911
+		// first make sure we have the necessary data
912
+		if (! isset($this->_req_data['_regid'])) {
913
+			EE_Error::add_error(
914
+				esc_html__(
915
+					'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
916
+					'event_espresso'
917
+				),
918
+				__FILE__,
919
+				__FUNCTION__,
920
+				__LINE__
921
+			);
922
+			$this->_template_args['success'] = false;
923
+			$this->_template_args['error'] = true;
924
+			$this->_return_json();
925
+		};
926
+		// do a nonce check cause we're not coming in from an normal route here.
927
+		$nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
928
+			: '';
929
+		$nonce_ref = 'checkin_nonce';
930
+		$this->_verify_nonce($nonce, $nonce_ref);
931
+		// beautiful! Made it this far so let's get the status.
932
+		$new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
933
+		// setup new class to return via ajax
934
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
935
+		$this->_template_args['success'] = true;
936
+		$this->_return_json();
937
+	}
938 938
 
939 939
 
940
-    /**
941
-     * handles toggling the checkin status for the registration,
942
-     *
943
-     * @access protected
944
-     * @return int|void
945
-     * @throws EE_Error
946
-     * @throws InvalidArgumentException
947
-     * @throws InvalidDataTypeException
948
-     * @throws InvalidInterfaceException
949
-     */
950
-    protected function _toggle_checkin_status()
951
-    {
952
-        // first let's get the query args out of the way for the redirect
953
-        $query_args = array(
954
-            'action'   => 'event_registrations',
955
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
956
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
957
-        );
958
-        $new_status = false;
959
-        // bulk action check in toggle
960
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
961
-            // cycle thru checkboxes
962
-            while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
963
-                $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
964
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
965
-            }
966
-        } elseif (isset($this->_req_data['_regid'])) {
967
-            // coming from ajax request
968
-            $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
969
-            $query_args['DTT_ID'] = $DTT_ID;
970
-            $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
971
-        } else {
972
-            EE_Error::add_error(
973
-                esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
974
-                __FILE__,
975
-                __FUNCTION__,
976
-                __LINE__
977
-            );
978
-        }
979
-        if (defined('DOING_AJAX')) {
980
-            return $new_status;
981
-        }
982
-        $this->_redirect_after_action(false, '', '', $query_args, true);
983
-    }
940
+	/**
941
+	 * handles toggling the checkin status for the registration,
942
+	 *
943
+	 * @access protected
944
+	 * @return int|void
945
+	 * @throws EE_Error
946
+	 * @throws InvalidArgumentException
947
+	 * @throws InvalidDataTypeException
948
+	 * @throws InvalidInterfaceException
949
+	 */
950
+	protected function _toggle_checkin_status()
951
+	{
952
+		// first let's get the query args out of the way for the redirect
953
+		$query_args = array(
954
+			'action'   => 'event_registrations',
955
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
956
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
957
+		);
958
+		$new_status = false;
959
+		// bulk action check in toggle
960
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
961
+			// cycle thru checkboxes
962
+			while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
963
+				$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
964
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
965
+			}
966
+		} elseif (isset($this->_req_data['_regid'])) {
967
+			// coming from ajax request
968
+			$DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
969
+			$query_args['DTT_ID'] = $DTT_ID;
970
+			$new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
971
+		} else {
972
+			EE_Error::add_error(
973
+				esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
974
+				__FILE__,
975
+				__FUNCTION__,
976
+				__LINE__
977
+			);
978
+		}
979
+		if (defined('DOING_AJAX')) {
980
+			return $new_status;
981
+		}
982
+		$this->_redirect_after_action(false, '', '', $query_args, true);
983
+	}
984 984
 
985 985
 
986
-    /**
987
-     * This is toggles a single Check-in for the given registration and datetime.
988
-     *
989
-     * @param  int $REG_ID The registration we're toggling
990
-     * @param  int $DTT_ID The datetime we're toggling
991
-     * @return int The new status toggled to.
992
-     * @throws EE_Error
993
-     * @throws InvalidArgumentException
994
-     * @throws InvalidDataTypeException
995
-     * @throws InvalidInterfaceException
996
-     */
997
-    private function _toggle_checkin($REG_ID, $DTT_ID)
998
-    {
999
-        /** @var EE_Registration $REG */
1000
-        $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1001
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
1002
-        if ($new_status !== false) {
1003
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
1004
-        } else {
1005
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1006
-            $new_status = false;
1007
-        }
1008
-        return $new_status;
1009
-    }
986
+	/**
987
+	 * This is toggles a single Check-in for the given registration and datetime.
988
+	 *
989
+	 * @param  int $REG_ID The registration we're toggling
990
+	 * @param  int $DTT_ID The datetime we're toggling
991
+	 * @return int The new status toggled to.
992
+	 * @throws EE_Error
993
+	 * @throws InvalidArgumentException
994
+	 * @throws InvalidDataTypeException
995
+	 * @throws InvalidInterfaceException
996
+	 */
997
+	private function _toggle_checkin($REG_ID, $DTT_ID)
998
+	{
999
+		/** @var EE_Registration $REG */
1000
+		$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1001
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
1002
+		if ($new_status !== false) {
1003
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
1004
+		} else {
1005
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1006
+			$new_status = false;
1007
+		}
1008
+		return $new_status;
1009
+	}
1010 1010
 
1011 1011
 
1012
-    /**
1013
-     * Takes care of deleting multiple EE_Checkin table rows
1014
-     *
1015
-     * @access protected
1016
-     * @return void
1017
-     * @throws EE_Error
1018
-     * @throws InvalidArgumentException
1019
-     * @throws InvalidDataTypeException
1020
-     * @throws InvalidInterfaceException
1021
-     */
1022
-    protected function _delete_checkin_rows()
1023
-    {
1024
-        $query_args = array(
1025
-            'action'  => 'registration_checkins',
1026
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1027
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1028
-        );
1029
-        $errors = 0;
1030
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1031
-            while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1032
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1033
-                    $errors++;
1034
-                }
1035
-            }
1036
-        } else {
1037
-            EE_Error::add_error(
1038
-                esc_html__(
1039
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1040
-                    'event_espresso'
1041
-                ),
1042
-                __FILE__,
1043
-                __FUNCTION__,
1044
-                __LINE__
1045
-            );
1046
-            $this->_redirect_after_action(false, '', '', $query_args, true);
1047
-        }
1048
-        if ($errors > 0) {
1049
-            EE_Error::add_error(
1050
-                sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1051
-                __FILE__,
1052
-                __FUNCTION__,
1053
-                __LINE__
1054
-            );
1055
-        } else {
1056
-            EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso'));
1057
-        }
1058
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1059
-    }
1012
+	/**
1013
+	 * Takes care of deleting multiple EE_Checkin table rows
1014
+	 *
1015
+	 * @access protected
1016
+	 * @return void
1017
+	 * @throws EE_Error
1018
+	 * @throws InvalidArgumentException
1019
+	 * @throws InvalidDataTypeException
1020
+	 * @throws InvalidInterfaceException
1021
+	 */
1022
+	protected function _delete_checkin_rows()
1023
+	{
1024
+		$query_args = array(
1025
+			'action'  => 'registration_checkins',
1026
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1027
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1028
+		);
1029
+		$errors = 0;
1030
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1031
+			while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1032
+				if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1033
+					$errors++;
1034
+				}
1035
+			}
1036
+		} else {
1037
+			EE_Error::add_error(
1038
+				esc_html__(
1039
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1040
+					'event_espresso'
1041
+				),
1042
+				__FILE__,
1043
+				__FUNCTION__,
1044
+				__LINE__
1045
+			);
1046
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1047
+		}
1048
+		if ($errors > 0) {
1049
+			EE_Error::add_error(
1050
+				sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1051
+				__FILE__,
1052
+				__FUNCTION__,
1053
+				__LINE__
1054
+			);
1055
+		} else {
1056
+			EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso'));
1057
+		}
1058
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1059
+	}
1060 1060
 
1061 1061
 
1062
-    /**
1063
-     * Deletes a single EE_Checkin row
1064
-     *
1065
-     * @return void
1066
-     * @throws EE_Error
1067
-     * @throws InvalidArgumentException
1068
-     * @throws InvalidDataTypeException
1069
-     * @throws InvalidInterfaceException
1070
-     */
1071
-    protected function _delete_checkin_row()
1072
-    {
1073
-        $query_args = array(
1074
-            'action'  => 'registration_checkins',
1075
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1076
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1077
-        );
1078
-        if (! empty($this->_req_data['CHK_ID'])) {
1079
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1080
-                EE_Error::add_error(
1081
-                    esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1082
-                    __FILE__,
1083
-                    __FUNCTION__,
1084
-                    __LINE__
1085
-                );
1086
-            } else {
1087
-                EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso'));
1088
-            }
1089
-        } else {
1090
-            EE_Error::add_error(
1091
-                esc_html__(
1092
-                    'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1093
-                    'event_espresso'
1094
-                ),
1095
-                __FILE__,
1096
-                __FUNCTION__,
1097
-                __LINE__
1098
-            );
1099
-        }
1100
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1101
-    }
1062
+	/**
1063
+	 * Deletes a single EE_Checkin row
1064
+	 *
1065
+	 * @return void
1066
+	 * @throws EE_Error
1067
+	 * @throws InvalidArgumentException
1068
+	 * @throws InvalidDataTypeException
1069
+	 * @throws InvalidInterfaceException
1070
+	 */
1071
+	protected function _delete_checkin_row()
1072
+	{
1073
+		$query_args = array(
1074
+			'action'  => 'registration_checkins',
1075
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1076
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1077
+		);
1078
+		if (! empty($this->_req_data['CHK_ID'])) {
1079
+			if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1080
+				EE_Error::add_error(
1081
+					esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1082
+					__FILE__,
1083
+					__FUNCTION__,
1084
+					__LINE__
1085
+				);
1086
+			} else {
1087
+				EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso'));
1088
+			}
1089
+		} else {
1090
+			EE_Error::add_error(
1091
+				esc_html__(
1092
+					'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1093
+					'event_espresso'
1094
+				),
1095
+				__FILE__,
1096
+				__FUNCTION__,
1097
+				__LINE__
1098
+			);
1099
+		}
1100
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1101
+	}
1102 1102
 
1103 1103
 
1104
-    /**
1105
-     *        generates HTML for the Event Registrations List Table
1106
-     *
1107
-     * @access protected
1108
-     * @return void
1109
-     * @throws EE_Error
1110
-     * @throws InvalidArgumentException
1111
-     * @throws InvalidDataTypeException
1112
-     * @throws InvalidInterfaceException
1113
-     */
1114
-    protected function _event_registrations_list_table()
1115
-    {
1116
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1117
-        $this->_admin_page_title .= isset($this->_req_data['event_id'])
1118
-            ? $this->get_action_link_or_button(
1119
-                'new_registration',
1120
-                'add-registrant',
1121
-                array('event_id' => $this->_req_data['event_id']),
1122
-                'add-new-h2',
1123
-                '',
1124
-                false
1125
-            )
1126
-            : '';
1127
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1128
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1129
-        $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1130
-        $checkin_invalid = new CheckinStatusDashicon(EE_Checkin::status_invalid);
1131
-        $legend_items = array(
1132
-            'star-icon'        => array(
1133
-                'class' => 'dashicons dashicons-star-filled gold-icon',
1134
-                'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1135
-            ),
1136
-            'checkin'          => array(
1137
-                'class' => $checked_in->cssClasses(),
1138
-                'desc'  => $checked_in->legendLabel(),
1139
-            ),
1140
-            'checkout'         => array(
1141
-                'class' => $checked_out->cssClasses(),
1142
-                'desc'  => $checked_out->legendLabel(),
1143
-            ),
1144
-            'nocheckinrecord'  => array(
1145
-                'class' => $checked_never->cssClasses(),
1146
-                'desc'  => $checked_never->legendLabel(),
1147
-            ),
1148
-            'canNotCheckin'  => array(
1149
-                'class' => $checkin_invalid->cssClasses(),
1150
-                'desc'  => $checkin_invalid->legendLabel(),
1151
-            ),
1152
-            'approved_status'  => array(
1153
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1154
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1155
-            ),
1156
-            'cancelled_status' => array(
1157
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1158
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1159
-            ),
1160
-            'declined_status'  => array(
1161
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1162
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1163
-            ),
1164
-            'not_approved'     => array(
1165
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1166
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1167
-            ),
1168
-            'pending_status'   => array(
1169
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1170
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1171
-            ),
1172
-            'wait_list'        => array(
1173
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1174
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1175
-            ),
1176
-        );
1177
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1178
-        $event_id = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
1179
-        /** @var EE_Event $event */
1180
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
1181
-        $this->_template_args['before_list_table'] = $event instanceof EE_Event
1182
-            ? '<h2>
1104
+	/**
1105
+	 *        generates HTML for the Event Registrations List Table
1106
+	 *
1107
+	 * @access protected
1108
+	 * @return void
1109
+	 * @throws EE_Error
1110
+	 * @throws InvalidArgumentException
1111
+	 * @throws InvalidDataTypeException
1112
+	 * @throws InvalidInterfaceException
1113
+	 */
1114
+	protected function _event_registrations_list_table()
1115
+	{
1116
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1117
+		$this->_admin_page_title .= isset($this->_req_data['event_id'])
1118
+			? $this->get_action_link_or_button(
1119
+				'new_registration',
1120
+				'add-registrant',
1121
+				array('event_id' => $this->_req_data['event_id']),
1122
+				'add-new-h2',
1123
+				'',
1124
+				false
1125
+			)
1126
+			: '';
1127
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1128
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1129
+		$checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1130
+		$checkin_invalid = new CheckinStatusDashicon(EE_Checkin::status_invalid);
1131
+		$legend_items = array(
1132
+			'star-icon'        => array(
1133
+				'class' => 'dashicons dashicons-star-filled gold-icon',
1134
+				'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1135
+			),
1136
+			'checkin'          => array(
1137
+				'class' => $checked_in->cssClasses(),
1138
+				'desc'  => $checked_in->legendLabel(),
1139
+			),
1140
+			'checkout'         => array(
1141
+				'class' => $checked_out->cssClasses(),
1142
+				'desc'  => $checked_out->legendLabel(),
1143
+			),
1144
+			'nocheckinrecord'  => array(
1145
+				'class' => $checked_never->cssClasses(),
1146
+				'desc'  => $checked_never->legendLabel(),
1147
+			),
1148
+			'canNotCheckin'  => array(
1149
+				'class' => $checkin_invalid->cssClasses(),
1150
+				'desc'  => $checkin_invalid->legendLabel(),
1151
+			),
1152
+			'approved_status'  => array(
1153
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1154
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1155
+			),
1156
+			'cancelled_status' => array(
1157
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1158
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1159
+			),
1160
+			'declined_status'  => array(
1161
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1162
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1163
+			),
1164
+			'not_approved'     => array(
1165
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1166
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1167
+			),
1168
+			'pending_status'   => array(
1169
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1170
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1171
+			),
1172
+			'wait_list'        => array(
1173
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1174
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1175
+			),
1176
+		);
1177
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1178
+		$event_id = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
1179
+		/** @var EE_Event $event */
1180
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
1181
+		$this->_template_args['before_list_table'] = $event instanceof EE_Event
1182
+			? '<h2>
1183 1183
                 ' . sprintf(
1184
-                esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1185
-                "<span class='ee-event-name'>{$event->name()}</span>"
1186
-            )
1187
-            : '';
1188
-        // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1189
-        // the event.
1190
-        $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1191
-        $datetime = null;
1192
-        if ($event instanceof EE_Event) {
1193
-            $datetimes_on_event = $event->datetimes();
1194
-            if (count($datetimes_on_event) === 1) {
1195
-                $datetime = reset($datetimes_on_event);
1196
-            }
1197
-        }
1198
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1199
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1200
-            $active_status   = $datetime->get_active_status();
1201
-            $datetime_status =
1202
-                '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' .
1203
-                esc_attr($active_status) . '">'
1204
-                . EEH_Template::pretty_status($active_status, false, 'sentence')
1205
-                . '</span>';
1206
-            $this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">';
1207
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>';
1208
-            $this->_template_args['before_list_table'] .= $datetime->name();
1209
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1210
-            $this->_template_args['before_list_table'] .= $datetime_status;
1211
-            $this->_template_args['before_list_table'] .= '</span>';
1212
-        }
1213
-        $this->_template_args['before_list_table'] .= '</h2>';
1214
-        // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1215
-        // column represents
1216
-        if (! $datetime instanceof EE_Datetime) {
1217
-            $this->_template_args['before_list_table'] .= '<h3 class="description">'
1218
-                                                          . esc_html__(
1219
-                                                              'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1220
-                                                              'event_espresso'
1221
-                                                          )
1222
-                                                          . '</h3>';
1223
-        }
1224
-        $this->display_admin_list_table_page_with_no_sidebar();
1225
-    }
1184
+				esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1185
+				"<span class='ee-event-name'>{$event->name()}</span>"
1186
+			)
1187
+			: '';
1188
+		// need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1189
+		// the event.
1190
+		$DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1191
+		$datetime = null;
1192
+		if ($event instanceof EE_Event) {
1193
+			$datetimes_on_event = $event->datetimes();
1194
+			if (count($datetimes_on_event) === 1) {
1195
+				$datetime = reset($datetimes_on_event);
1196
+			}
1197
+		}
1198
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1199
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1200
+			$active_status   = $datetime->get_active_status();
1201
+			$datetime_status =
1202
+				'<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' .
1203
+				esc_attr($active_status) . '">'
1204
+				. EEH_Template::pretty_status($active_status, false, 'sentence')
1205
+				. '</span>';
1206
+			$this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">';
1207
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>';
1208
+			$this->_template_args['before_list_table'] .= $datetime->name();
1209
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1210
+			$this->_template_args['before_list_table'] .= $datetime_status;
1211
+			$this->_template_args['before_list_table'] .= '</span>';
1212
+		}
1213
+		$this->_template_args['before_list_table'] .= '</h2>';
1214
+		// if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1215
+		// column represents
1216
+		if (! $datetime instanceof EE_Datetime) {
1217
+			$this->_template_args['before_list_table'] .= '<h3 class="description">'
1218
+														  . esc_html__(
1219
+															  'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1220
+															  'event_espresso'
1221
+														  )
1222
+														  . '</h3>';
1223
+		}
1224
+		$this->display_admin_list_table_page_with_no_sidebar();
1225
+	}
1226 1226
 
1227
-    /**
1228
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1229
-     * conditions)
1230
-     *
1231
-     * @return void ends the request by a redirect or download
1232
-     */
1233
-    public function _registrations_checkin_report()
1234
-    {
1235
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1236
-    }
1227
+	/**
1228
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1229
+	 * conditions)
1230
+	 *
1231
+	 * @return void ends the request by a redirect or download
1232
+	 */
1233
+	public function _registrations_checkin_report()
1234
+	{
1235
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1236
+	}
1237 1237
 
1238
-    /**
1239
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1240
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1241
-     *
1242
-     * @param array $request
1243
-     * @param int   $per_page
1244
-     * @param bool  $count
1245
-     * @return array
1246
-     * @throws EE_Error
1247
-     */
1248
-    protected function _get_checkin_query_params_from_request(
1249
-        $request,
1250
-        $per_page = 10,
1251
-        $count = false
1252
-    ) {
1253
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1254
-        // unlike the regular registrations list table,
1255
-        $status_ids_array = apply_filters(
1256
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1257
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1258
-        );
1259
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1260
-        return $query_params;
1261
-    }
1238
+	/**
1239
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1240
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1241
+	 *
1242
+	 * @param array $request
1243
+	 * @param int   $per_page
1244
+	 * @param bool  $count
1245
+	 * @return array
1246
+	 * @throws EE_Error
1247
+	 */
1248
+	protected function _get_checkin_query_params_from_request(
1249
+		$request,
1250
+		$per_page = 10,
1251
+		$count = false
1252
+	) {
1253
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1254
+		// unlike the regular registrations list table,
1255
+		$status_ids_array = apply_filters(
1256
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1257
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1258
+		);
1259
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1260
+		return $query_params;
1261
+	}
1262 1262
 
1263 1263
 
1264
-    /**
1265
-     * Gets registrations for an event
1266
-     *
1267
-     * @param int    $per_page
1268
-     * @param bool   $count whether to return count or data.
1269
-     * @param bool   $trash
1270
-     * @param string $orderby
1271
-     * @return EE_Registration[]|int
1272
-     * @throws EE_Error
1273
-     * @throws InvalidArgumentException
1274
-     * @throws InvalidDataTypeException
1275
-     * @throws InvalidInterfaceException
1276
-     */
1277
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1278
-    {
1279
-        // normalize some request params that get setup by the parent `get_registrations` method.
1280
-        $request = $this->_req_data;
1281
-        $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1282
-        $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1283
-        if ($trash) {
1284
-            $request['status'] = 'trash';
1285
-        }
1286
-        $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1287
-        /**
1288
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1289
-         *
1290
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1291
-         * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1292
-         *                             or if you have the development copy of EE you can view this at the path:
1293
-         *                             /docs/G--Model-System/model-query-params.md
1294
-         */
1295
-        $query_params['group_by'] = '';
1264
+	/**
1265
+	 * Gets registrations for an event
1266
+	 *
1267
+	 * @param int    $per_page
1268
+	 * @param bool   $count whether to return count or data.
1269
+	 * @param bool   $trash
1270
+	 * @param string $orderby
1271
+	 * @return EE_Registration[]|int
1272
+	 * @throws EE_Error
1273
+	 * @throws InvalidArgumentException
1274
+	 * @throws InvalidDataTypeException
1275
+	 * @throws InvalidInterfaceException
1276
+	 */
1277
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1278
+	{
1279
+		// normalize some request params that get setup by the parent `get_registrations` method.
1280
+		$request = $this->_req_data;
1281
+		$request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1282
+		$request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1283
+		if ($trash) {
1284
+			$request['status'] = 'trash';
1285
+		}
1286
+		$query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1287
+		/**
1288
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1289
+		 *
1290
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1291
+		 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1292
+		 *                             or if you have the development copy of EE you can view this at the path:
1293
+		 *                             /docs/G--Model-System/model-query-params.md
1294
+		 */
1295
+		$query_params['group_by'] = '';
1296 1296
 
1297
-        return $count
1298
-            ? EEM_Registration::instance()->count($query_params)
1299
-            /** @type EE_Registration[] */
1300
-            : EEM_Registration::instance()->get_all($query_params);
1301
-    }
1297
+		return $count
1298
+			? EEM_Registration::instance()->count($query_params)
1299
+			/** @type EE_Registration[] */
1300
+			: EEM_Registration::instance()->get_all($query_params);
1301
+	}
1302 1302
 }
Please login to merge, or discard this patch.