Completed
Branch master (df501c)
by
unknown
12:57 queued 10:35
created
admin_pages/general_settings/General_Settings_Admin_Page.core.php 2 patches
Indentation   +1426 added lines, -1426 removed lines patch added patch discarded remove patch
@@ -19,1441 +19,1441 @@
 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
-        $this->core_config = EE_Registry::instance()->CFG->core;
39
-    }
40
-
41
-
42
-    /**
43
-     * Set ajax hooks
44
-     */
45
-    protected function _ajax_hooks()
46
-    {
47
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
48
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
49
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
50
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
51
-    }
52
-
53
-
54
-    /**
55
-     * More page properties initialization.
56
-     */
57
-    protected function _define_page_props()
58
-    {
59
-        $this->_admin_page_title = GEN_SET_LABEL;
60
-        $this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
61
-    }
62
-
63
-
64
-    /**
65
-     * Set page routes property.
66
-     */
67
-    protected function _set_page_routes()
68
-    {
69
-        $this->_page_routes = [
70
-            'critical_pages'                => [
71
-                'func'       => [$this, '_espresso_page_settings'],
72
-                'capability' => 'manage_options',
73
-            ],
74
-            'update_espresso_page_settings' => [
75
-                'func'       => [$this, '_update_espresso_page_settings'],
76
-                'capability' => 'manage_options',
77
-                'noheader'   => true,
78
-            ],
79
-            'default'                       => [
80
-                'func'       => [$this, '_your_organization_settings'],
81
-                'capability' => 'manage_options',
82
-            ],
83
-
84
-            'update_your_organization_settings' => [
85
-                'func'       => [$this, '_update_your_organization_settings'],
86
-                'capability' => 'manage_options',
87
-                'noheader'   => true,
88
-            ],
89
-
90
-            'admin_option_settings' => [
91
-                'func'       => [$this, '_admin_option_settings'],
92
-                'capability' => 'manage_options',
93
-            ],
94
-
95
-            'update_admin_option_settings' => [
96
-                'func'       => [$this, '_update_admin_option_settings'],
97
-                'capability' => 'manage_options',
98
-                'noheader'   => true,
99
-            ],
100
-
101
-            'country_settings' => [
102
-                'func'       => [$this, '_country_settings'],
103
-                'capability' => 'manage_options',
104
-            ],
105
-
106
-            'update_country_settings' => [
107
-                'func'       => [$this, '_update_country_settings'],
108
-                'capability' => 'manage_options',
109
-                'noheader'   => true,
110
-            ],
111
-
112
-            'display_country_settings' => [
113
-                'func'       => [$this, 'display_country_settings'],
114
-                'capability' => 'manage_options',
115
-                'noheader'   => true,
116
-            ],
117
-
118
-            'add_new_state' => [
119
-                'func'       => [$this, 'add_new_state'],
120
-                'capability' => 'manage_options',
121
-                'noheader'   => true,
122
-            ],
123
-
124
-            'delete_state'            => [
125
-                'func'       => [$this, 'delete_state'],
126
-                'capability' => 'manage_options',
127
-                'noheader'   => true,
128
-            ],
129
-            'privacy_settings'        => [
130
-                'func'       => [$this, 'privacySettings'],
131
-                'capability' => 'manage_options',
132
-            ],
133
-            'update_privacy_settings' => [
134
-                'func'               => [$this, 'updatePrivacySettings'],
135
-                'capability'         => 'manage_options',
136
-                'noheader'           => true,
137
-                'headers_sent_route' => 'privacy_settings',
138
-            ],
139
-        ];
140
-    }
141
-
142
-
143
-    /**
144
-     * Set page configuration property
145
-     */
146
-    protected function _set_page_config()
147
-    {
148
-        $this->_page_config = [
149
-            'critical_pages'        => [
150
-                'nav'           => [
151
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
152
-                    'order' => 50,
153
-                ],
154
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
155
-                'help_tabs'     => [
156
-                    'general_settings_critical_pages_help_tab' => [
157
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
158
-                        'filename' => 'general_settings_critical_pages',
159
-                    ],
160
-                ],
161
-                'require_nonce' => false,
162
-            ],
163
-            'default'               => [
164
-                'nav'           => [
165
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
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
-                    'order' => 60,
181
-                ],
182
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
183
-                'help_tabs'     => [
184
-                    'general_settings_admin_options_help_tab' => [
185
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
186
-                        'filename' => 'general_settings_admin_options',
187
-                    ],
188
-                ],
189
-                'require_nonce' => false,
190
-            ],
191
-            'country_settings'      => [
192
-                'nav'           => [
193
-                    'label' => esc_html__('Countries', 'event_espresso'),
194
-                    'order' => 70,
195
-                ],
196
-                'help_tabs'     => [
197
-                    'general_settings_countries_help_tab' => [
198
-                        'title'    => esc_html__('Countries', 'event_espresso'),
199
-                        'filename' => 'general_settings_countries',
200
-                    ],
201
-                ],
202
-                'require_nonce' => false,
203
-            ],
204
-            'privacy_settings'      => [
205
-                'nav'           => [
206
-                    'label' => esc_html__('Privacy', 'event_espresso'),
207
-                    'order' => 80,
208
-                ],
209
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
210
-                'require_nonce' => false,
211
-            ],
212
-        ];
213
-    }
214
-
215
-
216
-    protected function _add_screen_options()
217
-    {
218
-    }
219
-
220
-
221
-    protected function _add_feature_pointers()
222
-    {
223
-    }
224
-
225
-
226
-    /**
227
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
228
-     */
229
-    public function load_scripts_styles()
230
-    {
231
-        // styles
232
-        wp_enqueue_style('espresso-ui-theme');
233
-        // scripts
234
-        wp_enqueue_script('ee_admin_js');
235
-    }
236
-
237
-
238
-    /**
239
-     * Execute logic running on `admin_init`
240
-     */
241
-    public function admin_init()
242
-    {
243
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
244
-            esc_html__(
245
-                '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.',
246
-                'event_espresso'
247
-            )
248
-        );
249
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
250
-            esc_html__(
251
-                'An error occurred! Please refresh the page and try again.',
252
-                'event_espresso'
253
-            )
254
-        );
255
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
256
-            esc_html__(
257
-                'Are you sure you want to delete this State / Province?',
258
-                'event_espresso'
259
-            )
260
-        );
261
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
262
-            'admin-ajax.php?page=espresso_general_settings',
263
-            is_ssl() ? 'https://' : 'http://'
264
-        );
265
-    }
266
-
267
-
268
-    public function admin_notices()
269
-    {
270
-    }
271
-
272
-
273
-    public function admin_footer_scripts()
274
-    {
275
-    }
276
-
277
-
278
-    /**
279
-     * Enqueue scripts and styles for the default route.
280
-     */
281
-    public function load_scripts_styles_default()
282
-    {
283
-        // styles
284
-        wp_enqueue_style('thickbox');
285
-        // scripts
286
-        wp_enqueue_script('media-upload');
287
-        wp_enqueue_script('thickbox');
288
-        wp_register_script(
289
-            'organization_settings',
290
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
291
-            ['jquery', 'media-upload', 'thickbox'],
292
-            EVENT_ESPRESSO_VERSION,
293
-            true
294
-        );
295
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
296
-        wp_enqueue_script('organization_settings');
297
-        wp_enqueue_style('organization-css');
298
-        $confirm_image_delete = [
299
-            'text' => wp_strip_all_tags(
300
-                esc_html__(
301
-                    'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
302
-                    'event_espresso'
303
-                )
304
-            ),
305
-        ];
306
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
-    }
308
-
309
-
310
-    /**
311
-     * Enqueue scripts and styles for the country settings route.
312
-     */
313
-    public function load_scripts_styles_country_settings()
314
-    {
315
-        // scripts
316
-        wp_register_script(
317
-            'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
-            ['ee_admin_js'],
320
-            EVENT_ESPRESSO_VERSION,
321
-            true
322
-        );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
324
-        wp_enqueue_script('gen_settings_countries');
325
-        wp_enqueue_style('organization-css');
326
-    }
327
-
328
-
329
-    /*************        Espresso Pages        *************/
330
-    /**
331
-     * _espresso_page_settings
332
-     *
333
-     * @throws EE_Error
334
-     * @throws DomainException
335
-     * @throws DomainException
336
-     * @throws InvalidDataTypeException
337
-     * @throws InvalidArgumentException
338
-     */
339
-    protected function _espresso_page_settings()
340
-    {
341
-        // Check to make sure all of the main pages are set up properly,
342
-        // if not create the default pages and display an admin notice
343
-        EEH_Activation::verify_default_pages_exist();
344
-        $this->_transient_garbage_collection();
345
-
346
-        $this->_template_args['values'] = $this->_yes_no_values;
347
-
348
-        $this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
349
-        $this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
350
-            ? get_post($this->core_config->reg_page_id)
351
-            : false;
352
-
353
-        $this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
354
-        $this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
355
-            ? get_post($this->core_config->txn_page_id)
356
-            : false;
357
-
358
-        $this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
359
-        $this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
360
-            ? get_post($this->core_config->thank_you_page_id)
361
-            : false;
362
-
363
-        $this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
364
-        $this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
365
-            ? get_post($this->core_config->cancel_page_id)
366
-            : false;
367
-
368
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
369
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
370
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
372
-            $this->_template_args,
373
-            true
374
-        );
375
-        $this->display_admin_page_with_sidebar();
376
-    }
377
-
378
-
379
-    /**
380
-     * Handler for updating espresso page settings.
381
-     *
382
-     * @throws EE_Error
383
-     */
384
-    protected function _update_espresso_page_settings()
385
-    {
386
-        // capture incoming request data && set page IDs
387
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
388
-            'reg_page_id',
389
-            $this->core_config->reg_page_id,
390
-            DataType::INT
391
-        );
392
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
393
-            'txn_page_id',
394
-            $this->core_config->txn_page_id,
395
-            DataType::INT
396
-        );
397
-        $this->core_config->thank_you_page_id = $this->request->getRequestParam(
398
-            'thank_you_page_id',
399
-            $this->core_config->thank_you_page_id,
400
-            DataType::INT
401
-        );
402
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
403
-            'cancel_page_id',
404
-            $this->core_config->cancel_page_id,
405
-            DataType::INT
406
-        );
407
-
408
-        $this->core_config = apply_filters(
409
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
410
-            $this->core_config,
411
-            $this->request->requestParams()
412
-        );
413
-
414
-        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
415
-        $this->_redirect_after_action(
416
-            $this->_update_espresso_configuration(
417
-                $what,
418
-                $this->core_config,
419
-                __FILE__,
420
-                __FUNCTION__,
421
-                __LINE__
422
-            ),
423
-            $what,
424
-            '',
425
-            [
426
-                'action' => 'critical_pages',
427
-            ],
428
-            true
429
-        );
430
-    }
431
-
432
-
433
-    /*************        Your Organization        *************/
434
-
435
-
436
-    /**
437
-     * @throws DomainException
438
-     * @throws EE_Error
439
-     * @throws InvalidArgumentException
440
-     * @throws InvalidDataTypeException
441
-     * @throws InvalidInterfaceException
442
-     */
443
-    protected function _your_organization_settings()
444
-    {
445
-        $this->_template_args['admin_page_content'] = '';
446
-        try {
447
-            /** @var OrganizationSettings $organization_settings_form */
448
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
449
-
450
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
451
-                $organization_settings_form->display(),
452
-                '',
453
-                'padding'
454
-            );
455
-        } catch (Exception $e) {
456
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
457
-        }
458
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
459
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
460
-        $this->display_admin_page_with_sidebar();
461
-    }
462
-
463
-
464
-    /**
465
-     * Handler for updating organization settings.
466
-     *
467
-     * @throws EE_Error
468
-     */
469
-    protected function _update_your_organization_settings()
470
-    {
471
-        try {
472
-            /** @var OrganizationSettings $organization_settings_form */
473
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
474
-
475
-            $success = $organization_settings_form->process($this->request->requestParams());
476
-
477
-            EE_Registry::instance()->CFG = apply_filters(
478
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
479
-                EE_Registry::instance()->CFG
480
-            );
481
-        } catch (Exception $e) {
482
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
483
-            $success = false;
484
-        }
485
-
486
-        if ($success) {
487
-            $success = $this->_update_espresso_configuration(
488
-                esc_html__('Your Organization Settings', 'event_espresso'),
489
-                EE_Registry::instance()->CFG,
490
-                __FILE__,
491
-                __FUNCTION__,
492
-                __LINE__
493
-            );
494
-        }
495
-
496
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
497
-    }
498
-
499
-
500
-
501
-    /*************        Admin Options        *************/
502
-
503
-
504
-    /**
505
-     * _admin_option_settings
506
-     *
507
-     * @throws EE_Error
508
-     * @throws LogicException
509
-     */
510
-    protected function _admin_option_settings()
511
-    {
512
-        $this->_template_args['admin_page_content'] = '';
513
-        try {
514
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
515
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
516
-            $this->_template_args['values'] = $this->_yes_no_values;
517
-            // also need to account for the do_action that was in the old template
518
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
519
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
520
-        } catch (Exception $e) {
521
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
522
-        }
523
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
524
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
525
-        $this->display_admin_page_with_sidebar();
526
-    }
527
-
528
-
529
-    /**
530
-     * _update_admin_option_settings
531
-     *
532
-     * @throws EE_Error
533
-     * @throws InvalidDataTypeException
534
-     * @throws InvalidFormSubmissionException
535
-     * @throws InvalidArgumentException
536
-     * @throws LogicException
537
-     */
538
-    protected function _update_admin_option_settings()
539
-    {
540
-        try {
541
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
542
-            $admin_options_settings_form->process(
543
-                $this->request->getRequestParam(
544
-                    $admin_options_settings_form->slug(),
545
-                    [],
546
-                    DataType::OBJECT, // need to change this to ARRAY after min PHP version gets bumped to 7+
547
-                    true
548
-                )
549
-            );
550
-            EE_Registry::instance()->CFG->admin = apply_filters(
551
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
552
-                EE_Registry::instance()->CFG->admin
553
-            );
554
-        } catch (Exception $e) {
555
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
556
-        }
557
-        $this->_redirect_after_action(
558
-            apply_filters(
559
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
560
-                $this->_update_espresso_configuration(
561
-                    esc_html__('Admin Options', 'event_espresso'),
562
-                    EE_Registry::instance()->CFG->admin,
563
-                    __FILE__,
564
-                    __FUNCTION__,
565
-                    __LINE__
566
-                )
567
-            ),
568
-            esc_html__('Admin Options', 'event_espresso'),
569
-            'updated',
570
-            ['action' => 'admin_option_settings']
571
-        );
572
-    }
573
-
574
-
575
-    /*************        Countries        *************/
576
-
577
-
578
-    /**
579
-     * @param string|null $default
580
-     * @return string
581
-     */
582
-    protected function getCountryISO(?string $default = null): string
583
-    {
584
-        $default = $default ?? $this->getCountryIsoForSite();
585
-        $CNT_ISO = $this->request->getRequestParam('country', $default);
586
-        $CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
587
-        return strtoupper($CNT_ISO);
588
-    }
589
-
590
-
591
-    /**
592
-     * @return string
593
-     */
594
-    protected function getCountryIsoForSite(): string
595
-    {
596
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
597
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
598
-            : 'US';
599
-    }
600
-
601
-
602
-    /**
603
-     * @param string          $CNT_ISO
604
-     * @param EE_Country|null $country
605
-     * @return EE_Base_Class|EE_Country
606
-     * @throws EE_Error
607
-     * @throws InvalidArgumentException
608
-     * @throws InvalidDataTypeException
609
-     * @throws InvalidInterfaceException
610
-     * @throws ReflectionException
611
-     */
612
-    protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
613
-    {
614
-        /** @var EE_Country $country */
615
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
616
-            ? $country
617
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
618
-    }
619
-
620
-
621
-    /**
622
-     * Output Country Settings view.
623
-     *
624
-     * @throws DomainException
625
-     * @throws EE_Error
626
-     * @throws InvalidArgumentException
627
-     * @throws InvalidDataTypeException
628
-     * @throws InvalidInterfaceException
629
-     * @throws ReflectionException
630
-     */
631
-    protected function _country_settings()
632
-    {
633
-        $CNT_ISO = $this->getCountryISO();
634
-
635
-        $this->_template_args['values']    = $this->_yes_no_values;
636
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
637
-            EE_Question::new_instance(
638
-                [
639
-                    'QST_ID'           => 0,
640
-                    'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
641
-                    'QST_system'       => 'admin-country',
642
-                ]
643
-            ),
644
-            EE_Answer::new_instance(
645
-                [
646
-                    'ANS_ID'    => 0,
647
-                    'ANS_value' => $CNT_ISO,
648
-                ]
649
-            ),
650
-            [
651
-                'input_id'       => 'country',
652
-                'input_name'     => 'country',
653
-                'input_prefix'   => '',
654
-                'append_qstn_id' => false,
655
-            ]
656
-        );
657
-
658
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
659
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
660
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
661
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
662
-            $country->ID(),
663
-            $country
664
-        );
665
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
666
-            $country->ID(),
667
-            $country
668
-        );
669
-        $this->_template_args['CNT_name_for_site']        = $country->name();
670
-
671
-        $this->_set_add_edit_form_tags('update_country_settings');
672
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
673
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
674
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
675
-            $this->_template_args,
676
-            true
677
-        );
678
-        $this->display_admin_page_with_no_sidebar();
679
-    }
680
-
681
-
682
-    /**
683
-     * @param string          $CNT_ISO
684
-     * @param EE_Country|null $country
685
-     * @return string
686
-     * @throws DomainException
687
-     * @throws EE_Error
688
-     * @throws InvalidArgumentException
689
-     * @throws InvalidDataTypeException
690
-     * @throws InvalidInterfaceException
691
-     * @throws ReflectionException
692
-     */
693
-    public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
694
-    {
695
-        $CNT_ISO          = $this->getCountryISO($CNT_ISO);
696
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
697
-
698
-        if (! $CNT_ISO) {
699
-            return '';
700
-        }
701
-
702
-        // for ajax
703
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
704
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
705
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
706
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
707
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
708
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
709
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
710
-
711
-        $country_input_types            = [
712
-            'CNT_active'      => [
713
-                'type'             => 'RADIO_BTN',
714
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
715
-                'class'            => '',
716
-                'options'          => $this->_yes_no_values,
717
-                'use_desc_4_label' => true,
718
-            ],
719
-            'CNT_ISO'         => [
720
-                'type'       => 'TEXT',
721
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
722
-                'class'      => 'small-text',
723
-            ],
724
-            'CNT_ISO3'        => [
725
-                'type'       => 'TEXT',
726
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
727
-                'class'      => 'small-text',
728
-            ],
729
-            // 'RGN_ID'          => [
730
-            //     'type'       => 'TEXT',
731
-            //     'input_name' => 'cntry[' . $CNT_ISO . ']',
732
-            //     'class'      => 'ee-input-size--small',
733
-            // ],
734
-            'CNT_name'        => [
735
-                'type'       => 'TEXT',
736
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
737
-                'class'      => 'regular-text',
738
-            ],
739
-            'CNT_cur_code'    => [
740
-                'type'       => 'TEXT',
741
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
742
-                'class'      => 'small-text',
743
-                'disabled'   => $CNT_cur_disabled,
744
-            ],
745
-            'CNT_cur_single'  => [
746
-                'type'       => 'TEXT',
747
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
748
-                'class'      => 'medium-text',
749
-                'disabled'   => $CNT_cur_disabled,
750
-            ],
751
-            'CNT_cur_plural'  => [
752
-                'type'       => 'TEXT',
753
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
754
-                'class'      => 'medium-text',
755
-                'disabled'   => $CNT_cur_disabled,
756
-            ],
757
-            'CNT_cur_sign'    => [
758
-                'type'         => 'TEXT',
759
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
760
-                'class'        => 'small-text',
761
-                'htmlentities' => false,
762
-                'disabled'     => $CNT_cur_disabled,
763
-            ],
764
-            'CNT_cur_sign_b4' => [
765
-                'type'             => 'RADIO_BTN',
766
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
767
-                'class'            => '',
768
-                'options'          => $this->_yes_no_values,
769
-                'use_desc_4_label' => true,
770
-                'disabled'         => $CNT_cur_disabled,
771
-            ],
772
-            'CNT_cur_dec_plc' => [
773
-                'type'       => 'RADIO_BTN',
774
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
775
-                'class'      => '',
776
-                'options'    => [
777
-                    ['id' => 0, 'text' => ''],
778
-                    ['id' => 1, 'text' => ''],
779
-                    ['id' => 2, 'text' => ''],
780
-                    ['id' => 3, 'text' => ''],
781
-                ],
782
-                'disabled'   => $CNT_cur_disabled,
783
-            ],
784
-            'CNT_cur_dec_mrk' => [
785
-                'type'             => 'RADIO_BTN',
786
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
787
-                'class'            => '',
788
-                'options'          => [
789
-                    [
790
-                        'id'   => ',',
791
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
792
-                    ],
793
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
794
-                ],
795
-                'use_desc_4_label' => true,
796
-                'disabled'         => $CNT_cur_disabled,
797
-            ],
798
-            'CNT_cur_thsnds'  => [
799
-                'type'             => 'RADIO_BTN',
800
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
801
-                'class'            => '',
802
-                'options'          => [
803
-                    [
804
-                        'id'   => ',',
805
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
806
-                    ],
807
-                    [
808
-                        'id'   => '.',
809
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
810
-                    ],
811
-                    [
812
-                        'id'   => ' ',
813
-                        'text' => esc_html__('(space)', 'event_espresso'),
814
-                    ],
815
-                    [
816
-                        'id'   => '_',
817
-                        'text' => esc_html__('_ (underscore)', 'event_espresso'),
818
-                    ],
819
-                    [
820
-                        'id'   => "'",
821
-                        'text' => esc_html__("' (apostrophe)", 'event_espresso'),
822
-                    ],
823
-                ],
824
-                'use_desc_4_label' => true,
825
-                'disabled'         => $CNT_cur_disabled,
826
-            ],
827
-            'CNT_tel_code'    => [
828
-                'type'       => 'TEXT',
829
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
830
-                'class'      => 'small-text',
831
-            ],
832
-            'CNT_is_EU'       => [
833
-                'type'             => 'RADIO_BTN',
834
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
835
-                'class'            => '',
836
-                'options'          => $this->_yes_no_values,
837
-                'use_desc_4_label' => true,
838
-            ],
839
-        ];
840
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
841
-            $country,
842
-            $country_input_types
843
-        );
844
-        $country_details_settings       = EEH_Template::display_template(
845
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
846
-            $this->_template_args,
847
-            true
848
-        );
849
-
850
-        if (defined('DOING_AJAX')) {
851
-            $notices = EE_Error::get_notices(false, false, false);
852
-            echo wp_json_encode(
853
-                [
854
-                    'return_data' => $country_details_settings,
855
-                    'success'     => $notices['success'],
856
-                    'errors'      => $notices['errors'],
857
-                ]
858
-            );
859
-            die();
860
-        }
861
-        return $country_details_settings;
862
-    }
863
-
864
-
865
-    /**
866
-     * @param string          $CNT_ISO
867
-     * @param EE_Country|null $country
868
-     * @return string
869
-     * @throws DomainException
870
-     * @throws EE_Error
871
-     * @throws InvalidArgumentException
872
-     * @throws InvalidDataTypeException
873
-     * @throws InvalidInterfaceException
874
-     * @throws ReflectionException
875
-     */
876
-    public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
877
-    {
878
-        $CNT_ISO = $this->getCountryISO($CNT_ISO);
879
-        if (! $CNT_ISO) {
880
-            return '';
881
-        }
882
-        // for ajax
883
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
884
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
885
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
886
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
887
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
888
-        if (empty($states)) {
889
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
890
-            $countrySubRegionDao = $this->loader->getShared(
891
-                'EventEspresso\core\services\address\CountrySubRegionDao'
892
-            );
893
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
894
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
895
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
896
-                    $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
897
-                }
898
-            }
899
-        }
900
-        if (is_array($states)) {
901
-            foreach ($states as $STA_ID => $state) {
902
-                if ($state instanceof EE_State) {
903
-                    $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
904
-                        $state,
905
-                        [
906
-                            'STA_abbrev' => [
907
-                                'type'             => 'TEXT',
908
-                                'label'            => esc_html__('Code', 'event_espresso'),
909
-                                'input_name'       => 'states[' . $STA_ID . ']',
910
-                                'class'            => 'small-text',
911
-                                'add_mobile_label' => true,
912
-                            ],
913
-                            'STA_name'   => [
914
-                                'type'             => 'TEXT',
915
-                                'label'            => esc_html__('Name', 'event_espresso'),
916
-                                'input_name'       => 'states[' . $STA_ID . ']',
917
-                                'class'            => 'regular-text',
918
-                                'add_mobile_label' => true,
919
-                            ],
920
-                            'STA_active' => [
921
-                                'type'             => 'RADIO_BTN',
922
-                                'label'            => esc_html__(
923
-                                    'State Appears in Dropdown Select Lists',
924
-                                    'event_espresso'
925
-                                ),
926
-                                'input_name'       => 'states[' . $STA_ID . ']',
927
-                                'options'          => $this->_yes_no_values,
928
-                                'use_desc_4_label' => true,
929
-                                'add_mobile_label' => true,
930
-                            ],
931
-                        ]
932
-                    );
933
-
934
-                    $delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
935
-                        [
936
-                            'action'     => 'delete_state',
937
-                            'STA_ID'     => $STA_ID,
938
-                            'CNT_ISO'    => $CNT_ISO,
939
-                            'STA_abbrev' => $state->abbrev(),
940
-                        ],
941
-                        GEN_SET_ADMIN_URL
942
-                    );
943
-
944
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
945
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
946
-                }
947
-            }
948
-        } else {
949
-            $this->_template_args['states'] = false;
950
-        }
951
-
952
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
953
-            ['action' => 'add_new_state'],
954
-            GEN_SET_ADMIN_URL
955
-        );
956
-
957
-        $state_details_settings = EEH_Template::display_template(
958
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
959
-            $this->_template_args,
960
-            true
961
-        );
962
-
963
-        if (defined('DOING_AJAX')) {
964
-            $notices = EE_Error::get_notices(false, false, false);
965
-            echo wp_json_encode(
966
-                [
967
-                    'return_data' => $state_details_settings,
968
-                    'success'     => $notices['success'],
969
-                    'errors'      => $notices['errors'],
970
-                ]
971
-            );
972
-            die();
973
-        }
974
-        return $state_details_settings;
975
-    }
976
-
977
-
978
-    /**
979
-     * @return void
980
-     * @throws EE_Error
981
-     * @throws InvalidArgumentException
982
-     * @throws InvalidDataTypeException
983
-     * @throws InvalidInterfaceException
984
-     * @throws ReflectionException
985
-     */
986
-    public function add_new_state()
987
-    {
988
-        $success = true;
989
-        $CNT_ISO = $this->getCountryISO('');
990
-        if (! $CNT_ISO) {
991
-            EE_Error::add_error(
992
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
993
-                __FILE__,
994
-                __FUNCTION__,
995
-                __LINE__
996
-            );
997
-            $success = false;
998
-        }
999
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1000
-        if (! $STA_abbrev) {
1001
-            EE_Error::add_error(
1002
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1003
-                __FILE__,
1004
-                __FUNCTION__,
1005
-                __LINE__
1006
-            );
1007
-            $success = false;
1008
-        }
1009
-        $STA_name = $this->request->getRequestParam('STA_name');
1010
-        if (! $STA_name) {
1011
-            EE_Error::add_error(
1012
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1013
-                __FILE__,
1014
-                __FUNCTION__,
1015
-                __LINE__
1016
-            );
1017
-            $success = false;
1018
-        }
1019
-
1020
-        if ($success) {
1021
-            $cols_n_values = [
1022
-                'CNT_ISO'    => $CNT_ISO,
1023
-                'STA_abbrev' => $STA_abbrev,
1024
-                'STA_name'   => $STA_name,
1025
-                'STA_active' => true,
1026
-            ];
1027
-            $success       = EEM_State::instance()->insert($cols_n_values);
1028
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1029
-        }
1030
-
1031
-        if (defined('DOING_AJAX')) {
1032
-            $notices = EE_Error::get_notices(false, false, false);
1033
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1034
-            die();
1035
-        } else {
1036
-            $this->_redirect_after_action(
1037
-                $success,
1038
-                esc_html__('State', 'event_espresso'),
1039
-                'added',
1040
-                ['action' => 'country_settings']
1041
-            );
1042
-        }
1043
-    }
1044
-
1045
-
1046
-    /**
1047
-     * @return void
1048
-     * @throws EE_Error
1049
-     * @throws InvalidArgumentException
1050
-     * @throws InvalidDataTypeException
1051
-     * @throws InvalidInterfaceException
1052
-     * @throws ReflectionException
1053
-     */
1054
-    public function delete_state()
1055
-    {
1056
-        $CNT_ISO    = $this->getCountryISO();
1057
-        $STA_ID     = $this->request->getRequestParam('STA_ID');
1058
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1059
-
1060
-        if (! $STA_ID) {
1061
-            EE_Error::add_error(
1062
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1063
-                __FILE__,
1064
-                __FUNCTION__,
1065
-                __LINE__
1066
-            );
1067
-            return;
1068
-        }
1069
-
1070
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1071
-        if ($success !== false) {
1072
-            do_action(
1073
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1074
-                $CNT_ISO,
1075
-                $STA_ID,
1076
-                ['STA_abbrev' => $STA_abbrev]
1077
-            );
1078
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1079
-        }
1080
-        if (defined('DOING_AJAX')) {
1081
-            $notices                = EE_Error::get_notices(false);
1082
-            $notices['return_data'] = true;
1083
-            echo wp_json_encode($notices);
1084
-            die();
1085
-        } else {
1086
-            $this->_redirect_after_action(
1087
-                $success,
1088
-                esc_html__('State', 'event_espresso'),
1089
-                'deleted',
1090
-                ['action' => 'country_settings']
1091
-            );
1092
-        }
1093
-    }
1094
-
1095
-
1096
-    /**
1097
-     *        _update_country_settings
1098
-     *
1099
-     * @return void
1100
-     * @throws EE_Error
1101
-     * @throws InvalidArgumentException
1102
-     * @throws InvalidDataTypeException
1103
-     * @throws InvalidInterfaceException
1104
-     * @throws ReflectionException
1105
-     */
1106
-    protected function _update_country_settings()
1107
-    {
1108
-        $CNT_ISO = $this->getCountryISO();
1109
-        if (! $CNT_ISO) {
1110
-            EE_Error::add_error(
1111
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1112
-                __FILE__,
1113
-                __FUNCTION__,
1114
-                __LINE__
1115
-            );
1116
-            return;
1117
-        }
1118
-
1119
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1120
-
1121
-        $cols_n_values                    = [];
1122
-        $cols_n_values['CNT_ISO3']        = strtoupper(
1123
-            $this->request->getRequestParam(
1124
-                "cntry[$CNT_ISO][CNT_ISO3]",
1125
-                $country->ISO3()
1126
-            )
1127
-        );
1128
-        $cols_n_values['CNT_name']        = $this->request->getRequestParam(
1129
-            "cntry[$CNT_ISO][CNT_name]",
1130
-            $country->name()
1131
-        );
1132
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1133
-            $this->request->getRequestParam(
1134
-                "cntry[$CNT_ISO][CNT_cur_code]",
1135
-                $country->currency_code()
1136
-            )
1137
-        );
1138
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1139
-            "cntry[$CNT_ISO][CNT_cur_single]",
1140
-            $country->currency_name_single()
1141
-        );
1142
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1143
-            "cntry[$CNT_ISO][CNT_cur_plural]",
1144
-            $country->currency_name_plural()
1145
-        );
1146
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1147
-            "cntry[$CNT_ISO][CNT_cur_sign]",
1148
-            $country->currency_sign()
1149
-        );
1150
-        $cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1151
-            "cntry[$CNT_ISO][CNT_cur_sign_b4]",
1152
-            $country->currency_sign_before(),
1153
-            DataType::BOOL
1154
-        );
1155
-        $cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1156
-            "cntry[$CNT_ISO][CNT_cur_dec_plc]",
1157
-            $country->currency_decimal_places()
1158
-        );
1159
-        $cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1160
-            "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1161
-            $country->currency_decimal_mark()
1162
-        );
1163
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1164
-            "cntry[$CNT_ISO][CNT_cur_thsnds]",
1165
-            $country->currency_thousands_separator()
1166
-        );
1167
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1168
-            "cntry[$CNT_ISO][CNT_tel_code]",
1169
-            $country->telephoneCode()
1170
-        );
1171
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1172
-            "cntry[$CNT_ISO][CNT_active]",
1173
-            $country->isActive(),
1174
-            DataType::BOOL
1175
-        );
1176
-
1177
-        // allow filtering of country data
1178
-        $cols_n_values = apply_filters(
1179
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1180
-            $cols_n_values
1181
-        );
1182
-
1183
-        // where values
1184
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1185
-        // run the update
1186
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1187
-
1188
-        // allow filtering of states data
1189
-        $states = apply_filters(
1190
-            'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1191
-            $this->request->getRequestParam('states', [], DataType::STRING, true)
1192
-        );
1193
-
1194
-        if (! empty($states) && $success !== false) {
1195
-            // loop thru state data ( looks like : states[75][STA_name] )
1196
-            foreach ($states as $STA_ID => $state) {
1197
-                $cols_n_values = [
1198
-                    'CNT_ISO'    => $CNT_ISO,
1199
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1200
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1201
-                    'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1202
-                ];
1203
-                // where values
1204
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1205
-                // run the update
1206
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1207
-                if ($success !== false) {
1208
-                    do_action(
1209
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1210
-                        $CNT_ISO,
1211
-                        $STA_ID,
1212
-                        $cols_n_values
1213
-                    );
1214
-                }
1215
-            }
1216
-        }
1217
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1218
-        if (
1219
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1220
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1221
-        ) {
1222
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1223
-            EE_Registry::instance()->CFG->update_espresso_config();
1224
-        }
1225
-
1226
-        if ($success !== false) {
1227
-            EE_Error::add_success(
1228
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1229
-            );
1230
-        }
1231
-        $this->_redirect_after_action(
1232
-            $success,
1233
-            '',
1234
-            '',
1235
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1236
-            true
1237
-        );
1238
-    }
1239
-
1240
-
1241
-    /**
1242
-     * form_form_field_label_wrap
1243
-     *
1244
-     * @param string $label
1245
-     * @return string
1246
-     */
1247
-    public function country_form_field_label_wrap(string $label): string
1248
-    {
1249
-        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
+		$this->core_config = EE_Registry::instance()->CFG->core;
39
+	}
40
+
41
+
42
+	/**
43
+	 * Set ajax hooks
44
+	 */
45
+	protected function _ajax_hooks()
46
+	{
47
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
48
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
49
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
50
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
51
+	}
52
+
53
+
54
+	/**
55
+	 * More page properties initialization.
56
+	 */
57
+	protected function _define_page_props()
58
+	{
59
+		$this->_admin_page_title = GEN_SET_LABEL;
60
+		$this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
61
+	}
62
+
63
+
64
+	/**
65
+	 * Set page routes property.
66
+	 */
67
+	protected function _set_page_routes()
68
+	{
69
+		$this->_page_routes = [
70
+			'critical_pages'                => [
71
+				'func'       => [$this, '_espresso_page_settings'],
72
+				'capability' => 'manage_options',
73
+			],
74
+			'update_espresso_page_settings' => [
75
+				'func'       => [$this, '_update_espresso_page_settings'],
76
+				'capability' => 'manage_options',
77
+				'noheader'   => true,
78
+			],
79
+			'default'                       => [
80
+				'func'       => [$this, '_your_organization_settings'],
81
+				'capability' => 'manage_options',
82
+			],
83
+
84
+			'update_your_organization_settings' => [
85
+				'func'       => [$this, '_update_your_organization_settings'],
86
+				'capability' => 'manage_options',
87
+				'noheader'   => true,
88
+			],
89
+
90
+			'admin_option_settings' => [
91
+				'func'       => [$this, '_admin_option_settings'],
92
+				'capability' => 'manage_options',
93
+			],
94
+
95
+			'update_admin_option_settings' => [
96
+				'func'       => [$this, '_update_admin_option_settings'],
97
+				'capability' => 'manage_options',
98
+				'noheader'   => true,
99
+			],
100
+
101
+			'country_settings' => [
102
+				'func'       => [$this, '_country_settings'],
103
+				'capability' => 'manage_options',
104
+			],
105
+
106
+			'update_country_settings' => [
107
+				'func'       => [$this, '_update_country_settings'],
108
+				'capability' => 'manage_options',
109
+				'noheader'   => true,
110
+			],
111
+
112
+			'display_country_settings' => [
113
+				'func'       => [$this, 'display_country_settings'],
114
+				'capability' => 'manage_options',
115
+				'noheader'   => true,
116
+			],
117
+
118
+			'add_new_state' => [
119
+				'func'       => [$this, 'add_new_state'],
120
+				'capability' => 'manage_options',
121
+				'noheader'   => true,
122
+			],
123
+
124
+			'delete_state'            => [
125
+				'func'       => [$this, 'delete_state'],
126
+				'capability' => 'manage_options',
127
+				'noheader'   => true,
128
+			],
129
+			'privacy_settings'        => [
130
+				'func'       => [$this, 'privacySettings'],
131
+				'capability' => 'manage_options',
132
+			],
133
+			'update_privacy_settings' => [
134
+				'func'               => [$this, 'updatePrivacySettings'],
135
+				'capability'         => 'manage_options',
136
+				'noheader'           => true,
137
+				'headers_sent_route' => 'privacy_settings',
138
+			],
139
+		];
140
+	}
141
+
142
+
143
+	/**
144
+	 * Set page configuration property
145
+	 */
146
+	protected function _set_page_config()
147
+	{
148
+		$this->_page_config = [
149
+			'critical_pages'        => [
150
+				'nav'           => [
151
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
152
+					'order' => 50,
153
+				],
154
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
155
+				'help_tabs'     => [
156
+					'general_settings_critical_pages_help_tab' => [
157
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
158
+						'filename' => 'general_settings_critical_pages',
159
+					],
160
+				],
161
+				'require_nonce' => false,
162
+			],
163
+			'default'               => [
164
+				'nav'           => [
165
+					'label' => esc_html__('Your Organization', 'event_espresso'),
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
+					'order' => 60,
181
+				],
182
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
183
+				'help_tabs'     => [
184
+					'general_settings_admin_options_help_tab' => [
185
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
186
+						'filename' => 'general_settings_admin_options',
187
+					],
188
+				],
189
+				'require_nonce' => false,
190
+			],
191
+			'country_settings'      => [
192
+				'nav'           => [
193
+					'label' => esc_html__('Countries', 'event_espresso'),
194
+					'order' => 70,
195
+				],
196
+				'help_tabs'     => [
197
+					'general_settings_countries_help_tab' => [
198
+						'title'    => esc_html__('Countries', 'event_espresso'),
199
+						'filename' => 'general_settings_countries',
200
+					],
201
+				],
202
+				'require_nonce' => false,
203
+			],
204
+			'privacy_settings'      => [
205
+				'nav'           => [
206
+					'label' => esc_html__('Privacy', 'event_espresso'),
207
+					'order' => 80,
208
+				],
209
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
210
+				'require_nonce' => false,
211
+			],
212
+		];
213
+	}
214
+
215
+
216
+	protected function _add_screen_options()
217
+	{
218
+	}
219
+
220
+
221
+	protected function _add_feature_pointers()
222
+	{
223
+	}
224
+
225
+
226
+	/**
227
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
228
+	 */
229
+	public function load_scripts_styles()
230
+	{
231
+		// styles
232
+		wp_enqueue_style('espresso-ui-theme');
233
+		// scripts
234
+		wp_enqueue_script('ee_admin_js');
235
+	}
236
+
237
+
238
+	/**
239
+	 * Execute logic running on `admin_init`
240
+	 */
241
+	public function admin_init()
242
+	{
243
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
244
+			esc_html__(
245
+				'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.',
246
+				'event_espresso'
247
+			)
248
+		);
249
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
250
+			esc_html__(
251
+				'An error occurred! Please refresh the page and try again.',
252
+				'event_espresso'
253
+			)
254
+		);
255
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
256
+			esc_html__(
257
+				'Are you sure you want to delete this State / Province?',
258
+				'event_espresso'
259
+			)
260
+		);
261
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
262
+			'admin-ajax.php?page=espresso_general_settings',
263
+			is_ssl() ? 'https://' : 'http://'
264
+		);
265
+	}
266
+
267
+
268
+	public function admin_notices()
269
+	{
270
+	}
271
+
272
+
273
+	public function admin_footer_scripts()
274
+	{
275
+	}
276
+
277
+
278
+	/**
279
+	 * Enqueue scripts and styles for the default route.
280
+	 */
281
+	public function load_scripts_styles_default()
282
+	{
283
+		// styles
284
+		wp_enqueue_style('thickbox');
285
+		// scripts
286
+		wp_enqueue_script('media-upload');
287
+		wp_enqueue_script('thickbox');
288
+		wp_register_script(
289
+			'organization_settings',
290
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
291
+			['jquery', 'media-upload', 'thickbox'],
292
+			EVENT_ESPRESSO_VERSION,
293
+			true
294
+		);
295
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
296
+		wp_enqueue_script('organization_settings');
297
+		wp_enqueue_style('organization-css');
298
+		$confirm_image_delete = [
299
+			'text' => wp_strip_all_tags(
300
+				esc_html__(
301
+					'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
302
+					'event_espresso'
303
+				)
304
+			),
305
+		];
306
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
+	}
308
+
309
+
310
+	/**
311
+	 * Enqueue scripts and styles for the country settings route.
312
+	 */
313
+	public function load_scripts_styles_country_settings()
314
+	{
315
+		// scripts
316
+		wp_register_script(
317
+			'gen_settings_countries',
318
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
+			['ee_admin_js'],
320
+			EVENT_ESPRESSO_VERSION,
321
+			true
322
+		);
323
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
324
+		wp_enqueue_script('gen_settings_countries');
325
+		wp_enqueue_style('organization-css');
326
+	}
327
+
328
+
329
+	/*************        Espresso Pages        *************/
330
+	/**
331
+	 * _espresso_page_settings
332
+	 *
333
+	 * @throws EE_Error
334
+	 * @throws DomainException
335
+	 * @throws DomainException
336
+	 * @throws InvalidDataTypeException
337
+	 * @throws InvalidArgumentException
338
+	 */
339
+	protected function _espresso_page_settings()
340
+	{
341
+		// Check to make sure all of the main pages are set up properly,
342
+		// if not create the default pages and display an admin notice
343
+		EEH_Activation::verify_default_pages_exist();
344
+		$this->_transient_garbage_collection();
345
+
346
+		$this->_template_args['values'] = $this->_yes_no_values;
347
+
348
+		$this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
349
+		$this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
350
+			? get_post($this->core_config->reg_page_id)
351
+			: false;
352
+
353
+		$this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
354
+		$this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
355
+			? get_post($this->core_config->txn_page_id)
356
+			: false;
357
+
358
+		$this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
359
+		$this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
360
+			? get_post($this->core_config->thank_you_page_id)
361
+			: false;
362
+
363
+		$this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
364
+		$this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
365
+			? get_post($this->core_config->cancel_page_id)
366
+			: false;
367
+
368
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
369
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
370
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
372
+			$this->_template_args,
373
+			true
374
+		);
375
+		$this->display_admin_page_with_sidebar();
376
+	}
377
+
378
+
379
+	/**
380
+	 * Handler for updating espresso page settings.
381
+	 *
382
+	 * @throws EE_Error
383
+	 */
384
+	protected function _update_espresso_page_settings()
385
+	{
386
+		// capture incoming request data && set page IDs
387
+		$this->core_config->reg_page_id       = $this->request->getRequestParam(
388
+			'reg_page_id',
389
+			$this->core_config->reg_page_id,
390
+			DataType::INT
391
+		);
392
+		$this->core_config->txn_page_id       = $this->request->getRequestParam(
393
+			'txn_page_id',
394
+			$this->core_config->txn_page_id,
395
+			DataType::INT
396
+		);
397
+		$this->core_config->thank_you_page_id = $this->request->getRequestParam(
398
+			'thank_you_page_id',
399
+			$this->core_config->thank_you_page_id,
400
+			DataType::INT
401
+		);
402
+		$this->core_config->cancel_page_id    = $this->request->getRequestParam(
403
+			'cancel_page_id',
404
+			$this->core_config->cancel_page_id,
405
+			DataType::INT
406
+		);
407
+
408
+		$this->core_config = apply_filters(
409
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
410
+			$this->core_config,
411
+			$this->request->requestParams()
412
+		);
413
+
414
+		$what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
415
+		$this->_redirect_after_action(
416
+			$this->_update_espresso_configuration(
417
+				$what,
418
+				$this->core_config,
419
+				__FILE__,
420
+				__FUNCTION__,
421
+				__LINE__
422
+			),
423
+			$what,
424
+			'',
425
+			[
426
+				'action' => 'critical_pages',
427
+			],
428
+			true
429
+		);
430
+	}
431
+
432
+
433
+	/*************        Your Organization        *************/
434
+
435
+
436
+	/**
437
+	 * @throws DomainException
438
+	 * @throws EE_Error
439
+	 * @throws InvalidArgumentException
440
+	 * @throws InvalidDataTypeException
441
+	 * @throws InvalidInterfaceException
442
+	 */
443
+	protected function _your_organization_settings()
444
+	{
445
+		$this->_template_args['admin_page_content'] = '';
446
+		try {
447
+			/** @var OrganizationSettings $organization_settings_form */
448
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
449
+
450
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
451
+				$organization_settings_form->display(),
452
+				'',
453
+				'padding'
454
+			);
455
+		} catch (Exception $e) {
456
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
457
+		}
458
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
459
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
460
+		$this->display_admin_page_with_sidebar();
461
+	}
462
+
463
+
464
+	/**
465
+	 * Handler for updating organization settings.
466
+	 *
467
+	 * @throws EE_Error
468
+	 */
469
+	protected function _update_your_organization_settings()
470
+	{
471
+		try {
472
+			/** @var OrganizationSettings $organization_settings_form */
473
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
474
+
475
+			$success = $organization_settings_form->process($this->request->requestParams());
476
+
477
+			EE_Registry::instance()->CFG = apply_filters(
478
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
479
+				EE_Registry::instance()->CFG
480
+			);
481
+		} catch (Exception $e) {
482
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
483
+			$success = false;
484
+		}
485
+
486
+		if ($success) {
487
+			$success = $this->_update_espresso_configuration(
488
+				esc_html__('Your Organization Settings', 'event_espresso'),
489
+				EE_Registry::instance()->CFG,
490
+				__FILE__,
491
+				__FUNCTION__,
492
+				__LINE__
493
+			);
494
+		}
495
+
496
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
497
+	}
498
+
499
+
500
+
501
+	/*************        Admin Options        *************/
502
+
503
+
504
+	/**
505
+	 * _admin_option_settings
506
+	 *
507
+	 * @throws EE_Error
508
+	 * @throws LogicException
509
+	 */
510
+	protected function _admin_option_settings()
511
+	{
512
+		$this->_template_args['admin_page_content'] = '';
513
+		try {
514
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
515
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
516
+			$this->_template_args['values'] = $this->_yes_no_values;
517
+			// also need to account for the do_action that was in the old template
518
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
519
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
520
+		} catch (Exception $e) {
521
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
522
+		}
523
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
524
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
525
+		$this->display_admin_page_with_sidebar();
526
+	}
527
+
528
+
529
+	/**
530
+	 * _update_admin_option_settings
531
+	 *
532
+	 * @throws EE_Error
533
+	 * @throws InvalidDataTypeException
534
+	 * @throws InvalidFormSubmissionException
535
+	 * @throws InvalidArgumentException
536
+	 * @throws LogicException
537
+	 */
538
+	protected function _update_admin_option_settings()
539
+	{
540
+		try {
541
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
542
+			$admin_options_settings_form->process(
543
+				$this->request->getRequestParam(
544
+					$admin_options_settings_form->slug(),
545
+					[],
546
+					DataType::OBJECT, // need to change this to ARRAY after min PHP version gets bumped to 7+
547
+					true
548
+				)
549
+			);
550
+			EE_Registry::instance()->CFG->admin = apply_filters(
551
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
552
+				EE_Registry::instance()->CFG->admin
553
+			);
554
+		} catch (Exception $e) {
555
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
556
+		}
557
+		$this->_redirect_after_action(
558
+			apply_filters(
559
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
560
+				$this->_update_espresso_configuration(
561
+					esc_html__('Admin Options', 'event_espresso'),
562
+					EE_Registry::instance()->CFG->admin,
563
+					__FILE__,
564
+					__FUNCTION__,
565
+					__LINE__
566
+				)
567
+			),
568
+			esc_html__('Admin Options', 'event_espresso'),
569
+			'updated',
570
+			['action' => 'admin_option_settings']
571
+		);
572
+	}
573
+
574
+
575
+	/*************        Countries        *************/
576
+
577
+
578
+	/**
579
+	 * @param string|null $default
580
+	 * @return string
581
+	 */
582
+	protected function getCountryISO(?string $default = null): string
583
+	{
584
+		$default = $default ?? $this->getCountryIsoForSite();
585
+		$CNT_ISO = $this->request->getRequestParam('country', $default);
586
+		$CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
587
+		return strtoupper($CNT_ISO);
588
+	}
589
+
590
+
591
+	/**
592
+	 * @return string
593
+	 */
594
+	protected function getCountryIsoForSite(): string
595
+	{
596
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
597
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
598
+			: 'US';
599
+	}
600
+
601
+
602
+	/**
603
+	 * @param string          $CNT_ISO
604
+	 * @param EE_Country|null $country
605
+	 * @return EE_Base_Class|EE_Country
606
+	 * @throws EE_Error
607
+	 * @throws InvalidArgumentException
608
+	 * @throws InvalidDataTypeException
609
+	 * @throws InvalidInterfaceException
610
+	 * @throws ReflectionException
611
+	 */
612
+	protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
613
+	{
614
+		/** @var EE_Country $country */
615
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
616
+			? $country
617
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
618
+	}
619
+
620
+
621
+	/**
622
+	 * Output Country Settings view.
623
+	 *
624
+	 * @throws DomainException
625
+	 * @throws EE_Error
626
+	 * @throws InvalidArgumentException
627
+	 * @throws InvalidDataTypeException
628
+	 * @throws InvalidInterfaceException
629
+	 * @throws ReflectionException
630
+	 */
631
+	protected function _country_settings()
632
+	{
633
+		$CNT_ISO = $this->getCountryISO();
634
+
635
+		$this->_template_args['values']    = $this->_yes_no_values;
636
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
637
+			EE_Question::new_instance(
638
+				[
639
+					'QST_ID'           => 0,
640
+					'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
641
+					'QST_system'       => 'admin-country',
642
+				]
643
+			),
644
+			EE_Answer::new_instance(
645
+				[
646
+					'ANS_ID'    => 0,
647
+					'ANS_value' => $CNT_ISO,
648
+				]
649
+			),
650
+			[
651
+				'input_id'       => 'country',
652
+				'input_name'     => 'country',
653
+				'input_prefix'   => '',
654
+				'append_qstn_id' => false,
655
+			]
656
+		);
657
+
658
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
659
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
660
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
661
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
662
+			$country->ID(),
663
+			$country
664
+		);
665
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
666
+			$country->ID(),
667
+			$country
668
+		);
669
+		$this->_template_args['CNT_name_for_site']        = $country->name();
670
+
671
+		$this->_set_add_edit_form_tags('update_country_settings');
672
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
673
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
674
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
675
+			$this->_template_args,
676
+			true
677
+		);
678
+		$this->display_admin_page_with_no_sidebar();
679
+	}
680
+
681
+
682
+	/**
683
+	 * @param string          $CNT_ISO
684
+	 * @param EE_Country|null $country
685
+	 * @return string
686
+	 * @throws DomainException
687
+	 * @throws EE_Error
688
+	 * @throws InvalidArgumentException
689
+	 * @throws InvalidDataTypeException
690
+	 * @throws InvalidInterfaceException
691
+	 * @throws ReflectionException
692
+	 */
693
+	public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
694
+	{
695
+		$CNT_ISO          = $this->getCountryISO($CNT_ISO);
696
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
697
+
698
+		if (! $CNT_ISO) {
699
+			return '';
700
+		}
701
+
702
+		// for ajax
703
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
704
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
705
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
706
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
707
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
708
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
709
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
710
+
711
+		$country_input_types            = [
712
+			'CNT_active'      => [
713
+				'type'             => 'RADIO_BTN',
714
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
715
+				'class'            => '',
716
+				'options'          => $this->_yes_no_values,
717
+				'use_desc_4_label' => true,
718
+			],
719
+			'CNT_ISO'         => [
720
+				'type'       => 'TEXT',
721
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
722
+				'class'      => 'small-text',
723
+			],
724
+			'CNT_ISO3'        => [
725
+				'type'       => 'TEXT',
726
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
727
+				'class'      => 'small-text',
728
+			],
729
+			// 'RGN_ID'          => [
730
+			//     'type'       => 'TEXT',
731
+			//     'input_name' => 'cntry[' . $CNT_ISO . ']',
732
+			//     'class'      => 'ee-input-size--small',
733
+			// ],
734
+			'CNT_name'        => [
735
+				'type'       => 'TEXT',
736
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
737
+				'class'      => 'regular-text',
738
+			],
739
+			'CNT_cur_code'    => [
740
+				'type'       => 'TEXT',
741
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
742
+				'class'      => 'small-text',
743
+				'disabled'   => $CNT_cur_disabled,
744
+			],
745
+			'CNT_cur_single'  => [
746
+				'type'       => 'TEXT',
747
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
748
+				'class'      => 'medium-text',
749
+				'disabled'   => $CNT_cur_disabled,
750
+			],
751
+			'CNT_cur_plural'  => [
752
+				'type'       => 'TEXT',
753
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
754
+				'class'      => 'medium-text',
755
+				'disabled'   => $CNT_cur_disabled,
756
+			],
757
+			'CNT_cur_sign'    => [
758
+				'type'         => 'TEXT',
759
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
760
+				'class'        => 'small-text',
761
+				'htmlentities' => false,
762
+				'disabled'     => $CNT_cur_disabled,
763
+			],
764
+			'CNT_cur_sign_b4' => [
765
+				'type'             => 'RADIO_BTN',
766
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
767
+				'class'            => '',
768
+				'options'          => $this->_yes_no_values,
769
+				'use_desc_4_label' => true,
770
+				'disabled'         => $CNT_cur_disabled,
771
+			],
772
+			'CNT_cur_dec_plc' => [
773
+				'type'       => 'RADIO_BTN',
774
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
775
+				'class'      => '',
776
+				'options'    => [
777
+					['id' => 0, 'text' => ''],
778
+					['id' => 1, 'text' => ''],
779
+					['id' => 2, 'text' => ''],
780
+					['id' => 3, 'text' => ''],
781
+				],
782
+				'disabled'   => $CNT_cur_disabled,
783
+			],
784
+			'CNT_cur_dec_mrk' => [
785
+				'type'             => 'RADIO_BTN',
786
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
787
+				'class'            => '',
788
+				'options'          => [
789
+					[
790
+						'id'   => ',',
791
+						'text' => esc_html__(', (comma)', 'event_espresso'),
792
+					],
793
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
794
+				],
795
+				'use_desc_4_label' => true,
796
+				'disabled'         => $CNT_cur_disabled,
797
+			],
798
+			'CNT_cur_thsnds'  => [
799
+				'type'             => 'RADIO_BTN',
800
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
801
+				'class'            => '',
802
+				'options'          => [
803
+					[
804
+						'id'   => ',',
805
+						'text' => esc_html__(', (comma)', 'event_espresso'),
806
+					],
807
+					[
808
+						'id'   => '.',
809
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
810
+					],
811
+					[
812
+						'id'   => ' ',
813
+						'text' => esc_html__('(space)', 'event_espresso'),
814
+					],
815
+					[
816
+						'id'   => '_',
817
+						'text' => esc_html__('_ (underscore)', 'event_espresso'),
818
+					],
819
+					[
820
+						'id'   => "'",
821
+						'text' => esc_html__("' (apostrophe)", 'event_espresso'),
822
+					],
823
+				],
824
+				'use_desc_4_label' => true,
825
+				'disabled'         => $CNT_cur_disabled,
826
+			],
827
+			'CNT_tel_code'    => [
828
+				'type'       => 'TEXT',
829
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
830
+				'class'      => 'small-text',
831
+			],
832
+			'CNT_is_EU'       => [
833
+				'type'             => 'RADIO_BTN',
834
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
835
+				'class'            => '',
836
+				'options'          => $this->_yes_no_values,
837
+				'use_desc_4_label' => true,
838
+			],
839
+		];
840
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
841
+			$country,
842
+			$country_input_types
843
+		);
844
+		$country_details_settings       = EEH_Template::display_template(
845
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
846
+			$this->_template_args,
847
+			true
848
+		);
849
+
850
+		if (defined('DOING_AJAX')) {
851
+			$notices = EE_Error::get_notices(false, false, false);
852
+			echo wp_json_encode(
853
+				[
854
+					'return_data' => $country_details_settings,
855
+					'success'     => $notices['success'],
856
+					'errors'      => $notices['errors'],
857
+				]
858
+			);
859
+			die();
860
+		}
861
+		return $country_details_settings;
862
+	}
863
+
864
+
865
+	/**
866
+	 * @param string          $CNT_ISO
867
+	 * @param EE_Country|null $country
868
+	 * @return string
869
+	 * @throws DomainException
870
+	 * @throws EE_Error
871
+	 * @throws InvalidArgumentException
872
+	 * @throws InvalidDataTypeException
873
+	 * @throws InvalidInterfaceException
874
+	 * @throws ReflectionException
875
+	 */
876
+	public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
877
+	{
878
+		$CNT_ISO = $this->getCountryISO($CNT_ISO);
879
+		if (! $CNT_ISO) {
880
+			return '';
881
+		}
882
+		// for ajax
883
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
884
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
885
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
886
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
887
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
888
+		if (empty($states)) {
889
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
890
+			$countrySubRegionDao = $this->loader->getShared(
891
+				'EventEspresso\core\services\address\CountrySubRegionDao'
892
+			);
893
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
894
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
895
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
896
+					$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
897
+				}
898
+			}
899
+		}
900
+		if (is_array($states)) {
901
+			foreach ($states as $STA_ID => $state) {
902
+				if ($state instanceof EE_State) {
903
+					$inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
904
+						$state,
905
+						[
906
+							'STA_abbrev' => [
907
+								'type'             => 'TEXT',
908
+								'label'            => esc_html__('Code', 'event_espresso'),
909
+								'input_name'       => 'states[' . $STA_ID . ']',
910
+								'class'            => 'small-text',
911
+								'add_mobile_label' => true,
912
+							],
913
+							'STA_name'   => [
914
+								'type'             => 'TEXT',
915
+								'label'            => esc_html__('Name', 'event_espresso'),
916
+								'input_name'       => 'states[' . $STA_ID . ']',
917
+								'class'            => 'regular-text',
918
+								'add_mobile_label' => true,
919
+							],
920
+							'STA_active' => [
921
+								'type'             => 'RADIO_BTN',
922
+								'label'            => esc_html__(
923
+									'State Appears in Dropdown Select Lists',
924
+									'event_espresso'
925
+								),
926
+								'input_name'       => 'states[' . $STA_ID . ']',
927
+								'options'          => $this->_yes_no_values,
928
+								'use_desc_4_label' => true,
929
+								'add_mobile_label' => true,
930
+							],
931
+						]
932
+					);
933
+
934
+					$delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
935
+						[
936
+							'action'     => 'delete_state',
937
+							'STA_ID'     => $STA_ID,
938
+							'CNT_ISO'    => $CNT_ISO,
939
+							'STA_abbrev' => $state->abbrev(),
940
+						],
941
+						GEN_SET_ADMIN_URL
942
+					);
943
+
944
+					$this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
945
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
946
+				}
947
+			}
948
+		} else {
949
+			$this->_template_args['states'] = false;
950
+		}
951
+
952
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
953
+			['action' => 'add_new_state'],
954
+			GEN_SET_ADMIN_URL
955
+		);
956
+
957
+		$state_details_settings = EEH_Template::display_template(
958
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
959
+			$this->_template_args,
960
+			true
961
+		);
962
+
963
+		if (defined('DOING_AJAX')) {
964
+			$notices = EE_Error::get_notices(false, false, false);
965
+			echo wp_json_encode(
966
+				[
967
+					'return_data' => $state_details_settings,
968
+					'success'     => $notices['success'],
969
+					'errors'      => $notices['errors'],
970
+				]
971
+			);
972
+			die();
973
+		}
974
+		return $state_details_settings;
975
+	}
976
+
977
+
978
+	/**
979
+	 * @return void
980
+	 * @throws EE_Error
981
+	 * @throws InvalidArgumentException
982
+	 * @throws InvalidDataTypeException
983
+	 * @throws InvalidInterfaceException
984
+	 * @throws ReflectionException
985
+	 */
986
+	public function add_new_state()
987
+	{
988
+		$success = true;
989
+		$CNT_ISO = $this->getCountryISO('');
990
+		if (! $CNT_ISO) {
991
+			EE_Error::add_error(
992
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
993
+				__FILE__,
994
+				__FUNCTION__,
995
+				__LINE__
996
+			);
997
+			$success = false;
998
+		}
999
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1000
+		if (! $STA_abbrev) {
1001
+			EE_Error::add_error(
1002
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1003
+				__FILE__,
1004
+				__FUNCTION__,
1005
+				__LINE__
1006
+			);
1007
+			$success = false;
1008
+		}
1009
+		$STA_name = $this->request->getRequestParam('STA_name');
1010
+		if (! $STA_name) {
1011
+			EE_Error::add_error(
1012
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1013
+				__FILE__,
1014
+				__FUNCTION__,
1015
+				__LINE__
1016
+			);
1017
+			$success = false;
1018
+		}
1019
+
1020
+		if ($success) {
1021
+			$cols_n_values = [
1022
+				'CNT_ISO'    => $CNT_ISO,
1023
+				'STA_abbrev' => $STA_abbrev,
1024
+				'STA_name'   => $STA_name,
1025
+				'STA_active' => true,
1026
+			];
1027
+			$success       = EEM_State::instance()->insert($cols_n_values);
1028
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1029
+		}
1030
+
1031
+		if (defined('DOING_AJAX')) {
1032
+			$notices = EE_Error::get_notices(false, false, false);
1033
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1034
+			die();
1035
+		} else {
1036
+			$this->_redirect_after_action(
1037
+				$success,
1038
+				esc_html__('State', 'event_espresso'),
1039
+				'added',
1040
+				['action' => 'country_settings']
1041
+			);
1042
+		}
1043
+	}
1044
+
1045
+
1046
+	/**
1047
+	 * @return void
1048
+	 * @throws EE_Error
1049
+	 * @throws InvalidArgumentException
1050
+	 * @throws InvalidDataTypeException
1051
+	 * @throws InvalidInterfaceException
1052
+	 * @throws ReflectionException
1053
+	 */
1054
+	public function delete_state()
1055
+	{
1056
+		$CNT_ISO    = $this->getCountryISO();
1057
+		$STA_ID     = $this->request->getRequestParam('STA_ID');
1058
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1059
+
1060
+		if (! $STA_ID) {
1061
+			EE_Error::add_error(
1062
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1063
+				__FILE__,
1064
+				__FUNCTION__,
1065
+				__LINE__
1066
+			);
1067
+			return;
1068
+		}
1069
+
1070
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1071
+		if ($success !== false) {
1072
+			do_action(
1073
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1074
+				$CNT_ISO,
1075
+				$STA_ID,
1076
+				['STA_abbrev' => $STA_abbrev]
1077
+			);
1078
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1079
+		}
1080
+		if (defined('DOING_AJAX')) {
1081
+			$notices                = EE_Error::get_notices(false);
1082
+			$notices['return_data'] = true;
1083
+			echo wp_json_encode($notices);
1084
+			die();
1085
+		} else {
1086
+			$this->_redirect_after_action(
1087
+				$success,
1088
+				esc_html__('State', 'event_espresso'),
1089
+				'deleted',
1090
+				['action' => 'country_settings']
1091
+			);
1092
+		}
1093
+	}
1094
+
1095
+
1096
+	/**
1097
+	 *        _update_country_settings
1098
+	 *
1099
+	 * @return void
1100
+	 * @throws EE_Error
1101
+	 * @throws InvalidArgumentException
1102
+	 * @throws InvalidDataTypeException
1103
+	 * @throws InvalidInterfaceException
1104
+	 * @throws ReflectionException
1105
+	 */
1106
+	protected function _update_country_settings()
1107
+	{
1108
+		$CNT_ISO = $this->getCountryISO();
1109
+		if (! $CNT_ISO) {
1110
+			EE_Error::add_error(
1111
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1112
+				__FILE__,
1113
+				__FUNCTION__,
1114
+				__LINE__
1115
+			);
1116
+			return;
1117
+		}
1118
+
1119
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1120
+
1121
+		$cols_n_values                    = [];
1122
+		$cols_n_values['CNT_ISO3']        = strtoupper(
1123
+			$this->request->getRequestParam(
1124
+				"cntry[$CNT_ISO][CNT_ISO3]",
1125
+				$country->ISO3()
1126
+			)
1127
+		);
1128
+		$cols_n_values['CNT_name']        = $this->request->getRequestParam(
1129
+			"cntry[$CNT_ISO][CNT_name]",
1130
+			$country->name()
1131
+		);
1132
+		$cols_n_values['CNT_cur_code']    = strtoupper(
1133
+			$this->request->getRequestParam(
1134
+				"cntry[$CNT_ISO][CNT_cur_code]",
1135
+				$country->currency_code()
1136
+			)
1137
+		);
1138
+		$cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1139
+			"cntry[$CNT_ISO][CNT_cur_single]",
1140
+			$country->currency_name_single()
1141
+		);
1142
+		$cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1143
+			"cntry[$CNT_ISO][CNT_cur_plural]",
1144
+			$country->currency_name_plural()
1145
+		);
1146
+		$cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1147
+			"cntry[$CNT_ISO][CNT_cur_sign]",
1148
+			$country->currency_sign()
1149
+		);
1150
+		$cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1151
+			"cntry[$CNT_ISO][CNT_cur_sign_b4]",
1152
+			$country->currency_sign_before(),
1153
+			DataType::BOOL
1154
+		);
1155
+		$cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1156
+			"cntry[$CNT_ISO][CNT_cur_dec_plc]",
1157
+			$country->currency_decimal_places()
1158
+		);
1159
+		$cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1160
+			"cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1161
+			$country->currency_decimal_mark()
1162
+		);
1163
+		$cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1164
+			"cntry[$CNT_ISO][CNT_cur_thsnds]",
1165
+			$country->currency_thousands_separator()
1166
+		);
1167
+		$cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1168
+			"cntry[$CNT_ISO][CNT_tel_code]",
1169
+			$country->telephoneCode()
1170
+		);
1171
+		$cols_n_values['CNT_active']      = $this->request->getRequestParam(
1172
+			"cntry[$CNT_ISO][CNT_active]",
1173
+			$country->isActive(),
1174
+			DataType::BOOL
1175
+		);
1176
+
1177
+		// allow filtering of country data
1178
+		$cols_n_values = apply_filters(
1179
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1180
+			$cols_n_values
1181
+		);
1182
+
1183
+		// where values
1184
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1185
+		// run the update
1186
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1187
+
1188
+		// allow filtering of states data
1189
+		$states = apply_filters(
1190
+			'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1191
+			$this->request->getRequestParam('states', [], DataType::STRING, true)
1192
+		);
1193
+
1194
+		if (! empty($states) && $success !== false) {
1195
+			// loop thru state data ( looks like : states[75][STA_name] )
1196
+			foreach ($states as $STA_ID => $state) {
1197
+				$cols_n_values = [
1198
+					'CNT_ISO'    => $CNT_ISO,
1199
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1200
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1201
+					'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1202
+				];
1203
+				// where values
1204
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1205
+				// run the update
1206
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1207
+				if ($success !== false) {
1208
+					do_action(
1209
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1210
+						$CNT_ISO,
1211
+						$STA_ID,
1212
+						$cols_n_values
1213
+					);
1214
+				}
1215
+			}
1216
+		}
1217
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1218
+		if (
1219
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1220
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1221
+		) {
1222
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1223
+			EE_Registry::instance()->CFG->update_espresso_config();
1224
+		}
1225
+
1226
+		if ($success !== false) {
1227
+			EE_Error::add_success(
1228
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1229
+			);
1230
+		}
1231
+		$this->_redirect_after_action(
1232
+			$success,
1233
+			'',
1234
+			'',
1235
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1236
+			true
1237
+		);
1238
+	}
1239
+
1240
+
1241
+	/**
1242
+	 * form_form_field_label_wrap
1243
+	 *
1244
+	 * @param string $label
1245
+	 * @return string
1246
+	 */
1247
+	public function country_form_field_label_wrap(string $label): string
1248
+	{
1249
+		return '
1250 1250
 			<tr>
1251 1251
 				<th>
1252 1252
 					' . $label . '
1253 1253
 				</th>';
1254
-    }
1255
-
1256
-
1257
-    /**
1258
-     * form_form_field_input__wrap
1259
-     *
1260
-     * @param string $input
1261
-     * @return string
1262
-     */
1263
-    public function country_form_field_input__wrap(string $input): string
1264
-    {
1265
-        return '
1254
+	}
1255
+
1256
+
1257
+	/**
1258
+	 * form_form_field_input__wrap
1259
+	 *
1260
+	 * @param string $input
1261
+	 * @return string
1262
+	 */
1263
+	public function country_form_field_input__wrap(string $input): string
1264
+	{
1265
+		return '
1266 1266
 				<td class="general-settings-country-input-td">
1267 1267
 					' . $input . '
1268 1268
 				</td>
1269 1269
 			</tr>';
1270
-    }
1271
-
1272
-
1273
-    /**
1274
-     * form_form_field_label_wrap
1275
-     *
1276
-     * @param string $label
1277
-     * @param string $required_text
1278
-     * @return string
1279
-     */
1280
-    public function state_form_field_label_wrap(string $label, string $required_text): string
1281
-    {
1282
-        return $required_text;
1283
-    }
1284
-
1285
-
1286
-    /**
1287
-     * form_form_field_input__wrap
1288
-     *
1289
-     * @param string $input
1290
-     * @return string
1291
-     */
1292
-    public function state_form_field_input__wrap(string $input): string
1293
-    {
1294
-        return '
1270
+	}
1271
+
1272
+
1273
+	/**
1274
+	 * form_form_field_label_wrap
1275
+	 *
1276
+	 * @param string $label
1277
+	 * @param string $required_text
1278
+	 * @return string
1279
+	 */
1280
+	public function state_form_field_label_wrap(string $label, string $required_text): string
1281
+	{
1282
+		return $required_text;
1283
+	}
1284
+
1285
+
1286
+	/**
1287
+	 * form_form_field_input__wrap
1288
+	 *
1289
+	 * @param string $input
1290
+	 * @return string
1291
+	 */
1292
+	public function state_form_field_input__wrap(string $input): string
1293
+	{
1294
+		return '
1295 1295
 				<td class="general-settings-country-state-input-td">
1296 1296
 					' . $input . '
1297 1297
 				</td>';
1298
-    }
1299
-
1300
-
1301
-    /***********/
1302
-
1303
-
1304
-    /**
1305
-     * displays edit and view links for critical EE pages
1306
-     *
1307
-     * @param int $ee_page_id
1308
-     * @return string
1309
-     */
1310
-    public static function edit_view_links(int $ee_page_id): string
1311
-    {
1312
-        $edit_url = add_query_arg(
1313
-            ['post' => $ee_page_id, 'action' => 'edit'],
1314
-            admin_url('post.php')
1315
-        );
1316
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1317
-        $links    .= ' &nbsp;|&nbsp; ';
1318
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1319
-
1320
-        return $links;
1321
-    }
1322
-
1323
-
1324
-    /**
1325
-     * displays page and shortcode status for critical EE pages
1326
-     *
1327
-     * @param WP_Post $ee_page
1328
-     * @param string  $shortcode
1329
-     * @return string
1330
-     */
1331
-    public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1332
-    {
1333
-        // page status
1334
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1335
-            $pg_colour = 'green';
1336
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1337
-        } else {
1338
-            $pg_colour = 'red';
1339
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1340
-        }
1341
-
1342
-        // shortcode status
1343
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1344
-            $sc_colour = 'green';
1345
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1346
-        } else {
1347
-            $sc_colour = 'red';
1348
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1349
-        }
1350
-
1351
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1352
-               . $pg_status
1353
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1354
-    }
1355
-
1356
-
1357
-    /**
1358
-     * generates a dropdown of all parent pages - copied from WP core
1359
-     *
1360
-     * @param int  $default
1361
-     * @param int  $parent
1362
-     * @param int  $level
1363
-     * @param bool $echo
1364
-     * @return string;
1365
-     */
1366
-    public static function page_settings_dropdown(
1367
-        int $default = 0,
1368
-        int $parent = 0,
1369
-        int $level = 0,
1370
-        bool $echo = true
1371
-    ): string {
1372
-        global $wpdb;
1373
-        $items  = $wpdb->get_results(
1374
-            $wpdb->prepare(
1375
-                "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",
1376
-                $parent
1377
-            )
1378
-        );
1379
-        $output = '';
1380
-
1381
-        if ($items) {
1382
-            $level = absint($level);
1383
-            foreach ($items as $item) {
1384
-                $ID         = absint($item->ID);
1385
-                $post_title = wp_strip_all_tags($item->post_title);
1386
-                $pad        = str_repeat('&nbsp;', $level * 3);
1387
-                $option     = "\n\t";
1388
-                $option     .= '<option class="level-' . $level . '" ';
1389
-                $option     .= 'value="' . $ID . '" ';
1390
-                $option     .= $ID === absint($default) ? ' selected' : '';
1391
-                $option     .= '>';
1392
-                $option     .= "$pad {$post_title}";
1393
-                $option     .= '</option>';
1394
-                $output     .= $option;
1395
-                ob_start();
1396
-                parent_dropdown($default, $item->ID, $level + 1);
1397
-                $output .= ob_get_clean();
1398
-            }
1399
-        }
1400
-        if ($echo) {
1401
-            echo wp_kses($output, AllowedTags::getWithFormTags());
1402
-            return '';
1403
-        }
1404
-        return $output;
1405
-    }
1406
-
1407
-
1408
-    /**
1409
-     * Loads the scripts for the privacy settings form
1410
-     */
1411
-    public function load_scripts_styles_privacy_settings()
1412
-    {
1413
-        $form_handler = $this->loader->getShared(
1414
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1415
-        );
1416
-        $form_handler->enqueueStylesAndScripts();
1417
-    }
1418
-
1419
-
1420
-    /**
1421
-     * display the privacy settings form
1422
-     *
1423
-     * @throws EE_Error
1424
-     */
1425
-    public function privacySettings()
1426
-    {
1427
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1428
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1429
-        $form_handler                               = $this->loader->getShared(
1430
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1431
-        );
1432
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1433
-            $form_handler->display(),
1434
-            '',
1435
-            'padding'
1436
-        );
1437
-        $this->display_admin_page_with_sidebar();
1438
-    }
1439
-
1440
-
1441
-    /**
1442
-     * Update the privacy settings from form data
1443
-     *
1444
-     * @throws EE_Error
1445
-     */
1446
-    public function updatePrivacySettings()
1447
-    {
1448
-        $form_handler = $this->loader->getShared(
1449
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1450
-        );
1451
-        $success      = $form_handler->process($this->get_request_data());
1452
-        $this->_redirect_after_action(
1453
-            $success,
1454
-            esc_html__('Registration Form Options', 'event_espresso'),
1455
-            'updated',
1456
-            ['action' => 'privacy_settings']
1457
-        );
1458
-    }
1298
+	}
1299
+
1300
+
1301
+	/***********/
1302
+
1303
+
1304
+	/**
1305
+	 * displays edit and view links for critical EE pages
1306
+	 *
1307
+	 * @param int $ee_page_id
1308
+	 * @return string
1309
+	 */
1310
+	public static function edit_view_links(int $ee_page_id): string
1311
+	{
1312
+		$edit_url = add_query_arg(
1313
+			['post' => $ee_page_id, 'action' => 'edit'],
1314
+			admin_url('post.php')
1315
+		);
1316
+		$links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1317
+		$links    .= ' &nbsp;|&nbsp; ';
1318
+		$links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1319
+
1320
+		return $links;
1321
+	}
1322
+
1323
+
1324
+	/**
1325
+	 * displays page and shortcode status for critical EE pages
1326
+	 *
1327
+	 * @param WP_Post $ee_page
1328
+	 * @param string  $shortcode
1329
+	 * @return string
1330
+	 */
1331
+	public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1332
+	{
1333
+		// page status
1334
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1335
+			$pg_colour = 'green';
1336
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1337
+		} else {
1338
+			$pg_colour = 'red';
1339
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1340
+		}
1341
+
1342
+		// shortcode status
1343
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1344
+			$sc_colour = 'green';
1345
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1346
+		} else {
1347
+			$sc_colour = 'red';
1348
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1349
+		}
1350
+
1351
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1352
+			   . $pg_status
1353
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1354
+	}
1355
+
1356
+
1357
+	/**
1358
+	 * generates a dropdown of all parent pages - copied from WP core
1359
+	 *
1360
+	 * @param int  $default
1361
+	 * @param int  $parent
1362
+	 * @param int  $level
1363
+	 * @param bool $echo
1364
+	 * @return string;
1365
+	 */
1366
+	public static function page_settings_dropdown(
1367
+		int $default = 0,
1368
+		int $parent = 0,
1369
+		int $level = 0,
1370
+		bool $echo = true
1371
+	): string {
1372
+		global $wpdb;
1373
+		$items  = $wpdb->get_results(
1374
+			$wpdb->prepare(
1375
+				"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",
1376
+				$parent
1377
+			)
1378
+		);
1379
+		$output = '';
1380
+
1381
+		if ($items) {
1382
+			$level = absint($level);
1383
+			foreach ($items as $item) {
1384
+				$ID         = absint($item->ID);
1385
+				$post_title = wp_strip_all_tags($item->post_title);
1386
+				$pad        = str_repeat('&nbsp;', $level * 3);
1387
+				$option     = "\n\t";
1388
+				$option     .= '<option class="level-' . $level . '" ';
1389
+				$option     .= 'value="' . $ID . '" ';
1390
+				$option     .= $ID === absint($default) ? ' selected' : '';
1391
+				$option     .= '>';
1392
+				$option     .= "$pad {$post_title}";
1393
+				$option     .= '</option>';
1394
+				$output     .= $option;
1395
+				ob_start();
1396
+				parent_dropdown($default, $item->ID, $level + 1);
1397
+				$output .= ob_get_clean();
1398
+			}
1399
+		}
1400
+		if ($echo) {
1401
+			echo wp_kses($output, AllowedTags::getWithFormTags());
1402
+			return '';
1403
+		}
1404
+		return $output;
1405
+	}
1406
+
1407
+
1408
+	/**
1409
+	 * Loads the scripts for the privacy settings form
1410
+	 */
1411
+	public function load_scripts_styles_privacy_settings()
1412
+	{
1413
+		$form_handler = $this->loader->getShared(
1414
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1415
+		);
1416
+		$form_handler->enqueueStylesAndScripts();
1417
+	}
1418
+
1419
+
1420
+	/**
1421
+	 * display the privacy settings form
1422
+	 *
1423
+	 * @throws EE_Error
1424
+	 */
1425
+	public function privacySettings()
1426
+	{
1427
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1428
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1429
+		$form_handler                               = $this->loader->getShared(
1430
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1431
+		);
1432
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1433
+			$form_handler->display(),
1434
+			'',
1435
+			'padding'
1436
+		);
1437
+		$this->display_admin_page_with_sidebar();
1438
+	}
1439
+
1440
+
1441
+	/**
1442
+	 * Update the privacy settings from form data
1443
+	 *
1444
+	 * @throws EE_Error
1445
+	 */
1446
+	public function updatePrivacySettings()
1447
+	{
1448
+		$form_handler = $this->loader->getShared(
1449
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1450
+		);
1451
+		$success      = $form_handler->process($this->get_request_data());
1452
+		$this->_redirect_after_action(
1453
+			$success,
1454
+			esc_html__('Registration Form Options', 'event_espresso'),
1455
+			'updated',
1456
+			['action' => 'privacy_settings']
1457
+		);
1458
+	}
1459 1459
 }
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -246,19 +246,19 @@  discard block
 block discarded – undo
246 246
                 'event_espresso'
247 247
             )
248 248
         );
249
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
249
+        EE_Registry::$i18n_js_strings['error_occurred'] = wp_strip_all_tags(
250 250
             esc_html__(
251 251
                 'An error occurred! Please refresh the page and try again.',
252 252
                 'event_espresso'
253 253
             )
254 254
         );
255
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
255
+        EE_Registry::$i18n_js_strings['confirm_delete_state'] = wp_strip_all_tags(
256 256
             esc_html__(
257 257
                 'Are you sure you want to delete this State / Province?',
258 258
                 'event_espresso'
259 259
             )
260 260
         );
261
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
261
+        EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
262 262
             'admin-ajax.php?page=espresso_general_settings',
263 263
             is_ssl() ? 'https://' : 'http://'
264 264
         );
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
         wp_enqueue_script('thickbox');
288 288
         wp_register_script(
289 289
             'organization_settings',
290
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
290
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
291 291
             ['jquery', 'media-upload', 'thickbox'],
292 292
             EVENT_ESPRESSO_VERSION,
293 293
             true
294 294
         );
295
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
295
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', [], EVENT_ESPRESSO_VERSION);
296 296
         wp_enqueue_script('organization_settings');
297 297
         wp_enqueue_style('organization-css');
298 298
         $confirm_image_delete = [
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
         // scripts
316 316
         wp_register_script(
317 317
             'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
318
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
319 319
             ['ee_admin_js'],
320 320
             EVENT_ESPRESSO_VERSION,
321 321
             true
322 322
         );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
323
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', [], EVENT_ESPRESSO_VERSION);
324 324
         wp_enqueue_script('gen_settings_countries');
325 325
         wp_enqueue_style('organization-css');
326 326
     }
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
369 369
         $this->_set_publish_post_box_vars(null, false, false, null, false);
370 370
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
371
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
372 372
             $this->_template_args,
373 373
             true
374 374
         );
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
     protected function _update_espresso_page_settings()
385 385
     {
386 386
         // capture incoming request data && set page IDs
387
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
387
+        $this->core_config->reg_page_id = $this->request->getRequestParam(
388 388
             'reg_page_id',
389 389
             $this->core_config->reg_page_id,
390 390
             DataType::INT
391 391
         );
392
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
392
+        $this->core_config->txn_page_id = $this->request->getRequestParam(
393 393
             'txn_page_id',
394 394
             $this->core_config->txn_page_id,
395 395
             DataType::INT
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
             $this->core_config->thank_you_page_id,
400 400
             DataType::INT
401 401
         );
402
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
402
+        $this->core_config->cancel_page_id = $this->request->getRequestParam(
403 403
             'cancel_page_id',
404 404
             $this->core_config->cancel_page_id,
405 405
             DataType::INT
@@ -662,16 +662,16 @@  discard block
 block discarded – undo
662 662
             $country->ID(),
663 663
             $country
664 664
         );
665
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
665
+        $this->_template_args['country_states_settings'] = $this->display_country_states(
666 666
             $country->ID(),
667 667
             $country
668 668
         );
669
-        $this->_template_args['CNT_name_for_site']        = $country->name();
669
+        $this->_template_args['CNT_name_for_site'] = $country->name();
670 670
 
671 671
         $this->_set_add_edit_form_tags('update_country_settings');
672 672
         $this->_set_publish_post_box_vars(null, false, false, null, false);
673 673
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
674
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
674
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
675 675
             $this->_template_args,
676 676
             true
677 677
         );
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
         $CNT_ISO          = $this->getCountryISO($CNT_ISO);
696 696
         $CNT_ISO_for_site = $this->getCountryIsoForSite();
697 697
 
698
-        if (! $CNT_ISO) {
698
+        if ( ! $CNT_ISO) {
699 699
             return '';
700 700
         }
701 701
 
@@ -708,22 +708,22 @@  discard block
 block discarded – undo
708 708
         $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
709 709
         $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
710 710
 
711
-        $country_input_types            = [
711
+        $country_input_types = [
712 712
             'CNT_active'      => [
713 713
                 'type'             => 'RADIO_BTN',
714
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
714
+                'input_name'       => 'cntry['.$CNT_ISO.']',
715 715
                 'class'            => '',
716 716
                 'options'          => $this->_yes_no_values,
717 717
                 'use_desc_4_label' => true,
718 718
             ],
719 719
             'CNT_ISO'         => [
720 720
                 'type'       => 'TEXT',
721
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
721
+                'input_name' => 'cntry['.$CNT_ISO.']',
722 722
                 'class'      => 'small-text',
723 723
             ],
724 724
             'CNT_ISO3'        => [
725 725
                 'type'       => 'TEXT',
726
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
726
+                'input_name' => 'cntry['.$CNT_ISO.']',
727 727
                 'class'      => 'small-text',
728 728
             ],
729 729
             // 'RGN_ID'          => [
@@ -733,37 +733,37 @@  discard block
 block discarded – undo
733 733
             // ],
734 734
             'CNT_name'        => [
735 735
                 'type'       => 'TEXT',
736
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
736
+                'input_name' => 'cntry['.$CNT_ISO.']',
737 737
                 'class'      => 'regular-text',
738 738
             ],
739 739
             'CNT_cur_code'    => [
740 740
                 'type'       => 'TEXT',
741
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
741
+                'input_name' => 'cntry['.$CNT_ISO.']',
742 742
                 'class'      => 'small-text',
743 743
                 'disabled'   => $CNT_cur_disabled,
744 744
             ],
745 745
             'CNT_cur_single'  => [
746 746
                 'type'       => 'TEXT',
747
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
747
+                'input_name' => 'cntry['.$CNT_ISO.']',
748 748
                 'class'      => 'medium-text',
749 749
                 'disabled'   => $CNT_cur_disabled,
750 750
             ],
751 751
             'CNT_cur_plural'  => [
752 752
                 'type'       => 'TEXT',
753
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
753
+                'input_name' => 'cntry['.$CNT_ISO.']',
754 754
                 'class'      => 'medium-text',
755 755
                 'disabled'   => $CNT_cur_disabled,
756 756
             ],
757 757
             'CNT_cur_sign'    => [
758 758
                 'type'         => 'TEXT',
759
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
759
+                'input_name'   => 'cntry['.$CNT_ISO.']',
760 760
                 'class'        => 'small-text',
761 761
                 'htmlentities' => false,
762 762
                 'disabled'     => $CNT_cur_disabled,
763 763
             ],
764 764
             'CNT_cur_sign_b4' => [
765 765
                 'type'             => 'RADIO_BTN',
766
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
766
+                'input_name'       => 'cntry['.$CNT_ISO.']',
767 767
                 'class'            => '',
768 768
                 'options'          => $this->_yes_no_values,
769 769
                 'use_desc_4_label' => true,
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
             ],
772 772
             'CNT_cur_dec_plc' => [
773 773
                 'type'       => 'RADIO_BTN',
774
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
774
+                'input_name' => 'cntry['.$CNT_ISO.']',
775 775
                 'class'      => '',
776 776
                 'options'    => [
777 777
                     ['id' => 0, 'text' => ''],
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
             ],
784 784
             'CNT_cur_dec_mrk' => [
785 785
                 'type'             => 'RADIO_BTN',
786
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
786
+                'input_name'       => 'cntry['.$CNT_ISO.']',
787 787
                 'class'            => '',
788 788
                 'options'          => [
789 789
                     [
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
             ],
798 798
             'CNT_cur_thsnds'  => [
799 799
                 'type'             => 'RADIO_BTN',
800
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
800
+                'input_name'       => 'cntry['.$CNT_ISO.']',
801 801
                 'class'            => '',
802 802
                 'options'          => [
803 803
                     [
@@ -826,12 +826,12 @@  discard block
 block discarded – undo
826 826
             ],
827 827
             'CNT_tel_code'    => [
828 828
                 'type'       => 'TEXT',
829
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
829
+                'input_name' => 'cntry['.$CNT_ISO.']',
830 830
                 'class'      => 'small-text',
831 831
             ],
832 832
             'CNT_is_EU'       => [
833 833
                 'type'             => 'RADIO_BTN',
834
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
834
+                'input_name'       => 'cntry['.$CNT_ISO.']',
835 835
                 'class'            => '',
836 836
                 'options'          => $this->_yes_no_values,
837 837
                 'use_desc_4_label' => true,
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
             $country,
842 842
             $country_input_types
843 843
         );
844
-        $country_details_settings       = EEH_Template::display_template(
845
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
844
+        $country_details_settings = EEH_Template::display_template(
845
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
846 846
             $this->_template_args,
847 847
             true
848 848
         );
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
     public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
877 877
     {
878 878
         $CNT_ISO = $this->getCountryISO($CNT_ISO);
879
-        if (! $CNT_ISO) {
879
+        if ( ! $CNT_ISO) {
880 880
             return '';
881 881
         }
882 882
         // for ajax
@@ -906,14 +906,14 @@  discard block
 block discarded – undo
906 906
                             'STA_abbrev' => [
907 907
                                 'type'             => 'TEXT',
908 908
                                 'label'            => esc_html__('Code', 'event_espresso'),
909
-                                'input_name'       => 'states[' . $STA_ID . ']',
909
+                                'input_name'       => 'states['.$STA_ID.']',
910 910
                                 'class'            => 'small-text',
911 911
                                 'add_mobile_label' => true,
912 912
                             ],
913 913
                             'STA_name'   => [
914 914
                                 'type'             => 'TEXT',
915 915
                                 'label'            => esc_html__('Name', 'event_espresso'),
916
-                                'input_name'       => 'states[' . $STA_ID . ']',
916
+                                'input_name'       => 'states['.$STA_ID.']',
917 917
                                 'class'            => 'regular-text',
918 918
                                 'add_mobile_label' => true,
919 919
                             ],
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
                                     'State Appears in Dropdown Select Lists',
924 924
                                     'event_espresso'
925 925
                                 ),
926
-                                'input_name'       => 'states[' . $STA_ID . ']',
926
+                                'input_name'       => 'states['.$STA_ID.']',
927 927
                                 'options'          => $this->_yes_no_values,
928 928
                                 'use_desc_4_label' => true,
929 929
                                 'add_mobile_label' => true,
@@ -941,8 +941,8 @@  discard block
 block discarded – undo
941 941
                         GEN_SET_ADMIN_URL
942 942
                     );
943 943
 
944
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
945
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
944
+                    $this->_template_args['states'][$STA_ID]['inputs']           = $inputs;
945
+                    $this->_template_args['states'][$STA_ID]['delete_state_url'] = $delete_state_url;
946 946
                 }
947 947
             }
948 948
         } else {
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
         );
956 956
 
957 957
         $state_details_settings = EEH_Template::display_template(
958
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
958
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
959 959
             $this->_template_args,
960 960
             true
961 961
         );
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
     {
988 988
         $success = true;
989 989
         $CNT_ISO = $this->getCountryISO('');
990
-        if (! $CNT_ISO) {
990
+        if ( ! $CNT_ISO) {
991 991
             EE_Error::add_error(
992 992
                 esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
993 993
                 __FILE__,
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
             $success = false;
998 998
         }
999 999
         $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1000
-        if (! $STA_abbrev) {
1000
+        if ( ! $STA_abbrev) {
1001 1001
             EE_Error::add_error(
1002 1002
                 esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1003 1003
                 __FILE__,
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
             $success = false;
1008 1008
         }
1009 1009
         $STA_name = $this->request->getRequestParam('STA_name');
1010
-        if (! $STA_name) {
1010
+        if ( ! $STA_name) {
1011 1011
             EE_Error::add_error(
1012 1012
                 esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1013 1013
                 __FILE__,
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
                 'STA_name'   => $STA_name,
1025 1025
                 'STA_active' => true,
1026 1026
             ];
1027
-            $success       = EEM_State::instance()->insert($cols_n_values);
1027
+            $success = EEM_State::instance()->insert($cols_n_values);
1028 1028
             EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1029 1029
         }
1030 1030
 
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
         $STA_ID     = $this->request->getRequestParam('STA_ID');
1058 1058
         $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1059 1059
 
1060
-        if (! $STA_ID) {
1060
+        if ( ! $STA_ID) {
1061 1061
             EE_Error::add_error(
1062 1062
                 esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1063 1063
                 __FILE__,
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
     protected function _update_country_settings()
1107 1107
     {
1108 1108
         $CNT_ISO = $this->getCountryISO();
1109
-        if (! $CNT_ISO) {
1109
+        if ( ! $CNT_ISO) {
1110 1110
             EE_Error::add_error(
1111 1111
                 esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1112 1112
                 __FILE__,
@@ -1125,25 +1125,25 @@  discard block
 block discarded – undo
1125 1125
                 $country->ISO3()
1126 1126
             )
1127 1127
         );
1128
-        $cols_n_values['CNT_name']        = $this->request->getRequestParam(
1128
+        $cols_n_values['CNT_name'] = $this->request->getRequestParam(
1129 1129
             "cntry[$CNT_ISO][CNT_name]",
1130 1130
             $country->name()
1131 1131
         );
1132
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1132
+        $cols_n_values['CNT_cur_code'] = strtoupper(
1133 1133
             $this->request->getRequestParam(
1134 1134
                 "cntry[$CNT_ISO][CNT_cur_code]",
1135 1135
                 $country->currency_code()
1136 1136
             )
1137 1137
         );
1138
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1138
+        $cols_n_values['CNT_cur_single'] = $this->request->getRequestParam(
1139 1139
             "cntry[$CNT_ISO][CNT_cur_single]",
1140 1140
             $country->currency_name_single()
1141 1141
         );
1142
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1142
+        $cols_n_values['CNT_cur_plural'] = $this->request->getRequestParam(
1143 1143
             "cntry[$CNT_ISO][CNT_cur_plural]",
1144 1144
             $country->currency_name_plural()
1145 1145
         );
1146
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1146
+        $cols_n_values['CNT_cur_sign'] = $this->request->getRequestParam(
1147 1147
             "cntry[$CNT_ISO][CNT_cur_sign]",
1148 1148
             $country->currency_sign()
1149 1149
         );
@@ -1160,15 +1160,15 @@  discard block
 block discarded – undo
1160 1160
             "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1161 1161
             $country->currency_decimal_mark()
1162 1162
         );
1163
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1163
+        $cols_n_values['CNT_cur_thsnds'] = $this->request->getRequestParam(
1164 1164
             "cntry[$CNT_ISO][CNT_cur_thsnds]",
1165 1165
             $country->currency_thousands_separator()
1166 1166
         );
1167
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1167
+        $cols_n_values['CNT_tel_code'] = $this->request->getRequestParam(
1168 1168
             "cntry[$CNT_ISO][CNT_tel_code]",
1169 1169
             $country->telephoneCode()
1170 1170
         );
1171
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1171
+        $cols_n_values['CNT_active'] = $this->request->getRequestParam(
1172 1172
             "cntry[$CNT_ISO][CNT_active]",
1173 1173
             $country->isActive(),
1174 1174
             DataType::BOOL
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
             $this->request->getRequestParam('states', [], DataType::STRING, true)
1192 1192
         );
1193 1193
 
1194
-        if (! empty($states) && $success !== false) {
1194
+        if ( ! empty($states) && $success !== false) {
1195 1195
             // loop thru state data ( looks like : states[75][STA_name] )
1196 1196
             foreach ($states as $STA_ID => $state) {
1197 1197
                 $cols_n_values = [
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
         return '
1250 1250
 			<tr>
1251 1251
 				<th>
1252
-					' . $label . '
1252
+					' . $label.'
1253 1253
 				</th>';
1254 1254
     }
1255 1255
 
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
     {
1265 1265
         return '
1266 1266
 				<td class="general-settings-country-input-td">
1267
-					' . $input . '
1267
+					' . $input.'
1268 1268
 				</td>
1269 1269
 			</tr>';
1270 1270
     }
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
     {
1294 1294
         return '
1295 1295
 				<td class="general-settings-country-state-input-td">
1296
-					' . $input . '
1296
+					' . $input.'
1297 1297
 				</td>';
1298 1298
     }
1299 1299
 
@@ -1313,9 +1313,9 @@  discard block
 block discarded – undo
1313 1313
             ['post' => $ee_page_id, 'action' => 'edit'],
1314 1314
             admin_url('post.php')
1315 1315
         );
1316
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1316
+        $links = '<a href="'.esc_url_raw($edit_url).'" >'.esc_html__('Edit', 'event_espresso').'</a>';
1317 1317
         $links    .= ' &nbsp;|&nbsp; ';
1318
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1318
+        $links    .= '<a href="'.get_permalink($ee_page_id).'" >'.esc_html__('View', 'event_espresso').'</a>';
1319 1319
 
1320 1320
         return $links;
1321 1321
     }
@@ -1348,9 +1348,9 @@  discard block
 block discarded – undo
1348 1348
             $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1349 1349
         }
1350 1350
 
1351
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1351
+        return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'
1352 1352
                . $pg_status
1353
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1353
+               . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
1354 1354
     }
1355 1355
 
1356 1356
 
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
         bool $echo = true
1371 1371
     ): string {
1372 1372
         global $wpdb;
1373
-        $items  = $wpdb->get_results(
1373
+        $items = $wpdb->get_results(
1374 1374
             $wpdb->prepare(
1375 1375
                 "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",
1376 1376
                 $parent
@@ -1385,8 +1385,8 @@  discard block
 block discarded – undo
1385 1385
                 $post_title = wp_strip_all_tags($item->post_title);
1386 1386
                 $pad        = str_repeat('&nbsp;', $level * 3);
1387 1387
                 $option     = "\n\t";
1388
-                $option     .= '<option class="level-' . $level . '" ';
1389
-                $option     .= 'value="' . $ID . '" ';
1388
+                $option     .= '<option class="level-'.$level.'" ';
1389
+                $option     .= 'value="'.$ID.'" ';
1390 1390
                 $option     .= $ID === absint($default) ? ' selected' : '';
1391 1391
                 $option     .= '>';
1392 1392
                 $option     .= "$pad {$post_title}";
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.39.rc.006');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.39.rc.006');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4104 added lines, -4104 removed lines patch added patch discarded remove patch
@@ -18,4180 +18,4180 @@
 block discarded – undo
18 18
  */
19 19
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
20 20
 {
21
-    /**
22
-     * @var LoaderInterface
23
-     */
24
-    protected $loader;
21
+	/**
22
+	 * @var LoaderInterface
23
+	 */
24
+	protected $loader;
25 25
 
26
-    /**
27
-     * @var RequestInterface
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var RequestInterface
28
+	 */
29
+	protected $request;
30 30
 
31
-    // set in _init_page_props()
32
-    public $page_slug;
31
+	// set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    // set in define_page_props()
39
-    protected $_admin_base_url;
38
+	// set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    // set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	// set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    // navtabs
52
-    protected $_nav_tabs;
51
+	// navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56 56
 
57
-    // template variables (used by templates)
58
-    protected $_template_path;
57
+	// template variables (used by templates)
58
+	protected $_template_path;
59 59
 
60
-    protected $_column_template_path;
60
+	protected $_column_template_path;
61 61
 
62
-    /**
63
-     * @var array $_template_args
64
-     */
65
-    protected $_template_args = [];
62
+	/**
63
+	 * @var array $_template_args
64
+	 */
65
+	protected $_template_args = [];
66 66
 
67
-    /**
68
-     * this will hold the list table object for a given view.
69
-     *
70
-     * @var EE_Admin_List_Table $_list_table_object
71
-     */
72
-    protected $_list_table_object;
67
+	/**
68
+	 * this will hold the list table object for a given view.
69
+	 *
70
+	 * @var EE_Admin_List_Table $_list_table_object
71
+	 */
72
+	protected $_list_table_object;
73 73
 
74
-    // bools
75
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
74
+	// bools
75
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
76 76
 
77
-    protected $_routing;
77
+	protected $_routing;
78 78
 
79
-    // list table args
80
-    protected $_view;
79
+	// list table args
80
+	protected $_view;
81 81
 
82
-    protected $_views;
82
+	protected $_views;
83 83
 
84 84
 
85
-    // action => method pairs used for routing incoming requests
86
-    protected $_page_routes;
85
+	// action => method pairs used for routing incoming requests
86
+	protected $_page_routes;
87 87
 
88
-    /**
89
-     * @var array $_page_config
90
-     */
91
-    protected $_page_config;
88
+	/**
89
+	 * @var array $_page_config
90
+	 */
91
+	protected $_page_config;
92 92
 
93
-    /**
94
-     * the current page route and route config
95
-     *
96
-     * @var string $_route
97
-     */
98
-    protected $_route;
93
+	/**
94
+	 * the current page route and route config
95
+	 *
96
+	 * @var string $_route
97
+	 */
98
+	protected $_route;
99 99
 
100
-    /**
101
-     * @var string $_cpt_route
102
-     */
103
-    protected $_cpt_route;
100
+	/**
101
+	 * @var string $_cpt_route
102
+	 */
103
+	protected $_cpt_route;
104 104
 
105
-    /**
106
-     * @var array $_route_config
107
-     */
108
-    protected $_route_config;
105
+	/**
106
+	 * @var array $_route_config
107
+	 */
108
+	protected $_route_config;
109 109
 
110
-    /**
111
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
112
-     * actions.
113
-     *
114
-     * @since 4.6.x
115
-     * @var array.
116
-     */
117
-    protected $_default_route_query_args;
118
-
119
-    // set via request page and action args.
120
-    protected $_current_page;
121
-
122
-    protected $_current_view;
123
-
124
-    protected $_current_page_view_url;
125
-
126
-    /**
127
-     * unprocessed value for the 'action' request param (default '')
128
-     *
129
-     * @var string
130
-     */
131
-    protected $raw_req_action = '';
132
-
133
-    /**
134
-     * unprocessed value for the 'page' request param (default '')
135
-     *
136
-     * @var string
137
-     */
138
-    protected $raw_req_page = '';
139
-
140
-    /**
141
-     * sanitized request action (and nonce)
142
-     *
143
-     * @var string
144
-     */
145
-    protected $_req_action = '';
146
-
147
-    /**
148
-     * sanitized request action nonce
149
-     *
150
-     * @var string
151
-     */
152
-    protected $_req_nonce = '';
153
-
154
-    /**
155
-     * @var string
156
-     */
157
-    protected $_search_btn_label = '';
158
-
159
-    /**
160
-     * @var string
161
-     */
162
-    protected $_search_box_callback = '';
163
-
164
-    /**
165
-     * @var WP_Screen
166
-     */
167
-    protected $_current_screen;
168
-
169
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
170
-    protected $_hook_obj;
171
-
172
-    // for holding incoming request data
173
-    protected $_req_data = [];
174
-
175
-    // yes / no array for admin form fields
176
-    protected $_yes_no_values = [];
177
-
178
-    // some default things shared by all child classes
179
-    protected $_default_espresso_metaboxes;
180
-
181
-    /**
182
-     * @var EE_Registry
183
-     */
184
-    protected $EE = null;
185
-
186
-
187
-    /**
188
-     * This is just a property that flags whether the given route is a caffeinated route or not.
189
-     *
190
-     * @var boolean
191
-     */
192
-    protected $_is_caf = false;
193
-
194
-
195
-    /**
196
-     * @Constructor
197
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
198
-     * @throws EE_Error
199
-     * @throws InvalidArgumentException
200
-     * @throws ReflectionException
201
-     * @throws InvalidDataTypeException
202
-     * @throws InvalidInterfaceException
203
-     */
204
-    public function __construct($routing = true)
205
-    {
206
-        $this->loader  = LoaderFactory::getLoader();
207
-        $this->request = $this->loader->getShared(RequestInterface::class);
208
-        $this->_routing = $routing;
209
-
210
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
211
-            $this->_is_caf = true;
212
-        }
213
-        $this->_yes_no_values = [
214
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
215
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
216
-        ];
217
-        // set the _req_data property.
218
-        $this->_req_data = $this->request->requestParams();
219
-        // set initial page props (child method)
220
-        $this->_init_page_props();
221
-        // set global defaults
222
-        $this->_set_defaults();
223
-        // set early because incoming requests could be ajax related and we need to register those hooks.
224
-        $this->_global_ajax_hooks();
225
-        $this->_ajax_hooks();
226
-        // other_page_hooks have to be early too.
227
-        $this->_do_other_page_hooks();
228
-        // set up page dependencies
229
-        $this->_before_page_setup();
230
-        $this->_page_setup();
231
-        // die();
232
-    }
233
-
234
-
235
-    /**
236
-     * _init_page_props
237
-     * Child classes use to set at least the following properties:
238
-     * $page_slug.
239
-     * $page_label.
240
-     *
241
-     * @abstract
242
-     * @return void
243
-     */
244
-    abstract protected function _init_page_props();
245
-
246
-
247
-    /**
248
-     * _ajax_hooks
249
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
250
-     * Note: within the ajax callback methods.
251
-     *
252
-     * @abstract
253
-     * @return void
254
-     */
255
-    abstract protected function _ajax_hooks();
256
-
257
-
258
-    /**
259
-     * _define_page_props
260
-     * child classes define page properties in here.  Must include at least:
261
-     * $_admin_base_url = base_url for all admin pages
262
-     * $_admin_page_title = default admin_page_title for admin pages
263
-     * $_labels = array of default labels for various automatically generated elements:
264
-     *    array(
265
-     *        'buttons' => array(
266
-     *            'add' => esc_html__('label for add new button'),
267
-     *            'edit' => esc_html__('label for edit button'),
268
-     *            'delete' => esc_html__('label for delete button')
269
-     *            )
270
-     *        )
271
-     *
272
-     * @abstract
273
-     * @return void
274
-     */
275
-    abstract protected function _define_page_props();
276
-
277
-
278
-    /**
279
-     * _set_page_routes
280
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
281
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
282
-     * have a 'default' route. Here's the format
283
-     * $this->_page_routes = array(
284
-     *        'default' => array(
285
-     *            'func' => '_default_method_handling_route',
286
-     *            'args' => array('array','of','args'),
287
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
288
-     *            ajax request, backend processing)
289
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
290
-     *            headers route after.  The string you enter here should match the defined route reference for a
291
-     *            headers sent route.
292
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
293
-     *            this route.
294
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
295
-     *            checks).
296
-     *        ),
297
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
298
-     *        handling method.
299
-     *        )
300
-     * )
301
-     *
302
-     * @abstract
303
-     * @return void
304
-     */
305
-    abstract protected function _set_page_routes();
306
-
307
-
308
-    /**
309
-     * _set_page_config
310
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
311
-     * array corresponds to the page_route for the loaded page. Format:
312
-     * $this->_page_config = array(
313
-     *        'default' => array(
314
-     *            'labels' => array(
315
-     *                'buttons' => array(
316
-     *                    'add' => esc_html__('label for adding item'),
317
-     *                    'edit' => esc_html__('label for editing item'),
318
-     *                    'delete' => esc_html__('label for deleting item')
319
-     *                ),
320
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
321
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
322
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
323
-     *            _define_page_props() method
324
-     *            'nav' => array(
325
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
326
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
327
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
328
-     *                'order' => 10, //required to indicate tab position.
329
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
330
-     *                displayed then add this parameter.
331
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
332
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
333
-     *            metaboxes set for eventespresso admin pages.
334
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
335
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
336
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
337
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
338
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
339
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
340
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
341
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
342
-     *            want to display.
343
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
344
-     *                'tab_id' => array(
345
-     *                    'title' => 'tab_title',
346
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
347
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
348
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
349
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
350
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
351
-     *                    attempt to use the callback which should match the name of a method in the class
352
-     *                    ),
353
-     *                'tab2_id' => array(
354
-     *                    'title' => 'tab2 title',
355
-     *                    'filename' => 'file_name_2'
356
-     *                    'callback' => 'callback_method_for_content',
357
-     *                 ),
358
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
359
-     *            help tab area on an admin page. @return void
360
-     *
361
-     * @abstract
362
-     */
363
-    abstract protected function _set_page_config();
364
-
365
-
366
-    /**
367
-     * _add_screen_options
368
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
-     * to a particular view.
371
-     *
372
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
-     *         see also WP_Screen object documents...
374
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
-     * @abstract
376
-     * @return void
377
-     */
378
-    abstract protected function _add_screen_options();
379
-
380
-
381
-    /**
382
-     * _add_feature_pointers
383
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
384
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
385
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
386
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
387
-     * extended) also see:
388
-     *
389
-     * @link   http://eamann.com/tech/wordpress-portland/
390
-     * @abstract
391
-     * @return void
392
-     */
393
-    abstract protected function _add_feature_pointers();
394
-
395
-
396
-    /**
397
-     * load_scripts_styles
398
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
399
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
400
-     * scripts/styles per view by putting them in a dynamic function in this format
401
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
402
-     *
403
-     * @abstract
404
-     * @return void
405
-     */
406
-    abstract public function load_scripts_styles();
407
-
408
-
409
-    /**
410
-     * admin_init
411
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
412
-     * all pages/views loaded by child class.
413
-     *
414
-     * @abstract
415
-     * @return void
416
-     */
417
-    abstract public function admin_init();
418
-
419
-
420
-    /**
421
-     * admin_notices
422
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
423
-     * all pages/views loaded by child class.
424
-     *
425
-     * @abstract
426
-     * @return void
427
-     */
428
-    abstract public function admin_notices();
429
-
430
-
431
-    /**
432
-     * admin_footer_scripts
433
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
434
-     * will apply to all pages/views loaded by child class.
435
-     *
436
-     * @return void
437
-     */
438
-    abstract public function admin_footer_scripts();
439
-
440
-
441
-    /**
442
-     * admin_footer
443
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
444
-     * apply to all pages/views loaded by child class.
445
-     *
446
-     * @return void
447
-     */
448
-    public function admin_footer()
449
-    {
450
-    }
451
-
452
-
453
-    /**
454
-     * _global_ajax_hooks
455
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
456
-     * Note: within the ajax callback methods.
457
-     *
458
-     * @abstract
459
-     * @return void
460
-     */
461
-    protected function _global_ajax_hooks()
462
-    {
463
-        // for lazy loading of metabox content
464
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
465
-    }
466
-
467
-
468
-    public function ajax_metabox_content()
469
-    {
470
-        $content_id  = $this->request->getRequestParam('contentid', '');
471
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
472
-        self::cached_rss_display($content_id, $content_url);
473
-        wp_die();
474
-    }
475
-
476
-
477
-    /**
478
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
479
-     *
480
-     * @return void
481
-     */
482
-    protected function _before_page_setup()
483
-    {
484
-        // default is to do nothing
485
-    }
486
-
487
-
488
-    /**
489
-     * Makes sure any things that need to be loaded early get handled.
490
-     * We also escape early here if the page requested doesn't match the object.
491
-     *
492
-     * @final
493
-     * @return void
494
-     * @throws EE_Error
495
-     * @throws InvalidArgumentException
496
-     * @throws ReflectionException
497
-     * @throws InvalidDataTypeException
498
-     * @throws InvalidInterfaceException
499
-     */
500
-    final protected function _page_setup()
501
-    {
502
-        // requires?
503
-        // admin_init stuff - global - we're setting this REALLY early
504
-        // so if EE_Admin pages have to hook into other WP pages they can.
505
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
507
-        // next verify if we need to load anything...
508
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
-        $this->_current_page = $this->request->getRequestParam('current_page', $this->_current_page, 'key');
510
-
511
-        $this->page_folder   = strtolower(
512
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
513
-        );
514
-        global $ee_menu_slugs;
515
-        $ee_menu_slugs = (array) $ee_menu_slugs;
516
-        if (
517
-            ! $this->request->isAjax()
518
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
519
-        ) {
520
-            return;
521
-        }
522
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
523
-        // we need to copy the action from the second to the first
524
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
525
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
526
-        $action     = $action !== '-1' ? $action : $action2;
527
-        $req_action = $action !== '-1' ? $action : 'default';
528
-
529
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
530
-        // then let's use the route as the action.
531
-        // This covers cases where we're coming in from a list table that isn't on the default route.
532
-        $route = $this->request->getRequestParam('route');
533
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
534
-            ? $route
535
-            : $req_action;
536
-
537
-        $this->_current_view = $this->_req_action;
538
-        $this->_req_nonce    = $this->_req_action . '_nonce';
539
-        $this->_define_page_props();
540
-        $this->_current_page_view_url = add_query_arg(
541
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
542
-            $this->_admin_base_url
543
-        );
544
-        // default things
545
-        $this->_default_espresso_metaboxes = [
546
-            '_espresso_news_post_box',
547
-            '_espresso_links_post_box',
548
-            '_espresso_ratings_request',
549
-            '_espresso_sponsors_post_box',
550
-        ];
551
-        // set page configs
552
-        $this->_set_page_routes();
553
-        $this->_set_page_config();
554
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
555
-        if ($this->request->requestParamIsSet('wp_referer')) {
556
-            $wp_referer = $this->request->getRequestParam('wp_referer');
557
-            if ($wp_referer) {
558
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
559
-            }
560
-        }
561
-        // for caffeinated and other extended functionality.
562
-        //  If there is a _extend_page_config method
563
-        // then let's run that to modify the all the various page configuration arrays
564
-        if (method_exists($this, '_extend_page_config')) {
565
-            $this->_extend_page_config();
566
-        }
567
-        // for CPT and other extended functionality.
568
-        // If there is an _extend_page_config_for_cpt
569
-        // then let's run that to modify all the various page configuration arrays.
570
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
571
-            $this->_extend_page_config_for_cpt();
572
-        }
573
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
574
-        $this->_page_routes = apply_filters(
575
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
576
-            $this->_page_routes,
577
-            $this
578
-        );
579
-        $this->_page_config = apply_filters(
580
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
581
-            $this->_page_config,
582
-            $this
583
-        );
584
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
585
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
586
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
587
-            add_action(
588
-                'AHEE__EE_Admin_Page__route_admin_request',
589
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
590
-                10,
591
-                2
592
-            );
593
-        }
594
-        // next route only if routing enabled
595
-        if ($this->_routing && ! $this->request->isAjax()) {
596
-            $this->_verify_routes();
597
-            // next let's just check user_access and kill if no access
598
-            $this->check_user_access();
599
-            if ($this->_is_UI_request) {
600
-                // admin_init stuff - global, all views for this page class, specific view
601
-                add_action('admin_init', [$this, 'admin_init'], 10);
602
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
603
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
604
-                }
605
-            } else {
606
-                // hijack regular WP loading and route admin request immediately
607
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
608
-                $this->route_admin_request();
609
-            }
610
-        }
611
-    }
612
-
613
-
614
-    /**
615
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
616
-     *
617
-     * @return void
618
-     * @throws EE_Error
619
-     */
620
-    private function _do_other_page_hooks()
621
-    {
622
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
623
-        foreach ($registered_pages as $page) {
624
-            // now let's setup the file name and class that should be present
625
-            $classname = str_replace('.class.php', '', $page);
626
-            // autoloaders should take care of loading file
627
-            if (! class_exists($classname)) {
628
-                $error_msg[] = sprintf(
629
-                    esc_html__(
630
-                        'Something went wrong with loading the %s admin hooks page.',
631
-                        'event_espresso'
632
-                    ),
633
-                    $page
634
-                );
635
-                $error_msg[] = $error_msg[0]
636
-                               . "\r\n"
637
-                               . sprintf(
638
-                                   esc_html__(
639
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
640
-                                       'event_espresso'
641
-                                   ),
642
-                                   $page,
643
-                                   '<br />',
644
-                                   '<strong>' . $classname . '</strong>'
645
-                               );
646
-                throw new EE_Error(implode('||', $error_msg));
647
-            }
648
-            // notice we are passing the instance of this class to the hook object.
649
-            $this->loader->getShared($classname, [$this]);
650
-        }
651
-    }
652
-
653
-
654
-    /**
655
-     * @throws ReflectionException
656
-     * @throws EE_Error
657
-     */
658
-    public function load_page_dependencies()
659
-    {
660
-        try {
661
-            $this->_load_page_dependencies();
662
-        } catch (EE_Error $e) {
663
-            $e->get_error();
664
-        }
665
-    }
666
-
667
-
668
-    /**
669
-     * load_page_dependencies
670
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
671
-     *
672
-     * @return void
673
-     * @throws DomainException
674
-     * @throws EE_Error
675
-     * @throws InvalidArgumentException
676
-     * @throws InvalidDataTypeException
677
-     * @throws InvalidInterfaceException
678
-     */
679
-    protected function _load_page_dependencies()
680
-    {
681
-        // let's set the current_screen and screen options to override what WP set
682
-        $this->_current_screen = get_current_screen();
683
-        // load admin_notices - global, page class, and view specific
684
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
685
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
686
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
687
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
688
-        }
689
-        // load network admin_notices - global, page class, and view specific
690
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
691
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
692
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
693
-        }
694
-        // this will save any per_page screen options if they are present
695
-        $this->_set_per_page_screen_options();
696
-        // setup list table properties
697
-        $this->_set_list_table();
698
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
699
-        // However in some cases the metaboxes will need to be added within a route handling callback.
700
-        $this->_add_registered_meta_boxes();
701
-        $this->_add_screen_columns();
702
-        // add screen options - global, page child class, and view specific
703
-        $this->_add_global_screen_options();
704
-        $this->_add_screen_options();
705
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
706
-        if (method_exists($this, $add_screen_options)) {
707
-            $this->{$add_screen_options}();
708
-        }
709
-        // add help tab(s) - set via page_config and qtips.
710
-        $this->_add_help_tabs();
711
-        $this->_add_qtips();
712
-        // add feature_pointers - global, page child class, and view specific
713
-        $this->_add_feature_pointers();
714
-        $this->_add_global_feature_pointers();
715
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
716
-        if (method_exists($this, $add_feature_pointer)) {
717
-            $this->{$add_feature_pointer}();
718
-        }
719
-        // enqueue scripts/styles - global, page class, and view specific
720
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
721
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
722
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
723
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
724
-        }
725
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
726
-        // admin_print_footer_scripts - global, page child class, and view specific.
727
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
728
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
729
-        // is a good use case. Notice the late priority we're giving these
730
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
731
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
732
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
733
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
734
-        }
735
-        // admin footer scripts
736
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
737
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
738
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
739
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
740
-        }
741
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
742
-        // targeted hook
743
-        do_action(
744
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
745
-        );
746
-    }
747
-
748
-
749
-    /**
750
-     * _set_defaults
751
-     * This sets some global defaults for class properties.
752
-     */
753
-    private function _set_defaults()
754
-    {
755
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
756
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
757
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
758
-        $this->_page_config          = $this->_default_route_query_args = [];
759
-        $this->_default_nav_tab_name = 'overview';
760
-        // init template args
761
-        $this->_template_args = [
762
-            'admin_page_header'  => '',
763
-            'admin_page_content' => '',
764
-            'post_body_content'  => '',
765
-            'before_list_table'  => '',
766
-            'after_list_table'   => '',
767
-        ];
768
-    }
769
-
770
-
771
-    /**
772
-     * route_admin_request
773
-     *
774
-     * @return void
775
-     * @throws InvalidArgumentException
776
-     * @throws InvalidInterfaceException
777
-     * @throws InvalidDataTypeException
778
-     * @throws EE_Error
779
-     * @throws ReflectionException
780
-     * @see    _route_admin_request()
781
-     */
782
-    public function route_admin_request()
783
-    {
784
-        try {
785
-            $this->_route_admin_request();
786
-        } catch (EE_Error $e) {
787
-            $e->get_error();
788
-        }
789
-    }
790
-
791
-
792
-    public function set_wp_page_slug($wp_page_slug)
793
-    {
794
-        $this->_wp_page_slug = $wp_page_slug;
795
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
796
-        if (is_network_admin()) {
797
-            $this->_wp_page_slug .= '-network';
798
-        }
799
-    }
800
-
801
-
802
-    /**
803
-     * _verify_routes
804
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
805
-     * we know if we need to drop out.
806
-     *
807
-     * @return bool
808
-     * @throws EE_Error
809
-     */
810
-    protected function _verify_routes()
811
-    {
812
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
813
-        if (! $this->_current_page && ! $this->request->isAjax()) {
814
-            return false;
815
-        }
816
-        $this->_route = false;
817
-        // check that the page_routes array is not empty
818
-        if (empty($this->_page_routes)) {
819
-            // user error msg
820
-            $error_msg = sprintf(
821
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
822
-                $this->_admin_page_title
823
-            );
824
-            // developer error msg
825
-            $error_msg .= '||' . $error_msg
826
-                          . esc_html__(
827
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
828
-                              'event_espresso'
829
-                          );
830
-            throw new EE_Error($error_msg);
831
-        }
832
-        // and that the requested page route exists
833
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
834
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
835
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
836
-                ? $this->_page_config[ $this->_req_action ]
837
-                : [];
838
-        } else {
839
-            // user error msg
840
-            $error_msg = sprintf(
841
-                esc_html__(
842
-                    'The requested page route does not exist for the %s admin page.',
843
-                    'event_espresso'
844
-                ),
845
-                $this->_admin_page_title
846
-            );
847
-            // developer error msg
848
-            $error_msg .= '||' . $error_msg
849
-                          . sprintf(
850
-                              esc_html__(
851
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
852
-                                  'event_espresso'
853
-                              ),
854
-                              $this->_req_action
855
-                          );
856
-            throw new EE_Error($error_msg);
857
-        }
858
-        // and that a default route exists
859
-        if (! array_key_exists('default', $this->_page_routes)) {
860
-            // user error msg
861
-            $error_msg = sprintf(
862
-                esc_html__(
863
-                    'A default page route has not been set for the % admin page.',
864
-                    'event_espresso'
865
-                ),
866
-                $this->_admin_page_title
867
-            );
868
-            // developer error msg
869
-            $error_msg .= '||' . $error_msg
870
-                          . esc_html__(
871
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
872
-                              'event_espresso'
873
-                          );
874
-            throw new EE_Error($error_msg);
875
-        }
876
-        // first lets' catch if the UI request has EVER been set.
877
-        if ($this->_is_UI_request === null) {
878
-            // lets set if this is a UI request or not.
879
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
880
-            // wait a minute... we might have a noheader in the route array
881
-            $this->_is_UI_request = ! (
882
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
883
-            )
884
-                ? $this->_is_UI_request
885
-                : false;
886
-        }
887
-        $this->_set_current_labels();
888
-        return true;
889
-    }
890
-
891
-
892
-    /**
893
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
894
-     *
895
-     * @param string $route the route name we're verifying
896
-     * @return bool we'll throw an exception if this isn't a valid route.
897
-     * @throws EE_Error
898
-     */
899
-    protected function _verify_route($route)
900
-    {
901
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
902
-            return true;
903
-        }
904
-        // user error msg
905
-        $error_msg = sprintf(
906
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
907
-            $this->_admin_page_title
908
-        );
909
-        // developer error msg
910
-        $error_msg .= '||' . $error_msg
911
-                      . sprintf(
912
-                          esc_html__(
913
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
914
-                              'event_espresso'
915
-                          ),
916
-                          $route
917
-                      );
918
-        throw new EE_Error($error_msg);
919
-    }
920
-
921
-
922
-    /**
923
-     * perform nonce verification
924
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
925
-     * using this method (and save retyping!)
926
-     *
927
-     * @param string $nonce     The nonce sent
928
-     * @param string $nonce_ref The nonce reference string (name0)
929
-     * @return void
930
-     * @throws EE_Error
931
-     */
932
-    protected function _verify_nonce($nonce, $nonce_ref)
933
-    {
934
-        // verify nonce against expected value
935
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
936
-            // these are not the droids you are looking for !!!
937
-            $msg = sprintf(
938
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
939
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
940
-                '</a>'
941
-            );
942
-            if (WP_DEBUG) {
943
-                $msg .= "\n  ";
944
-                $msg .= sprintf(
945
-                    esc_html__(
946
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
947
-                        'event_espresso'
948
-                    ),
949
-                    __CLASS__
950
-                );
951
-            }
952
-            if (! $this->request->isAjax()) {
953
-                wp_die($msg);
954
-            }
955
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
956
-            $this->_return_json();
957
-        }
958
-    }
959
-
960
-
961
-    /**
962
-     * _route_admin_request()
963
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
964
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
965
-     * in the page routes and then will try to load the corresponding method.
966
-     *
967
-     * @return void
968
-     * @throws EE_Error
969
-     * @throws InvalidArgumentException
970
-     * @throws InvalidDataTypeException
971
-     * @throws InvalidInterfaceException
972
-     * @throws ReflectionException
973
-     */
974
-    protected function _route_admin_request()
975
-    {
976
-        if (! $this->_is_UI_request) {
977
-            $this->_verify_routes();
978
-        }
979
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
980
-        if ($this->_req_action !== 'default' && $nonce_check) {
981
-            // set nonce from post data
982
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
983
-            $this->_verify_nonce($nonce, $this->_req_nonce);
984
-        }
985
-        // set the nav_tabs array but ONLY if this is  UI_request
986
-        if ($this->_is_UI_request) {
987
-            $this->_set_nav_tabs();
988
-        }
989
-        // grab callback function
990
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
991
-        // check if callback has args
992
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
993
-        $error_msg = '';
994
-        // action right before calling route
995
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
996
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
997
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
998
-        }
999
-        // right before calling the route, let's clean the _wp_http_referer
1000
-        $this->request->unSetRequestParam('_wp_http_referer');
1001
-        $this->request->unSetServerParam('_wp_http_referer');
1002
-        $cleaner_request_uri = remove_query_arg(
1003
-            '_wp_http_referer',
1004
-            wp_unslash($this->request->getServerParam('REQUEST_URI'))
1005
-        );
1006
-        $this->request->setRequestParam('_wp_http_referer', $cleaner_request_uri);
1007
-        $this->request->setServerParam('REQUEST_URI', $cleaner_request_uri);
1008
-        if (! empty($func)) {
1009
-            if (is_array($func)) {
1010
-                [$class, $method] = $func;
1011
-            } elseif (strpos($func, '::') !== false) {
1012
-                [$class, $method] = explode('::', $func);
1013
-            } else {
1014
-                $class  = $this;
1015
-                $method = $func;
1016
-            }
1017
-            if (! (is_object($class) && $class === $this)) {
1018
-                // send along this admin page object for access by addons.
1019
-                $args['admin_page_object'] = $this;
1020
-            }
1021
-            if (
1022
-                // is it a method on a class that doesn't work?
1023
-                (
1024
-                    (
1025
-                        method_exists($class, $method)
1026
-                        && call_user_func_array([$class, $method], $args) === false
1027
-                    )
1028
-                    && (
1029
-                        // is it a standalone function that doesn't work?
1030
-                        function_exists($method)
1031
-                        && call_user_func_array(
1032
-                            $func,
1033
-                            array_merge(['admin_page_object' => $this], $args)
1034
-                        ) === false
1035
-                    )
1036
-                )
1037
-                || (
1038
-                    // is it neither a class method NOR a standalone function?
1039
-                    ! method_exists($class, $method)
1040
-                    && ! function_exists($method)
1041
-                )
1042
-            ) {
1043
-                // user error msg
1044
-                $error_msg = esc_html__(
1045
-                    'An error occurred. The  requested page route could not be found.',
1046
-                    'event_espresso'
1047
-                );
1048
-                // developer error msg
1049
-                $error_msg .= '||';
1050
-                $error_msg .= sprintf(
1051
-                    esc_html__(
1052
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1053
-                        'event_espresso'
1054
-                    ),
1055
-                    $method
1056
-                );
1057
-            }
1058
-            if (! empty($error_msg)) {
1059
-                throw new EE_Error($error_msg);
1060
-            }
1061
-        }
1062
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1063
-        // then we need to reset the routing properties to the new route.
1064
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1065
-        if (
1066
-            $this->_is_UI_request === false
1067
-            && is_array($this->_route)
1068
-            && ! empty($this->_route['headers_sent_route'])
1069
-        ) {
1070
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1071
-        }
1072
-    }
1073
-
1074
-
1075
-    /**
1076
-     * This method just allows the resetting of page properties in the case where a no headers
1077
-     * route redirects to a headers route in its route config.
1078
-     *
1079
-     * @param string $new_route New (non header) route to redirect to.
1080
-     * @return   void
1081
-     * @throws ReflectionException
1082
-     * @throws InvalidArgumentException
1083
-     * @throws InvalidInterfaceException
1084
-     * @throws InvalidDataTypeException
1085
-     * @throws EE_Error
1086
-     * @since   4.3.0
1087
-     */
1088
-    protected function _reset_routing_properties($new_route)
1089
-    {
1090
-        $this->_is_UI_request = true;
1091
-        // now we set the current route to whatever the headers_sent_route is set at
1092
-        $this->request->setRequestParam('action', $new_route);
1093
-        // rerun page setup
1094
-        $this->_page_setup();
1095
-    }
1096
-
1097
-
1098
-    /**
1099
-     * _add_query_arg
1100
-     * adds nonce to array of arguments then calls WP add_query_arg function
1101
-     *(internally just uses EEH_URL's function with the same name)
1102
-     *
1103
-     * @param array  $args
1104
-     * @param string $url
1105
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1106
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1107
-     *                                        Example usage: If the current page is:
1108
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1109
-     *                                        &action=default&event_id=20&month_range=March%202015
1110
-     *                                        &_wpnonce=5467821
1111
-     *                                        and you call:
1112
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1113
-     *                                        array(
1114
-     *                                        'action' => 'resend_something',
1115
-     *                                        'page=>espresso_registrations'
1116
-     *                                        ),
1117
-     *                                        $some_url,
1118
-     *                                        true
1119
-     *                                        );
1120
-     *                                        It will produce a url in this structure:
1121
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1122
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1123
-     *                                        month_range]=March%202015
1124
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1125
-     * @return string
1126
-     */
1127
-    public static function add_query_args_and_nonce(
1128
-        $args = [],
1129
-        $url = false,
1130
-        $sticky = false,
1131
-        $exclude_nonce = false
1132
-    ) {
1133
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1134
-        if ($sticky) {
1135
-            /** @var RequestInterface $request */
1136
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1137
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer'], true);
1138
-            foreach ($request->requestParams() as $key => $value) {
1139
-                // do not add nonces
1140
-                if (strpos($key, 'nonce') !== false) {
1141
-                    continue;
1142
-                }
1143
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1144
-            }
1145
-        }
1146
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1147
-    }
1148
-
1149
-
1150
-    /**
1151
-     * This returns a generated link that will load the related help tab.
1152
-     *
1153
-     * @param string $help_tab_id the id for the connected help tab
1154
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1155
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1156
-     * @return string              generated link
1157
-     * @uses EEH_Template::get_help_tab_link()
1158
-     */
1159
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1160
-    {
1161
-        return EEH_Template::get_help_tab_link(
1162
-            $help_tab_id,
1163
-            $this->page_slug,
1164
-            $this->_req_action,
1165
-            $icon_style,
1166
-            $help_text
1167
-        );
1168
-    }
1169
-
1170
-
1171
-    /**
1172
-     * _add_help_tabs
1173
-     * Note child classes define their help tabs within the page_config array.
1174
-     *
1175
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1176
-     * @return void
1177
-     * @throws DomainException
1178
-     * @throws EE_Error
1179
-     */
1180
-    protected function _add_help_tabs()
1181
-    {
1182
-        if (isset($this->_page_config[ $this->_req_action ])) {
1183
-            $config = $this->_page_config[ $this->_req_action ];
1184
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1185
-            if (is_array($config) && isset($config['help_sidebar'])) {
1186
-                // check that the callback given is valid
1187
-                if (! method_exists($this, $config['help_sidebar'])) {
1188
-                    throw new EE_Error(
1189
-                        sprintf(
1190
-                            esc_html__(
1191
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1192
-                                'event_espresso'
1193
-                            ),
1194
-                            $config['help_sidebar'],
1195
-                            get_class($this)
1196
-                        )
1197
-                    );
1198
-                }
1199
-                $content = apply_filters(
1200
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1201
-                    $this->{$config['help_sidebar']}()
1202
-                );
1203
-                $this->_current_screen->set_help_sidebar($content);
1204
-            }
1205
-            if (! isset($config['help_tabs'])) {
1206
-                return;
1207
-            } //no help tabs for this route
1208
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1209
-                // we're here so there ARE help tabs!
1210
-                // make sure we've got what we need
1211
-                if (! isset($cfg['title'])) {
1212
-                    throw new EE_Error(
1213
-                        esc_html__(
1214
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1215
-                            'event_espresso'
1216
-                        )
1217
-                    );
1218
-                }
1219
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1220
-                    throw new EE_Error(
1221
-                        esc_html__(
1222
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1223
-                            'event_espresso'
1224
-                        )
1225
-                    );
1226
-                }
1227
-                // first priority goes to content.
1228
-                if (! empty($cfg['content'])) {
1229
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1230
-                    // second priority goes to filename
1231
-                } elseif (! empty($cfg['filename'])) {
1232
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1233
-                    // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1234
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1235
-                                                             . basename($this->_get_dir())
1236
-                                                             . '/help_tabs/'
1237
-                                                             . $cfg['filename']
1238
-                                                             . '.help_tab.php' : $file_path;
1239
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1240
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1241
-                        EE_Error::add_error(
1242
-                            sprintf(
1243
-                                esc_html__(
1244
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1245
-                                    'event_espresso'
1246
-                                ),
1247
-                                $tab_id,
1248
-                                key($config),
1249
-                                $file_path
1250
-                            ),
1251
-                            __FILE__,
1252
-                            __FUNCTION__,
1253
-                            __LINE__
1254
-                        );
1255
-                        return;
1256
-                    }
1257
-                    $template_args['admin_page_obj'] = $this;
1258
-                    $content                         = EEH_Template::display_template(
1259
-                        $file_path,
1260
-                        $template_args,
1261
-                        true
1262
-                    );
1263
-                } else {
1264
-                    $content = '';
1265
-                }
1266
-                // check if callback is valid
1267
-                if (
1268
-                    empty($content)
1269
-                    && (
1270
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1271
-                    )
1272
-                ) {
1273
-                    EE_Error::add_error(
1274
-                        sprintf(
1275
-                            esc_html__(
1276
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1277
-                                'event_espresso'
1278
-                            ),
1279
-                            $cfg['title']
1280
-                        ),
1281
-                        __FILE__,
1282
-                        __FUNCTION__,
1283
-                        __LINE__
1284
-                    );
1285
-                    return;
1286
-                }
1287
-                // setup config array for help tab method
1288
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1289
-                $_ht = [
1290
-                    'id'       => $id,
1291
-                    'title'    => $cfg['title'],
1292
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1293
-                    'content'  => $content,
1294
-                ];
1295
-                $this->_current_screen->add_help_tab($_ht);
1296
-            }
1297
-        }
1298
-    }
1299
-
1300
-
1301
-    /**
1302
-     * This simply sets up any qtips that have been defined in the page config
1303
-     *
1304
-     * @return void
1305
-     */
1306
-    protected function _add_qtips()
1307
-    {
1308
-        if (isset($this->_route_config['qtips'])) {
1309
-            $qtips = (array) $this->_route_config['qtips'];
1310
-            // load qtip loader
1311
-            $path = [
1312
-                $this->_get_dir() . '/qtips/',
1313
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1314
-            ];
1315
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1316
-        }
1317
-    }
1318
-
1319
-
1320
-    /**
1321
-     * _set_nav_tabs
1322
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1323
-     * wish to add additional tabs or modify accordingly.
1324
-     *
1325
-     * @return void
1326
-     * @throws InvalidArgumentException
1327
-     * @throws InvalidInterfaceException
1328
-     * @throws InvalidDataTypeException
1329
-     */
1330
-    protected function _set_nav_tabs()
1331
-    {
1332
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1333
-        $i = 0;
1334
-        foreach ($this->_page_config as $slug => $config) {
1335
-            if (! is_array($config) || empty($config['nav'])) {
1336
-                continue;
1337
-            }
1338
-            // no nav tab for this config
1339
-            // check for persistent flag
1340
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1341
-                // nav tab is only to appear when route requested.
1342
-                continue;
1343
-            }
1344
-            if (! $this->check_user_access($slug, true)) {
1345
-                // no nav tab because current user does not have access.
1346
-                continue;
1347
-            }
1348
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1349
-            $this->_nav_tabs[ $slug ] = [
1350
-                'url'       => isset($config['nav']['url'])
1351
-                    ? $config['nav']['url']
1352
-                    : self::add_query_args_and_nonce(
1353
-                        ['action' => $slug],
1354
-                        $this->_admin_base_url
1355
-                    ),
1356
-                'link_text' => isset($config['nav']['label'])
1357
-                    ? $config['nav']['label']
1358
-                    : ucwords(
1359
-                        str_replace('_', ' ', $slug)
1360
-                    ),
1361
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1362
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1363
-            ];
1364
-            $i++;
1365
-        }
1366
-        // if $this->_nav_tabs is empty then lets set the default
1367
-        if (empty($this->_nav_tabs)) {
1368
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1369
-                'url'       => $this->_admin_base_url,
1370
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1371
-                'css_class' => 'nav-tab-active',
1372
-                'order'     => 10,
1373
-            ];
1374
-        }
1375
-        // now let's sort the tabs according to order
1376
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1377
-    }
1378
-
1379
-
1380
-    /**
1381
-     * _set_current_labels
1382
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1383
-     * property array
1384
-     *
1385
-     * @return void
1386
-     */
1387
-    private function _set_current_labels()
1388
-    {
1389
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1390
-            foreach ($this->_route_config['labels'] as $label => $text) {
1391
-                if (is_array($text)) {
1392
-                    foreach ($text as $sublabel => $subtext) {
1393
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1394
-                    }
1395
-                } else {
1396
-                    $this->_labels[ $label ] = $text;
1397
-                }
1398
-            }
1399
-        }
1400
-    }
1401
-
1402
-
1403
-    /**
1404
-     *        verifies user access for this admin page
1405
-     *
1406
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1407
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1408
-     *                               return false if verify fail.
1409
-     * @return bool
1410
-     * @throws InvalidArgumentException
1411
-     * @throws InvalidDataTypeException
1412
-     * @throws InvalidInterfaceException
1413
-     */
1414
-    public function check_user_access($route_to_check = '', $verify_only = false)
1415
-    {
1416
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1417
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1418
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1419
-                          && is_array(
1420
-                              $this->_page_routes[ $route_to_check ]
1421
-                          )
1422
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1423
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1424
-        if (empty($capability) && empty($route_to_check)) {
1425
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1426
-                : $this->_route['capability'];
1427
-        } else {
1428
-            $capability = empty($capability) ? 'manage_options' : $capability;
1429
-        }
1430
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1431
-        if (
1432
-            ! $this->request->isAjax()
1433
-            && (
1434
-                ! function_exists('is_admin')
1435
-                || ! EE_Registry::instance()->CAP->current_user_can(
1436
-                    $capability,
1437
-                    $this->page_slug
1438
-                    . '_'
1439
-                    . $route_to_check,
1440
-                    $id
1441
-                )
1442
-            )
1443
-        ) {
1444
-            if ($verify_only) {
1445
-                return false;
1446
-            }
1447
-            if (is_user_logged_in()) {
1448
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1449
-            } else {
1450
-                return false;
1451
-            }
1452
-        }
1453
-        return true;
1454
-    }
1455
-
1456
-
1457
-    /**
1458
-     * admin_init_global
1459
-     * This runs all the code that we want executed within the WP admin_init hook.
1460
-     * This method executes for ALL EE Admin pages.
1461
-     *
1462
-     * @return void
1463
-     */
1464
-    public function admin_init_global()
1465
-    {
1466
-    }
1467
-
1468
-
1469
-    /**
1470
-     * wp_loaded_global
1471
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1472
-     * EE_Admin page and will execute on every EE Admin Page load
1473
-     *
1474
-     * @return void
1475
-     */
1476
-    public function wp_loaded()
1477
-    {
1478
-    }
1479
-
1480
-
1481
-    /**
1482
-     * admin_notices
1483
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1484
-     * ALL EE_Admin pages.
1485
-     *
1486
-     * @return void
1487
-     */
1488
-    public function admin_notices_global()
1489
-    {
1490
-        $this->_display_no_javascript_warning();
1491
-        $this->_display_espresso_notices();
1492
-    }
1493
-
1494
-
1495
-    public function network_admin_notices_global()
1496
-    {
1497
-        $this->_display_no_javascript_warning();
1498
-        $this->_display_espresso_notices();
1499
-    }
1500
-
1501
-
1502
-    /**
1503
-     * admin_footer_scripts_global
1504
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1505
-     * will apply on ALL EE_Admin pages.
1506
-     *
1507
-     * @return void
1508
-     */
1509
-    public function admin_footer_scripts_global()
1510
-    {
1511
-        $this->_add_admin_page_ajax_loading_img();
1512
-        $this->_add_admin_page_overlay();
1513
-        // if metaboxes are present we need to add the nonce field
1514
-        if (
1515
-            isset($this->_route_config['metaboxes'])
1516
-            || isset($this->_route_config['list_table'])
1517
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1518
-        ) {
1519
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1520
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1521
-        }
1522
-    }
1523
-
1524
-
1525
-    /**
1526
-     * admin_footer_global
1527
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1528
-     * ALL EE_Admin Pages.
1529
-     *
1530
-     * @return void
1531
-     */
1532
-    public function admin_footer_global()
1533
-    {
1534
-        // dialog container for dialog helper
1535
-        echo '
110
+	/**
111
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
112
+	 * actions.
113
+	 *
114
+	 * @since 4.6.x
115
+	 * @var array.
116
+	 */
117
+	protected $_default_route_query_args;
118
+
119
+	// set via request page and action args.
120
+	protected $_current_page;
121
+
122
+	protected $_current_view;
123
+
124
+	protected $_current_page_view_url;
125
+
126
+	/**
127
+	 * unprocessed value for the 'action' request param (default '')
128
+	 *
129
+	 * @var string
130
+	 */
131
+	protected $raw_req_action = '';
132
+
133
+	/**
134
+	 * unprocessed value for the 'page' request param (default '')
135
+	 *
136
+	 * @var string
137
+	 */
138
+	protected $raw_req_page = '';
139
+
140
+	/**
141
+	 * sanitized request action (and nonce)
142
+	 *
143
+	 * @var string
144
+	 */
145
+	protected $_req_action = '';
146
+
147
+	/**
148
+	 * sanitized request action nonce
149
+	 *
150
+	 * @var string
151
+	 */
152
+	protected $_req_nonce = '';
153
+
154
+	/**
155
+	 * @var string
156
+	 */
157
+	protected $_search_btn_label = '';
158
+
159
+	/**
160
+	 * @var string
161
+	 */
162
+	protected $_search_box_callback = '';
163
+
164
+	/**
165
+	 * @var WP_Screen
166
+	 */
167
+	protected $_current_screen;
168
+
169
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
170
+	protected $_hook_obj;
171
+
172
+	// for holding incoming request data
173
+	protected $_req_data = [];
174
+
175
+	// yes / no array for admin form fields
176
+	protected $_yes_no_values = [];
177
+
178
+	// some default things shared by all child classes
179
+	protected $_default_espresso_metaboxes;
180
+
181
+	/**
182
+	 * @var EE_Registry
183
+	 */
184
+	protected $EE = null;
185
+
186
+
187
+	/**
188
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
189
+	 *
190
+	 * @var boolean
191
+	 */
192
+	protected $_is_caf = false;
193
+
194
+
195
+	/**
196
+	 * @Constructor
197
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
198
+	 * @throws EE_Error
199
+	 * @throws InvalidArgumentException
200
+	 * @throws ReflectionException
201
+	 * @throws InvalidDataTypeException
202
+	 * @throws InvalidInterfaceException
203
+	 */
204
+	public function __construct($routing = true)
205
+	{
206
+		$this->loader  = LoaderFactory::getLoader();
207
+		$this->request = $this->loader->getShared(RequestInterface::class);
208
+		$this->_routing = $routing;
209
+
210
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
211
+			$this->_is_caf = true;
212
+		}
213
+		$this->_yes_no_values = [
214
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
215
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
216
+		];
217
+		// set the _req_data property.
218
+		$this->_req_data = $this->request->requestParams();
219
+		// set initial page props (child method)
220
+		$this->_init_page_props();
221
+		// set global defaults
222
+		$this->_set_defaults();
223
+		// set early because incoming requests could be ajax related and we need to register those hooks.
224
+		$this->_global_ajax_hooks();
225
+		$this->_ajax_hooks();
226
+		// other_page_hooks have to be early too.
227
+		$this->_do_other_page_hooks();
228
+		// set up page dependencies
229
+		$this->_before_page_setup();
230
+		$this->_page_setup();
231
+		// die();
232
+	}
233
+
234
+
235
+	/**
236
+	 * _init_page_props
237
+	 * Child classes use to set at least the following properties:
238
+	 * $page_slug.
239
+	 * $page_label.
240
+	 *
241
+	 * @abstract
242
+	 * @return void
243
+	 */
244
+	abstract protected function _init_page_props();
245
+
246
+
247
+	/**
248
+	 * _ajax_hooks
249
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
250
+	 * Note: within the ajax callback methods.
251
+	 *
252
+	 * @abstract
253
+	 * @return void
254
+	 */
255
+	abstract protected function _ajax_hooks();
256
+
257
+
258
+	/**
259
+	 * _define_page_props
260
+	 * child classes define page properties in here.  Must include at least:
261
+	 * $_admin_base_url = base_url for all admin pages
262
+	 * $_admin_page_title = default admin_page_title for admin pages
263
+	 * $_labels = array of default labels for various automatically generated elements:
264
+	 *    array(
265
+	 *        'buttons' => array(
266
+	 *            'add' => esc_html__('label for add new button'),
267
+	 *            'edit' => esc_html__('label for edit button'),
268
+	 *            'delete' => esc_html__('label for delete button')
269
+	 *            )
270
+	 *        )
271
+	 *
272
+	 * @abstract
273
+	 * @return void
274
+	 */
275
+	abstract protected function _define_page_props();
276
+
277
+
278
+	/**
279
+	 * _set_page_routes
280
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
281
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
282
+	 * have a 'default' route. Here's the format
283
+	 * $this->_page_routes = array(
284
+	 *        'default' => array(
285
+	 *            'func' => '_default_method_handling_route',
286
+	 *            'args' => array('array','of','args'),
287
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
288
+	 *            ajax request, backend processing)
289
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
290
+	 *            headers route after.  The string you enter here should match the defined route reference for a
291
+	 *            headers sent route.
292
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
293
+	 *            this route.
294
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
295
+	 *            checks).
296
+	 *        ),
297
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
298
+	 *        handling method.
299
+	 *        )
300
+	 * )
301
+	 *
302
+	 * @abstract
303
+	 * @return void
304
+	 */
305
+	abstract protected function _set_page_routes();
306
+
307
+
308
+	/**
309
+	 * _set_page_config
310
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
311
+	 * array corresponds to the page_route for the loaded page. Format:
312
+	 * $this->_page_config = array(
313
+	 *        'default' => array(
314
+	 *            'labels' => array(
315
+	 *                'buttons' => array(
316
+	 *                    'add' => esc_html__('label for adding item'),
317
+	 *                    'edit' => esc_html__('label for editing item'),
318
+	 *                    'delete' => esc_html__('label for deleting item')
319
+	 *                ),
320
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
321
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
322
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
323
+	 *            _define_page_props() method
324
+	 *            'nav' => array(
325
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
326
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
327
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
328
+	 *                'order' => 10, //required to indicate tab position.
329
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
330
+	 *                displayed then add this parameter.
331
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
332
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
333
+	 *            metaboxes set for eventespresso admin pages.
334
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
335
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
336
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
337
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
338
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
339
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
340
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
341
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
342
+	 *            want to display.
343
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
344
+	 *                'tab_id' => array(
345
+	 *                    'title' => 'tab_title',
346
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
347
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
348
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
349
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
350
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
351
+	 *                    attempt to use the callback which should match the name of a method in the class
352
+	 *                    ),
353
+	 *                'tab2_id' => array(
354
+	 *                    'title' => 'tab2 title',
355
+	 *                    'filename' => 'file_name_2'
356
+	 *                    'callback' => 'callback_method_for_content',
357
+	 *                 ),
358
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
359
+	 *            help tab area on an admin page. @return void
360
+	 *
361
+	 * @abstract
362
+	 */
363
+	abstract protected function _set_page_config();
364
+
365
+
366
+	/**
367
+	 * _add_screen_options
368
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
+	 * to a particular view.
371
+	 *
372
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
+	 *         see also WP_Screen object documents...
374
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
+	 * @abstract
376
+	 * @return void
377
+	 */
378
+	abstract protected function _add_screen_options();
379
+
380
+
381
+	/**
382
+	 * _add_feature_pointers
383
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
384
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
385
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
386
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
387
+	 * extended) also see:
388
+	 *
389
+	 * @link   http://eamann.com/tech/wordpress-portland/
390
+	 * @abstract
391
+	 * @return void
392
+	 */
393
+	abstract protected function _add_feature_pointers();
394
+
395
+
396
+	/**
397
+	 * load_scripts_styles
398
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
399
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
400
+	 * scripts/styles per view by putting them in a dynamic function in this format
401
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
402
+	 *
403
+	 * @abstract
404
+	 * @return void
405
+	 */
406
+	abstract public function load_scripts_styles();
407
+
408
+
409
+	/**
410
+	 * admin_init
411
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
412
+	 * all pages/views loaded by child class.
413
+	 *
414
+	 * @abstract
415
+	 * @return void
416
+	 */
417
+	abstract public function admin_init();
418
+
419
+
420
+	/**
421
+	 * admin_notices
422
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
423
+	 * all pages/views loaded by child class.
424
+	 *
425
+	 * @abstract
426
+	 * @return void
427
+	 */
428
+	abstract public function admin_notices();
429
+
430
+
431
+	/**
432
+	 * admin_footer_scripts
433
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
434
+	 * will apply to all pages/views loaded by child class.
435
+	 *
436
+	 * @return void
437
+	 */
438
+	abstract public function admin_footer_scripts();
439
+
440
+
441
+	/**
442
+	 * admin_footer
443
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
444
+	 * apply to all pages/views loaded by child class.
445
+	 *
446
+	 * @return void
447
+	 */
448
+	public function admin_footer()
449
+	{
450
+	}
451
+
452
+
453
+	/**
454
+	 * _global_ajax_hooks
455
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
456
+	 * Note: within the ajax callback methods.
457
+	 *
458
+	 * @abstract
459
+	 * @return void
460
+	 */
461
+	protected function _global_ajax_hooks()
462
+	{
463
+		// for lazy loading of metabox content
464
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
465
+	}
466
+
467
+
468
+	public function ajax_metabox_content()
469
+	{
470
+		$content_id  = $this->request->getRequestParam('contentid', '');
471
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
472
+		self::cached_rss_display($content_id, $content_url);
473
+		wp_die();
474
+	}
475
+
476
+
477
+	/**
478
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
479
+	 *
480
+	 * @return void
481
+	 */
482
+	protected function _before_page_setup()
483
+	{
484
+		// default is to do nothing
485
+	}
486
+
487
+
488
+	/**
489
+	 * Makes sure any things that need to be loaded early get handled.
490
+	 * We also escape early here if the page requested doesn't match the object.
491
+	 *
492
+	 * @final
493
+	 * @return void
494
+	 * @throws EE_Error
495
+	 * @throws InvalidArgumentException
496
+	 * @throws ReflectionException
497
+	 * @throws InvalidDataTypeException
498
+	 * @throws InvalidInterfaceException
499
+	 */
500
+	final protected function _page_setup()
501
+	{
502
+		// requires?
503
+		// admin_init stuff - global - we're setting this REALLY early
504
+		// so if EE_Admin pages have to hook into other WP pages they can.
505
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
507
+		// next verify if we need to load anything...
508
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
+		$this->_current_page = $this->request->getRequestParam('current_page', $this->_current_page, 'key');
510
+
511
+		$this->page_folder   = strtolower(
512
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
513
+		);
514
+		global $ee_menu_slugs;
515
+		$ee_menu_slugs = (array) $ee_menu_slugs;
516
+		if (
517
+			! $this->request->isAjax()
518
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
519
+		) {
520
+			return;
521
+		}
522
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
523
+		// we need to copy the action from the second to the first
524
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
525
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
526
+		$action     = $action !== '-1' ? $action : $action2;
527
+		$req_action = $action !== '-1' ? $action : 'default';
528
+
529
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
530
+		// then let's use the route as the action.
531
+		// This covers cases where we're coming in from a list table that isn't on the default route.
532
+		$route = $this->request->getRequestParam('route');
533
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
534
+			? $route
535
+			: $req_action;
536
+
537
+		$this->_current_view = $this->_req_action;
538
+		$this->_req_nonce    = $this->_req_action . '_nonce';
539
+		$this->_define_page_props();
540
+		$this->_current_page_view_url = add_query_arg(
541
+			['page' => $this->_current_page, 'action' => $this->_current_view],
542
+			$this->_admin_base_url
543
+		);
544
+		// default things
545
+		$this->_default_espresso_metaboxes = [
546
+			'_espresso_news_post_box',
547
+			'_espresso_links_post_box',
548
+			'_espresso_ratings_request',
549
+			'_espresso_sponsors_post_box',
550
+		];
551
+		// set page configs
552
+		$this->_set_page_routes();
553
+		$this->_set_page_config();
554
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
555
+		if ($this->request->requestParamIsSet('wp_referer')) {
556
+			$wp_referer = $this->request->getRequestParam('wp_referer');
557
+			if ($wp_referer) {
558
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
559
+			}
560
+		}
561
+		// for caffeinated and other extended functionality.
562
+		//  If there is a _extend_page_config method
563
+		// then let's run that to modify the all the various page configuration arrays
564
+		if (method_exists($this, '_extend_page_config')) {
565
+			$this->_extend_page_config();
566
+		}
567
+		// for CPT and other extended functionality.
568
+		// If there is an _extend_page_config_for_cpt
569
+		// then let's run that to modify all the various page configuration arrays.
570
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
571
+			$this->_extend_page_config_for_cpt();
572
+		}
573
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
574
+		$this->_page_routes = apply_filters(
575
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
576
+			$this->_page_routes,
577
+			$this
578
+		);
579
+		$this->_page_config = apply_filters(
580
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
581
+			$this->_page_config,
582
+			$this
583
+		);
584
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
585
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
586
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
587
+			add_action(
588
+				'AHEE__EE_Admin_Page__route_admin_request',
589
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
590
+				10,
591
+				2
592
+			);
593
+		}
594
+		// next route only if routing enabled
595
+		if ($this->_routing && ! $this->request->isAjax()) {
596
+			$this->_verify_routes();
597
+			// next let's just check user_access and kill if no access
598
+			$this->check_user_access();
599
+			if ($this->_is_UI_request) {
600
+				// admin_init stuff - global, all views for this page class, specific view
601
+				add_action('admin_init', [$this, 'admin_init'], 10);
602
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
603
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
604
+				}
605
+			} else {
606
+				// hijack regular WP loading and route admin request immediately
607
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
608
+				$this->route_admin_request();
609
+			}
610
+		}
611
+	}
612
+
613
+
614
+	/**
615
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
616
+	 *
617
+	 * @return void
618
+	 * @throws EE_Error
619
+	 */
620
+	private function _do_other_page_hooks()
621
+	{
622
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
623
+		foreach ($registered_pages as $page) {
624
+			// now let's setup the file name and class that should be present
625
+			$classname = str_replace('.class.php', '', $page);
626
+			// autoloaders should take care of loading file
627
+			if (! class_exists($classname)) {
628
+				$error_msg[] = sprintf(
629
+					esc_html__(
630
+						'Something went wrong with loading the %s admin hooks page.',
631
+						'event_espresso'
632
+					),
633
+					$page
634
+				);
635
+				$error_msg[] = $error_msg[0]
636
+							   . "\r\n"
637
+							   . sprintf(
638
+								   esc_html__(
639
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
640
+									   'event_espresso'
641
+								   ),
642
+								   $page,
643
+								   '<br />',
644
+								   '<strong>' . $classname . '</strong>'
645
+							   );
646
+				throw new EE_Error(implode('||', $error_msg));
647
+			}
648
+			// notice we are passing the instance of this class to the hook object.
649
+			$this->loader->getShared($classname, [$this]);
650
+		}
651
+	}
652
+
653
+
654
+	/**
655
+	 * @throws ReflectionException
656
+	 * @throws EE_Error
657
+	 */
658
+	public function load_page_dependencies()
659
+	{
660
+		try {
661
+			$this->_load_page_dependencies();
662
+		} catch (EE_Error $e) {
663
+			$e->get_error();
664
+		}
665
+	}
666
+
667
+
668
+	/**
669
+	 * load_page_dependencies
670
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
671
+	 *
672
+	 * @return void
673
+	 * @throws DomainException
674
+	 * @throws EE_Error
675
+	 * @throws InvalidArgumentException
676
+	 * @throws InvalidDataTypeException
677
+	 * @throws InvalidInterfaceException
678
+	 */
679
+	protected function _load_page_dependencies()
680
+	{
681
+		// let's set the current_screen and screen options to override what WP set
682
+		$this->_current_screen = get_current_screen();
683
+		// load admin_notices - global, page class, and view specific
684
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
685
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
686
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
687
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
688
+		}
689
+		// load network admin_notices - global, page class, and view specific
690
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
691
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
692
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
693
+		}
694
+		// this will save any per_page screen options if they are present
695
+		$this->_set_per_page_screen_options();
696
+		// setup list table properties
697
+		$this->_set_list_table();
698
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
699
+		// However in some cases the metaboxes will need to be added within a route handling callback.
700
+		$this->_add_registered_meta_boxes();
701
+		$this->_add_screen_columns();
702
+		// add screen options - global, page child class, and view specific
703
+		$this->_add_global_screen_options();
704
+		$this->_add_screen_options();
705
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
706
+		if (method_exists($this, $add_screen_options)) {
707
+			$this->{$add_screen_options}();
708
+		}
709
+		// add help tab(s) - set via page_config and qtips.
710
+		$this->_add_help_tabs();
711
+		$this->_add_qtips();
712
+		// add feature_pointers - global, page child class, and view specific
713
+		$this->_add_feature_pointers();
714
+		$this->_add_global_feature_pointers();
715
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
716
+		if (method_exists($this, $add_feature_pointer)) {
717
+			$this->{$add_feature_pointer}();
718
+		}
719
+		// enqueue scripts/styles - global, page class, and view specific
720
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
721
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
722
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
723
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
724
+		}
725
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
726
+		// admin_print_footer_scripts - global, page child class, and view specific.
727
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
728
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
729
+		// is a good use case. Notice the late priority we're giving these
730
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
731
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
732
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
733
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
734
+		}
735
+		// admin footer scripts
736
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
737
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
738
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
739
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
740
+		}
741
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
742
+		// targeted hook
743
+		do_action(
744
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
745
+		);
746
+	}
747
+
748
+
749
+	/**
750
+	 * _set_defaults
751
+	 * This sets some global defaults for class properties.
752
+	 */
753
+	private function _set_defaults()
754
+	{
755
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
756
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
757
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
758
+		$this->_page_config          = $this->_default_route_query_args = [];
759
+		$this->_default_nav_tab_name = 'overview';
760
+		// init template args
761
+		$this->_template_args = [
762
+			'admin_page_header'  => '',
763
+			'admin_page_content' => '',
764
+			'post_body_content'  => '',
765
+			'before_list_table'  => '',
766
+			'after_list_table'   => '',
767
+		];
768
+	}
769
+
770
+
771
+	/**
772
+	 * route_admin_request
773
+	 *
774
+	 * @return void
775
+	 * @throws InvalidArgumentException
776
+	 * @throws InvalidInterfaceException
777
+	 * @throws InvalidDataTypeException
778
+	 * @throws EE_Error
779
+	 * @throws ReflectionException
780
+	 * @see    _route_admin_request()
781
+	 */
782
+	public function route_admin_request()
783
+	{
784
+		try {
785
+			$this->_route_admin_request();
786
+		} catch (EE_Error $e) {
787
+			$e->get_error();
788
+		}
789
+	}
790
+
791
+
792
+	public function set_wp_page_slug($wp_page_slug)
793
+	{
794
+		$this->_wp_page_slug = $wp_page_slug;
795
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
796
+		if (is_network_admin()) {
797
+			$this->_wp_page_slug .= '-network';
798
+		}
799
+	}
800
+
801
+
802
+	/**
803
+	 * _verify_routes
804
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
805
+	 * we know if we need to drop out.
806
+	 *
807
+	 * @return bool
808
+	 * @throws EE_Error
809
+	 */
810
+	protected function _verify_routes()
811
+	{
812
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
813
+		if (! $this->_current_page && ! $this->request->isAjax()) {
814
+			return false;
815
+		}
816
+		$this->_route = false;
817
+		// check that the page_routes array is not empty
818
+		if (empty($this->_page_routes)) {
819
+			// user error msg
820
+			$error_msg = sprintf(
821
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
822
+				$this->_admin_page_title
823
+			);
824
+			// developer error msg
825
+			$error_msg .= '||' . $error_msg
826
+						  . esc_html__(
827
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
828
+							  'event_espresso'
829
+						  );
830
+			throw new EE_Error($error_msg);
831
+		}
832
+		// and that the requested page route exists
833
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
834
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
835
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
836
+				? $this->_page_config[ $this->_req_action ]
837
+				: [];
838
+		} else {
839
+			// user error msg
840
+			$error_msg = sprintf(
841
+				esc_html__(
842
+					'The requested page route does not exist for the %s admin page.',
843
+					'event_espresso'
844
+				),
845
+				$this->_admin_page_title
846
+			);
847
+			// developer error msg
848
+			$error_msg .= '||' . $error_msg
849
+						  . sprintf(
850
+							  esc_html__(
851
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
852
+								  'event_espresso'
853
+							  ),
854
+							  $this->_req_action
855
+						  );
856
+			throw new EE_Error($error_msg);
857
+		}
858
+		// and that a default route exists
859
+		if (! array_key_exists('default', $this->_page_routes)) {
860
+			// user error msg
861
+			$error_msg = sprintf(
862
+				esc_html__(
863
+					'A default page route has not been set for the % admin page.',
864
+					'event_espresso'
865
+				),
866
+				$this->_admin_page_title
867
+			);
868
+			// developer error msg
869
+			$error_msg .= '||' . $error_msg
870
+						  . esc_html__(
871
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
872
+							  'event_espresso'
873
+						  );
874
+			throw new EE_Error($error_msg);
875
+		}
876
+		// first lets' catch if the UI request has EVER been set.
877
+		if ($this->_is_UI_request === null) {
878
+			// lets set if this is a UI request or not.
879
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
880
+			// wait a minute... we might have a noheader in the route array
881
+			$this->_is_UI_request = ! (
882
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
883
+			)
884
+				? $this->_is_UI_request
885
+				: false;
886
+		}
887
+		$this->_set_current_labels();
888
+		return true;
889
+	}
890
+
891
+
892
+	/**
893
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
894
+	 *
895
+	 * @param string $route the route name we're verifying
896
+	 * @return bool we'll throw an exception if this isn't a valid route.
897
+	 * @throws EE_Error
898
+	 */
899
+	protected function _verify_route($route)
900
+	{
901
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
902
+			return true;
903
+		}
904
+		// user error msg
905
+		$error_msg = sprintf(
906
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
907
+			$this->_admin_page_title
908
+		);
909
+		// developer error msg
910
+		$error_msg .= '||' . $error_msg
911
+					  . sprintf(
912
+						  esc_html__(
913
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
914
+							  'event_espresso'
915
+						  ),
916
+						  $route
917
+					  );
918
+		throw new EE_Error($error_msg);
919
+	}
920
+
921
+
922
+	/**
923
+	 * perform nonce verification
924
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
925
+	 * using this method (and save retyping!)
926
+	 *
927
+	 * @param string $nonce     The nonce sent
928
+	 * @param string $nonce_ref The nonce reference string (name0)
929
+	 * @return void
930
+	 * @throws EE_Error
931
+	 */
932
+	protected function _verify_nonce($nonce, $nonce_ref)
933
+	{
934
+		// verify nonce against expected value
935
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
936
+			// these are not the droids you are looking for !!!
937
+			$msg = sprintf(
938
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
939
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
940
+				'</a>'
941
+			);
942
+			if (WP_DEBUG) {
943
+				$msg .= "\n  ";
944
+				$msg .= sprintf(
945
+					esc_html__(
946
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
947
+						'event_espresso'
948
+					),
949
+					__CLASS__
950
+				);
951
+			}
952
+			if (! $this->request->isAjax()) {
953
+				wp_die($msg);
954
+			}
955
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
956
+			$this->_return_json();
957
+		}
958
+	}
959
+
960
+
961
+	/**
962
+	 * _route_admin_request()
963
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
964
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
965
+	 * in the page routes and then will try to load the corresponding method.
966
+	 *
967
+	 * @return void
968
+	 * @throws EE_Error
969
+	 * @throws InvalidArgumentException
970
+	 * @throws InvalidDataTypeException
971
+	 * @throws InvalidInterfaceException
972
+	 * @throws ReflectionException
973
+	 */
974
+	protected function _route_admin_request()
975
+	{
976
+		if (! $this->_is_UI_request) {
977
+			$this->_verify_routes();
978
+		}
979
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
980
+		if ($this->_req_action !== 'default' && $nonce_check) {
981
+			// set nonce from post data
982
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
983
+			$this->_verify_nonce($nonce, $this->_req_nonce);
984
+		}
985
+		// set the nav_tabs array but ONLY if this is  UI_request
986
+		if ($this->_is_UI_request) {
987
+			$this->_set_nav_tabs();
988
+		}
989
+		// grab callback function
990
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
991
+		// check if callback has args
992
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
993
+		$error_msg = '';
994
+		// action right before calling route
995
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
996
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
997
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
998
+		}
999
+		// right before calling the route, let's clean the _wp_http_referer
1000
+		$this->request->unSetRequestParam('_wp_http_referer');
1001
+		$this->request->unSetServerParam('_wp_http_referer');
1002
+		$cleaner_request_uri = remove_query_arg(
1003
+			'_wp_http_referer',
1004
+			wp_unslash($this->request->getServerParam('REQUEST_URI'))
1005
+		);
1006
+		$this->request->setRequestParam('_wp_http_referer', $cleaner_request_uri);
1007
+		$this->request->setServerParam('REQUEST_URI', $cleaner_request_uri);
1008
+		if (! empty($func)) {
1009
+			if (is_array($func)) {
1010
+				[$class, $method] = $func;
1011
+			} elseif (strpos($func, '::') !== false) {
1012
+				[$class, $method] = explode('::', $func);
1013
+			} else {
1014
+				$class  = $this;
1015
+				$method = $func;
1016
+			}
1017
+			if (! (is_object($class) && $class === $this)) {
1018
+				// send along this admin page object for access by addons.
1019
+				$args['admin_page_object'] = $this;
1020
+			}
1021
+			if (
1022
+				// is it a method on a class that doesn't work?
1023
+				(
1024
+					(
1025
+						method_exists($class, $method)
1026
+						&& call_user_func_array([$class, $method], $args) === false
1027
+					)
1028
+					&& (
1029
+						// is it a standalone function that doesn't work?
1030
+						function_exists($method)
1031
+						&& call_user_func_array(
1032
+							$func,
1033
+							array_merge(['admin_page_object' => $this], $args)
1034
+						) === false
1035
+					)
1036
+				)
1037
+				|| (
1038
+					// is it neither a class method NOR a standalone function?
1039
+					! method_exists($class, $method)
1040
+					&& ! function_exists($method)
1041
+				)
1042
+			) {
1043
+				// user error msg
1044
+				$error_msg = esc_html__(
1045
+					'An error occurred. The  requested page route could not be found.',
1046
+					'event_espresso'
1047
+				);
1048
+				// developer error msg
1049
+				$error_msg .= '||';
1050
+				$error_msg .= sprintf(
1051
+					esc_html__(
1052
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1053
+						'event_espresso'
1054
+					),
1055
+					$method
1056
+				);
1057
+			}
1058
+			if (! empty($error_msg)) {
1059
+				throw new EE_Error($error_msg);
1060
+			}
1061
+		}
1062
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1063
+		// then we need to reset the routing properties to the new route.
1064
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1065
+		if (
1066
+			$this->_is_UI_request === false
1067
+			&& is_array($this->_route)
1068
+			&& ! empty($this->_route['headers_sent_route'])
1069
+		) {
1070
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1071
+		}
1072
+	}
1073
+
1074
+
1075
+	/**
1076
+	 * This method just allows the resetting of page properties in the case where a no headers
1077
+	 * route redirects to a headers route in its route config.
1078
+	 *
1079
+	 * @param string $new_route New (non header) route to redirect to.
1080
+	 * @return   void
1081
+	 * @throws ReflectionException
1082
+	 * @throws InvalidArgumentException
1083
+	 * @throws InvalidInterfaceException
1084
+	 * @throws InvalidDataTypeException
1085
+	 * @throws EE_Error
1086
+	 * @since   4.3.0
1087
+	 */
1088
+	protected function _reset_routing_properties($new_route)
1089
+	{
1090
+		$this->_is_UI_request = true;
1091
+		// now we set the current route to whatever the headers_sent_route is set at
1092
+		$this->request->setRequestParam('action', $new_route);
1093
+		// rerun page setup
1094
+		$this->_page_setup();
1095
+	}
1096
+
1097
+
1098
+	/**
1099
+	 * _add_query_arg
1100
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1101
+	 *(internally just uses EEH_URL's function with the same name)
1102
+	 *
1103
+	 * @param array  $args
1104
+	 * @param string $url
1105
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1106
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1107
+	 *                                        Example usage: If the current page is:
1108
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1109
+	 *                                        &action=default&event_id=20&month_range=March%202015
1110
+	 *                                        &_wpnonce=5467821
1111
+	 *                                        and you call:
1112
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1113
+	 *                                        array(
1114
+	 *                                        'action' => 'resend_something',
1115
+	 *                                        'page=>espresso_registrations'
1116
+	 *                                        ),
1117
+	 *                                        $some_url,
1118
+	 *                                        true
1119
+	 *                                        );
1120
+	 *                                        It will produce a url in this structure:
1121
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1122
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1123
+	 *                                        month_range]=March%202015
1124
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1125
+	 * @return string
1126
+	 */
1127
+	public static function add_query_args_and_nonce(
1128
+		$args = [],
1129
+		$url = false,
1130
+		$sticky = false,
1131
+		$exclude_nonce = false
1132
+	) {
1133
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1134
+		if ($sticky) {
1135
+			/** @var RequestInterface $request */
1136
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1137
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer'], true);
1138
+			foreach ($request->requestParams() as $key => $value) {
1139
+				// do not add nonces
1140
+				if (strpos($key, 'nonce') !== false) {
1141
+					continue;
1142
+				}
1143
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1144
+			}
1145
+		}
1146
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1147
+	}
1148
+
1149
+
1150
+	/**
1151
+	 * This returns a generated link that will load the related help tab.
1152
+	 *
1153
+	 * @param string $help_tab_id the id for the connected help tab
1154
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1155
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1156
+	 * @return string              generated link
1157
+	 * @uses EEH_Template::get_help_tab_link()
1158
+	 */
1159
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1160
+	{
1161
+		return EEH_Template::get_help_tab_link(
1162
+			$help_tab_id,
1163
+			$this->page_slug,
1164
+			$this->_req_action,
1165
+			$icon_style,
1166
+			$help_text
1167
+		);
1168
+	}
1169
+
1170
+
1171
+	/**
1172
+	 * _add_help_tabs
1173
+	 * Note child classes define their help tabs within the page_config array.
1174
+	 *
1175
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1176
+	 * @return void
1177
+	 * @throws DomainException
1178
+	 * @throws EE_Error
1179
+	 */
1180
+	protected function _add_help_tabs()
1181
+	{
1182
+		if (isset($this->_page_config[ $this->_req_action ])) {
1183
+			$config = $this->_page_config[ $this->_req_action ];
1184
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1185
+			if (is_array($config) && isset($config['help_sidebar'])) {
1186
+				// check that the callback given is valid
1187
+				if (! method_exists($this, $config['help_sidebar'])) {
1188
+					throw new EE_Error(
1189
+						sprintf(
1190
+							esc_html__(
1191
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1192
+								'event_espresso'
1193
+							),
1194
+							$config['help_sidebar'],
1195
+							get_class($this)
1196
+						)
1197
+					);
1198
+				}
1199
+				$content = apply_filters(
1200
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1201
+					$this->{$config['help_sidebar']}()
1202
+				);
1203
+				$this->_current_screen->set_help_sidebar($content);
1204
+			}
1205
+			if (! isset($config['help_tabs'])) {
1206
+				return;
1207
+			} //no help tabs for this route
1208
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1209
+				// we're here so there ARE help tabs!
1210
+				// make sure we've got what we need
1211
+				if (! isset($cfg['title'])) {
1212
+					throw new EE_Error(
1213
+						esc_html__(
1214
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1215
+							'event_espresso'
1216
+						)
1217
+					);
1218
+				}
1219
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1220
+					throw new EE_Error(
1221
+						esc_html__(
1222
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1223
+							'event_espresso'
1224
+						)
1225
+					);
1226
+				}
1227
+				// first priority goes to content.
1228
+				if (! empty($cfg['content'])) {
1229
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1230
+					// second priority goes to filename
1231
+				} elseif (! empty($cfg['filename'])) {
1232
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1233
+					// it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1234
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1235
+															 . basename($this->_get_dir())
1236
+															 . '/help_tabs/'
1237
+															 . $cfg['filename']
1238
+															 . '.help_tab.php' : $file_path;
1239
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1240
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1241
+						EE_Error::add_error(
1242
+							sprintf(
1243
+								esc_html__(
1244
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1245
+									'event_espresso'
1246
+								),
1247
+								$tab_id,
1248
+								key($config),
1249
+								$file_path
1250
+							),
1251
+							__FILE__,
1252
+							__FUNCTION__,
1253
+							__LINE__
1254
+						);
1255
+						return;
1256
+					}
1257
+					$template_args['admin_page_obj'] = $this;
1258
+					$content                         = EEH_Template::display_template(
1259
+						$file_path,
1260
+						$template_args,
1261
+						true
1262
+					);
1263
+				} else {
1264
+					$content = '';
1265
+				}
1266
+				// check if callback is valid
1267
+				if (
1268
+					empty($content)
1269
+					&& (
1270
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1271
+					)
1272
+				) {
1273
+					EE_Error::add_error(
1274
+						sprintf(
1275
+							esc_html__(
1276
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1277
+								'event_espresso'
1278
+							),
1279
+							$cfg['title']
1280
+						),
1281
+						__FILE__,
1282
+						__FUNCTION__,
1283
+						__LINE__
1284
+					);
1285
+					return;
1286
+				}
1287
+				// setup config array for help tab method
1288
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1289
+				$_ht = [
1290
+					'id'       => $id,
1291
+					'title'    => $cfg['title'],
1292
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1293
+					'content'  => $content,
1294
+				];
1295
+				$this->_current_screen->add_help_tab($_ht);
1296
+			}
1297
+		}
1298
+	}
1299
+
1300
+
1301
+	/**
1302
+	 * This simply sets up any qtips that have been defined in the page config
1303
+	 *
1304
+	 * @return void
1305
+	 */
1306
+	protected function _add_qtips()
1307
+	{
1308
+		if (isset($this->_route_config['qtips'])) {
1309
+			$qtips = (array) $this->_route_config['qtips'];
1310
+			// load qtip loader
1311
+			$path = [
1312
+				$this->_get_dir() . '/qtips/',
1313
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1314
+			];
1315
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1316
+		}
1317
+	}
1318
+
1319
+
1320
+	/**
1321
+	 * _set_nav_tabs
1322
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1323
+	 * wish to add additional tabs or modify accordingly.
1324
+	 *
1325
+	 * @return void
1326
+	 * @throws InvalidArgumentException
1327
+	 * @throws InvalidInterfaceException
1328
+	 * @throws InvalidDataTypeException
1329
+	 */
1330
+	protected function _set_nav_tabs()
1331
+	{
1332
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1333
+		$i = 0;
1334
+		foreach ($this->_page_config as $slug => $config) {
1335
+			if (! is_array($config) || empty($config['nav'])) {
1336
+				continue;
1337
+			}
1338
+			// no nav tab for this config
1339
+			// check for persistent flag
1340
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1341
+				// nav tab is only to appear when route requested.
1342
+				continue;
1343
+			}
1344
+			if (! $this->check_user_access($slug, true)) {
1345
+				// no nav tab because current user does not have access.
1346
+				continue;
1347
+			}
1348
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1349
+			$this->_nav_tabs[ $slug ] = [
1350
+				'url'       => isset($config['nav']['url'])
1351
+					? $config['nav']['url']
1352
+					: self::add_query_args_and_nonce(
1353
+						['action' => $slug],
1354
+						$this->_admin_base_url
1355
+					),
1356
+				'link_text' => isset($config['nav']['label'])
1357
+					? $config['nav']['label']
1358
+					: ucwords(
1359
+						str_replace('_', ' ', $slug)
1360
+					),
1361
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1362
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1363
+			];
1364
+			$i++;
1365
+		}
1366
+		// if $this->_nav_tabs is empty then lets set the default
1367
+		if (empty($this->_nav_tabs)) {
1368
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1369
+				'url'       => $this->_admin_base_url,
1370
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1371
+				'css_class' => 'nav-tab-active',
1372
+				'order'     => 10,
1373
+			];
1374
+		}
1375
+		// now let's sort the tabs according to order
1376
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1377
+	}
1378
+
1379
+
1380
+	/**
1381
+	 * _set_current_labels
1382
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1383
+	 * property array
1384
+	 *
1385
+	 * @return void
1386
+	 */
1387
+	private function _set_current_labels()
1388
+	{
1389
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1390
+			foreach ($this->_route_config['labels'] as $label => $text) {
1391
+				if (is_array($text)) {
1392
+					foreach ($text as $sublabel => $subtext) {
1393
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1394
+					}
1395
+				} else {
1396
+					$this->_labels[ $label ] = $text;
1397
+				}
1398
+			}
1399
+		}
1400
+	}
1401
+
1402
+
1403
+	/**
1404
+	 *        verifies user access for this admin page
1405
+	 *
1406
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1407
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1408
+	 *                               return false if verify fail.
1409
+	 * @return bool
1410
+	 * @throws InvalidArgumentException
1411
+	 * @throws InvalidDataTypeException
1412
+	 * @throws InvalidInterfaceException
1413
+	 */
1414
+	public function check_user_access($route_to_check = '', $verify_only = false)
1415
+	{
1416
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1417
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1418
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1419
+						  && is_array(
1420
+							  $this->_page_routes[ $route_to_check ]
1421
+						  )
1422
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1423
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1424
+		if (empty($capability) && empty($route_to_check)) {
1425
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1426
+				: $this->_route['capability'];
1427
+		} else {
1428
+			$capability = empty($capability) ? 'manage_options' : $capability;
1429
+		}
1430
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1431
+		if (
1432
+			! $this->request->isAjax()
1433
+			&& (
1434
+				! function_exists('is_admin')
1435
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1436
+					$capability,
1437
+					$this->page_slug
1438
+					. '_'
1439
+					. $route_to_check,
1440
+					$id
1441
+				)
1442
+			)
1443
+		) {
1444
+			if ($verify_only) {
1445
+				return false;
1446
+			}
1447
+			if (is_user_logged_in()) {
1448
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1449
+			} else {
1450
+				return false;
1451
+			}
1452
+		}
1453
+		return true;
1454
+	}
1455
+
1456
+
1457
+	/**
1458
+	 * admin_init_global
1459
+	 * This runs all the code that we want executed within the WP admin_init hook.
1460
+	 * This method executes for ALL EE Admin pages.
1461
+	 *
1462
+	 * @return void
1463
+	 */
1464
+	public function admin_init_global()
1465
+	{
1466
+	}
1467
+
1468
+
1469
+	/**
1470
+	 * wp_loaded_global
1471
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1472
+	 * EE_Admin page and will execute on every EE Admin Page load
1473
+	 *
1474
+	 * @return void
1475
+	 */
1476
+	public function wp_loaded()
1477
+	{
1478
+	}
1479
+
1480
+
1481
+	/**
1482
+	 * admin_notices
1483
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1484
+	 * ALL EE_Admin pages.
1485
+	 *
1486
+	 * @return void
1487
+	 */
1488
+	public function admin_notices_global()
1489
+	{
1490
+		$this->_display_no_javascript_warning();
1491
+		$this->_display_espresso_notices();
1492
+	}
1493
+
1494
+
1495
+	public function network_admin_notices_global()
1496
+	{
1497
+		$this->_display_no_javascript_warning();
1498
+		$this->_display_espresso_notices();
1499
+	}
1500
+
1501
+
1502
+	/**
1503
+	 * admin_footer_scripts_global
1504
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1505
+	 * will apply on ALL EE_Admin pages.
1506
+	 *
1507
+	 * @return void
1508
+	 */
1509
+	public function admin_footer_scripts_global()
1510
+	{
1511
+		$this->_add_admin_page_ajax_loading_img();
1512
+		$this->_add_admin_page_overlay();
1513
+		// if metaboxes are present we need to add the nonce field
1514
+		if (
1515
+			isset($this->_route_config['metaboxes'])
1516
+			|| isset($this->_route_config['list_table'])
1517
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1518
+		) {
1519
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1520
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1521
+		}
1522
+	}
1523
+
1524
+
1525
+	/**
1526
+	 * admin_footer_global
1527
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1528
+	 * ALL EE_Admin Pages.
1529
+	 *
1530
+	 * @return void
1531
+	 */
1532
+	public function admin_footer_global()
1533
+	{
1534
+		// dialog container for dialog helper
1535
+		echo '
1536 1536
         <div class="ee-admin-dialog-container auto-hide hidden">
1537 1537
             <div class="ee-notices"></div>
1538 1538
             <div class="ee-admin-dialog-container-inner-content"></div>
1539 1539
         </div>
1540 1540
         ';
1541 1541
 
1542
-        // current set timezone for timezone js
1543
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1544
-    }
1545
-
1546
-
1547
-    /**
1548
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1549
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1550
-     * help popups then in your templates or your content you set "triggers" for the content using the
1551
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1552
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1553
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1554
-     * for the
1555
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1556
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1557
-     *    'help_trigger_id' => array(
1558
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1559
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1560
-     *    )
1561
-     * );
1562
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1563
-     *
1564
-     * @param array $help_array
1565
-     * @param bool  $display
1566
-     * @return string content
1567
-     * @throws DomainException
1568
-     * @throws EE_Error
1569
-     */
1570
-    protected function _set_help_popup_content($help_array = [], $display = false)
1571
-    {
1572
-        $content    = '';
1573
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1574
-        // loop through the array and setup content
1575
-        foreach ($help_array as $trigger => $help) {
1576
-            // make sure the array is setup properly
1577
-            if (! isset($help['title']) || ! isset($help['content'])) {
1578
-                throw new EE_Error(
1579
-                    esc_html__(
1580
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1581
-                        'event_espresso'
1582
-                    )
1583
-                );
1584
-            }
1585
-            // we're good so let's setup the template vars and then assign parsed template content to our content.
1586
-            $template_args = [
1587
-                'help_popup_id'      => $trigger,
1588
-                'help_popup_title'   => $help['title'],
1589
-                'help_popup_content' => $help['content'],
1590
-            ];
1591
-            $content       .= EEH_Template::display_template(
1592
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1593
-                $template_args,
1594
-                true
1595
-            );
1596
-        }
1597
-        if ($display) {
1598
-            echo wp_kses($content, AllowedTags::getWithFormTags());
1599
-            return '';
1600
-        }
1601
-        return $content;
1602
-    }
1603
-
1604
-
1605
-    /**
1606
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1607
-     *
1608
-     * @return array properly formatted array for help popup content
1609
-     * @throws EE_Error
1610
-     */
1611
-    private function _get_help_content()
1612
-    {
1613
-        // what is the method we're looking for?
1614
-        $method_name = '_help_popup_content_' . $this->_req_action;
1615
-        // if method doesn't exist let's get out.
1616
-        if (! method_exists($this, $method_name)) {
1617
-            return [];
1618
-        }
1619
-        // k we're good to go let's retrieve the help array
1620
-        $help_array = call_user_func([$this, $method_name]);
1621
-        // make sure we've got an array!
1622
-        if (! is_array($help_array)) {
1623
-            throw new EE_Error(
1624
-                esc_html__(
1625
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1626
-                    'event_espresso'
1627
-                )
1628
-            );
1629
-        }
1630
-        return $help_array;
1631
-    }
1632
-
1633
-
1634
-    /**
1635
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1636
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1637
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1638
-     *
1639
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1640
-     * @param boolean $display    if false then we return the trigger string
1641
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1642
-     * @return string
1643
-     * @throws DomainException
1644
-     * @throws EE_Error
1645
-     */
1646
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1647
-    {
1648
-        if ($this->request->isAjax()) {
1649
-            return '';
1650
-        }
1651
-        // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1652
-        $help_array   = $this->_get_help_content();
1653
-        $help_content = '';
1654
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1655
-            $help_array[ $trigger_id ] = [
1656
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1657
-                'content' => esc_html__(
1658
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1659
-                    'event_espresso'
1660
-                ),
1661
-            ];
1662
-            $help_content              = $this->_set_help_popup_content($help_array);
1663
-        }
1664
-        // let's setup the trigger
1665
-        $content = '<a class="ee-dialog" href="?height='
1666
-                   . esc_attr($dimensions[0])
1667
-                   . '&width='
1668
-                   . esc_attr($dimensions[1])
1669
-                   . '&inlineId='
1670
-                   . esc_attr($trigger_id)
1671
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1672
-        $content .= $help_content;
1673
-        if ($display) {
1674
-            echo wp_kses($content, AllowedTags::getWithFormTags());
1675
-            return '';
1676
-        }
1677
-        return $content;
1678
-    }
1679
-
1680
-
1681
-    /**
1682
-     * _add_global_screen_options
1683
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1684
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1685
-     *
1686
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1687
-     *         see also WP_Screen object documents...
1688
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1689
-     * @abstract
1690
-     * @return void
1691
-     */
1692
-    private function _add_global_screen_options()
1693
-    {
1694
-    }
1695
-
1696
-
1697
-    /**
1698
-     * _add_global_feature_pointers
1699
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1700
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1701
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1702
-     *
1703
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1704
-     *         extended) also see:
1705
-     * @link   http://eamann.com/tech/wordpress-portland/
1706
-     * @abstract
1707
-     * @return void
1708
-     */
1709
-    private function _add_global_feature_pointers()
1710
-    {
1711
-    }
1712
-
1713
-
1714
-    /**
1715
-     * load_global_scripts_styles
1716
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1717
-     *
1718
-     * @return void
1719
-     */
1720
-    public function load_global_scripts_styles()
1721
-    {
1722
-        /** STYLES **/
1723
-        // add debugging styles
1724
-        if (WP_DEBUG) {
1725
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1726
-        }
1727
-        // register all styles
1728
-        wp_register_style(
1729
-            'espresso-ui-theme',
1730
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1731
-            [],
1732
-            EVENT_ESPRESSO_VERSION
1733
-        );
1734
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1735
-        // helpers styles
1736
-        wp_register_style(
1737
-            'ee-text-links',
1738
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1739
-            [],
1740
-            EVENT_ESPRESSO_VERSION
1741
-        );
1742
-        /** SCRIPTS **/
1743
-        // register all scripts
1744
-        wp_register_script(
1745
-            'ee-dialog',
1746
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1747
-            ['jquery', 'jquery-ui-draggable'],
1748
-            EVENT_ESPRESSO_VERSION,
1749
-            true
1750
-        );
1751
-        wp_register_script(
1752
-            'ee_admin_js',
1753
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1754
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1755
-            EVENT_ESPRESSO_VERSION,
1756
-            true
1757
-        );
1758
-        wp_register_script(
1759
-            'jquery-ui-timepicker-addon',
1760
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1761
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1762
-            EVENT_ESPRESSO_VERSION,
1763
-            true
1764
-        );
1765
-        // script for sorting tables
1766
-        wp_register_script(
1767
-            'espresso_ajax_table_sorting',
1768
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1769
-            ['ee_admin_js', 'jquery-ui-sortable'],
1770
-            EVENT_ESPRESSO_VERSION,
1771
-            true
1772
-        );
1773
-        // script for parsing uri's
1774
-        wp_register_script(
1775
-            'ee-parse-uri',
1776
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1777
-            [],
1778
-            EVENT_ESPRESSO_VERSION,
1779
-            true
1780
-        );
1781
-        // and parsing associative serialized form elements
1782
-        wp_register_script(
1783
-            'ee-serialize-full-array',
1784
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1785
-            ['jquery'],
1786
-            EVENT_ESPRESSO_VERSION,
1787
-            true
1788
-        );
1789
-        // helpers scripts
1790
-        wp_register_script(
1791
-            'ee-text-links',
1792
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1793
-            ['jquery'],
1794
-            EVENT_ESPRESSO_VERSION,
1795
-            true
1796
-        );
1797
-        wp_register_script(
1798
-            'ee-moment-core',
1799
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1800
-            [],
1801
-            EVENT_ESPRESSO_VERSION,
1802
-            true
1803
-        );
1804
-        wp_register_script(
1805
-            'ee-moment',
1806
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1807
-            ['ee-moment-core'],
1808
-            EVENT_ESPRESSO_VERSION,
1809
-            true
1810
-        );
1811
-        wp_register_script(
1812
-            'ee-datepicker',
1813
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1814
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1815
-            EVENT_ESPRESSO_VERSION,
1816
-            true
1817
-        );
1818
-        // google charts
1819
-        wp_register_script(
1820
-            'google-charts',
1821
-            'https://www.gstatic.com/charts/loader.js',
1822
-            [],
1823
-            EVENT_ESPRESSO_VERSION
1824
-        );
1825
-        // ENQUEUE ALL BASICS BY DEFAULT
1826
-        wp_enqueue_style('ee-admin-css');
1827
-        wp_enqueue_script('ee_admin_js');
1828
-        wp_enqueue_script('ee-accounting');
1829
-        wp_enqueue_script('jquery-validate');
1830
-        // taking care of metaboxes
1831
-        if (
1832
-            empty($this->_cpt_route)
1833
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1834
-        ) {
1835
-            wp_enqueue_script('dashboard');
1836
-        }
1837
-        // LOCALIZED DATA
1838
-        // localize script for ajax lazy loading
1839
-        $lazy_loader_container_ids = apply_filters(
1840
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1841
-            ['espresso_news_post_box_content']
1842
-        );
1843
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1844
-        add_filter(
1845
-            'admin_body_class',
1846
-            function ($classes) {
1847
-                if (strpos($classes, 'espresso-admin') === false) {
1848
-                    $classes .= ' espresso-admin';
1849
-                }
1850
-                return $classes;
1851
-            }
1852
-        );
1853
-    }
1854
-
1855
-
1856
-    /**
1857
-     *        admin_footer_scripts_eei18n_js_strings
1858
-     *
1859
-     * @return        void
1860
-     */
1861
-    public function admin_footer_scripts_eei18n_js_strings()
1862
-    {
1863
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1864
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1865
-            __(
1866
-                'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
1867
-                'event_espresso'
1868
-            )
1869
-        );
1870
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1871
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1872
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1873
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1874
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1875
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1876
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1877
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1878
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1879
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1880
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1881
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1882
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1883
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1884
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1885
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1886
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1887
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1888
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1889
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1890
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1891
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1892
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1893
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1894
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1895
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1896
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1897
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1898
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1899
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1900
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1901
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1902
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1903
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1904
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1905
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1906
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1907
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1908
-    }
1909
-
1910
-
1911
-    /**
1912
-     *        load enhanced xdebug styles for ppl with failing eyesight
1913
-     *
1914
-     * @return        void
1915
-     */
1916
-    public function add_xdebug_style()
1917
-    {
1918
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1919
-    }
1920
-
1921
-
1922
-    /************************/
1923
-    /** LIST TABLE METHODS **/
1924
-    /************************/
1925
-    /**
1926
-     * this sets up the list table if the current view requires it.
1927
-     *
1928
-     * @return void
1929
-     * @throws EE_Error
1930
-     */
1931
-    protected function _set_list_table()
1932
-    {
1933
-        // first is this a list_table view?
1934
-        if (! isset($this->_route_config['list_table'])) {
1935
-            return;
1936
-        } //not a list_table view so get out.
1937
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
1938
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1939
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1940
-            // user error msg
1941
-            $error_msg = esc_html__(
1942
-                'An error occurred. The requested list table views could not be found.',
1943
-                'event_espresso'
1944
-            );
1945
-            // developer error msg
1946
-            $error_msg .= '||'
1947
-                          . sprintf(
1948
-                              esc_html__(
1949
-                                  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
1950
-                                  'event_espresso'
1951
-                              ),
1952
-                              $this->_req_action,
1953
-                              $list_table_view
1954
-                          );
1955
-            throw new EE_Error($error_msg);
1956
-        }
1957
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1958
-        $this->_views = apply_filters(
1959
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1960
-            $this->_views
1961
-        );
1962
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1963
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1964
-        $this->_set_list_table_view();
1965
-        $this->_set_list_table_object();
1966
-    }
1967
-
1968
-
1969
-    /**
1970
-     * set current view for List Table
1971
-     *
1972
-     * @return void
1973
-     */
1974
-    protected function _set_list_table_view()
1975
-    {
1976
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1977
-        $status = $this->request->getRequestParam('status', null, 'key');
1978
-        $this->_view = $status && array_key_exists($status, $this->_views)
1979
-            ? $status
1980
-            : $this->_view;
1981
-    }
1982
-
1983
-
1984
-    /**
1985
-     * _set_list_table_object
1986
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1987
-     *
1988
-     * @throws InvalidInterfaceException
1989
-     * @throws InvalidArgumentException
1990
-     * @throws InvalidDataTypeException
1991
-     * @throws EE_Error
1992
-     * @throws InvalidInterfaceException
1993
-     */
1994
-    protected function _set_list_table_object()
1995
-    {
1996
-        if (isset($this->_route_config['list_table'])) {
1997
-            if (! class_exists($this->_route_config['list_table'])) {
1998
-                throw new EE_Error(
1999
-                    sprintf(
2000
-                        esc_html__(
2001
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2002
-                            'event_espresso'
2003
-                        ),
2004
-                        $this->_route_config['list_table'],
2005
-                        get_class($this)
2006
-                    )
2007
-                );
2008
-            }
2009
-            $this->_list_table_object = $this->loader->getShared(
2010
-                $this->_route_config['list_table'],
2011
-                [$this]
2012
-            );
2013
-        }
2014
-    }
2015
-
2016
-
2017
-    /**
2018
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2019
-     *
2020
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2021
-     *                                                    urls.  The array should be indexed by the view it is being
2022
-     *                                                    added to.
2023
-     * @return array
2024
-     */
2025
-    public function get_list_table_view_RLs($extra_query_args = [])
2026
-    {
2027
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2028
-        if (empty($this->_views)) {
2029
-            $this->_views = [];
2030
-        }
2031
-        // cycle thru views
2032
-        foreach ($this->_views as $key => $view) {
2033
-            $query_args = [];
2034
-            // check for current view
2035
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2036
-            $query_args['action']                        = $this->_req_action;
2037
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2038
-            $query_args['status']                        = $view['slug'];
2039
-            // merge any other arguments sent in.
2040
-            if (isset($extra_query_args[ $view['slug'] ])) {
2041
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2042
-            }
2043
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2044
-        }
2045
-        return $this->_views;
2046
-    }
2047
-
2048
-
2049
-    /**
2050
-     * _entries_per_page_dropdown
2051
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2052
-     *
2053
-     * @param int $max_entries total number of rows in the table
2054
-     * @return string
2055
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2056
-     *         WP does it.
2057
-     */
2058
-    protected function _entries_per_page_dropdown($max_entries = 0)
2059
-    {
2060
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2061
-        $values   = [10, 25, 50, 100];
2062
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2063
-        if ($max_entries) {
2064
-            $values[] = $max_entries;
2065
-            sort($values);
2066
-        }
2067
-        $entries_per_page_dropdown = '
1542
+		// current set timezone for timezone js
1543
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1544
+	}
1545
+
1546
+
1547
+	/**
1548
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1549
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1550
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1551
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1552
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1553
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1554
+	 * for the
1555
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1556
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1557
+	 *    'help_trigger_id' => array(
1558
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1559
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1560
+	 *    )
1561
+	 * );
1562
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1563
+	 *
1564
+	 * @param array $help_array
1565
+	 * @param bool  $display
1566
+	 * @return string content
1567
+	 * @throws DomainException
1568
+	 * @throws EE_Error
1569
+	 */
1570
+	protected function _set_help_popup_content($help_array = [], $display = false)
1571
+	{
1572
+		$content    = '';
1573
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1574
+		// loop through the array and setup content
1575
+		foreach ($help_array as $trigger => $help) {
1576
+			// make sure the array is setup properly
1577
+			if (! isset($help['title']) || ! isset($help['content'])) {
1578
+				throw new EE_Error(
1579
+					esc_html__(
1580
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1581
+						'event_espresso'
1582
+					)
1583
+				);
1584
+			}
1585
+			// we're good so let's setup the template vars and then assign parsed template content to our content.
1586
+			$template_args = [
1587
+				'help_popup_id'      => $trigger,
1588
+				'help_popup_title'   => $help['title'],
1589
+				'help_popup_content' => $help['content'],
1590
+			];
1591
+			$content       .= EEH_Template::display_template(
1592
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1593
+				$template_args,
1594
+				true
1595
+			);
1596
+		}
1597
+		if ($display) {
1598
+			echo wp_kses($content, AllowedTags::getWithFormTags());
1599
+			return '';
1600
+		}
1601
+		return $content;
1602
+	}
1603
+
1604
+
1605
+	/**
1606
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1607
+	 *
1608
+	 * @return array properly formatted array for help popup content
1609
+	 * @throws EE_Error
1610
+	 */
1611
+	private function _get_help_content()
1612
+	{
1613
+		// what is the method we're looking for?
1614
+		$method_name = '_help_popup_content_' . $this->_req_action;
1615
+		// if method doesn't exist let's get out.
1616
+		if (! method_exists($this, $method_name)) {
1617
+			return [];
1618
+		}
1619
+		// k we're good to go let's retrieve the help array
1620
+		$help_array = call_user_func([$this, $method_name]);
1621
+		// make sure we've got an array!
1622
+		if (! is_array($help_array)) {
1623
+			throw new EE_Error(
1624
+				esc_html__(
1625
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1626
+					'event_espresso'
1627
+				)
1628
+			);
1629
+		}
1630
+		return $help_array;
1631
+	}
1632
+
1633
+
1634
+	/**
1635
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1636
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1637
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1638
+	 *
1639
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1640
+	 * @param boolean $display    if false then we return the trigger string
1641
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1642
+	 * @return string
1643
+	 * @throws DomainException
1644
+	 * @throws EE_Error
1645
+	 */
1646
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1647
+	{
1648
+		if ($this->request->isAjax()) {
1649
+			return '';
1650
+		}
1651
+		// let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1652
+		$help_array   = $this->_get_help_content();
1653
+		$help_content = '';
1654
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1655
+			$help_array[ $trigger_id ] = [
1656
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1657
+				'content' => esc_html__(
1658
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1659
+					'event_espresso'
1660
+				),
1661
+			];
1662
+			$help_content              = $this->_set_help_popup_content($help_array);
1663
+		}
1664
+		// let's setup the trigger
1665
+		$content = '<a class="ee-dialog" href="?height='
1666
+				   . esc_attr($dimensions[0])
1667
+				   . '&width='
1668
+				   . esc_attr($dimensions[1])
1669
+				   . '&inlineId='
1670
+				   . esc_attr($trigger_id)
1671
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1672
+		$content .= $help_content;
1673
+		if ($display) {
1674
+			echo wp_kses($content, AllowedTags::getWithFormTags());
1675
+			return '';
1676
+		}
1677
+		return $content;
1678
+	}
1679
+
1680
+
1681
+	/**
1682
+	 * _add_global_screen_options
1683
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1684
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1685
+	 *
1686
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1687
+	 *         see also WP_Screen object documents...
1688
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1689
+	 * @abstract
1690
+	 * @return void
1691
+	 */
1692
+	private function _add_global_screen_options()
1693
+	{
1694
+	}
1695
+
1696
+
1697
+	/**
1698
+	 * _add_global_feature_pointers
1699
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1700
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1701
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1702
+	 *
1703
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1704
+	 *         extended) also see:
1705
+	 * @link   http://eamann.com/tech/wordpress-portland/
1706
+	 * @abstract
1707
+	 * @return void
1708
+	 */
1709
+	private function _add_global_feature_pointers()
1710
+	{
1711
+	}
1712
+
1713
+
1714
+	/**
1715
+	 * load_global_scripts_styles
1716
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1717
+	 *
1718
+	 * @return void
1719
+	 */
1720
+	public function load_global_scripts_styles()
1721
+	{
1722
+		/** STYLES **/
1723
+		// add debugging styles
1724
+		if (WP_DEBUG) {
1725
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1726
+		}
1727
+		// register all styles
1728
+		wp_register_style(
1729
+			'espresso-ui-theme',
1730
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1731
+			[],
1732
+			EVENT_ESPRESSO_VERSION
1733
+		);
1734
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1735
+		// helpers styles
1736
+		wp_register_style(
1737
+			'ee-text-links',
1738
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1739
+			[],
1740
+			EVENT_ESPRESSO_VERSION
1741
+		);
1742
+		/** SCRIPTS **/
1743
+		// register all scripts
1744
+		wp_register_script(
1745
+			'ee-dialog',
1746
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1747
+			['jquery', 'jquery-ui-draggable'],
1748
+			EVENT_ESPRESSO_VERSION,
1749
+			true
1750
+		);
1751
+		wp_register_script(
1752
+			'ee_admin_js',
1753
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1754
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1755
+			EVENT_ESPRESSO_VERSION,
1756
+			true
1757
+		);
1758
+		wp_register_script(
1759
+			'jquery-ui-timepicker-addon',
1760
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1761
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1762
+			EVENT_ESPRESSO_VERSION,
1763
+			true
1764
+		);
1765
+		// script for sorting tables
1766
+		wp_register_script(
1767
+			'espresso_ajax_table_sorting',
1768
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1769
+			['ee_admin_js', 'jquery-ui-sortable'],
1770
+			EVENT_ESPRESSO_VERSION,
1771
+			true
1772
+		);
1773
+		// script for parsing uri's
1774
+		wp_register_script(
1775
+			'ee-parse-uri',
1776
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1777
+			[],
1778
+			EVENT_ESPRESSO_VERSION,
1779
+			true
1780
+		);
1781
+		// and parsing associative serialized form elements
1782
+		wp_register_script(
1783
+			'ee-serialize-full-array',
1784
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1785
+			['jquery'],
1786
+			EVENT_ESPRESSO_VERSION,
1787
+			true
1788
+		);
1789
+		// helpers scripts
1790
+		wp_register_script(
1791
+			'ee-text-links',
1792
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1793
+			['jquery'],
1794
+			EVENT_ESPRESSO_VERSION,
1795
+			true
1796
+		);
1797
+		wp_register_script(
1798
+			'ee-moment-core',
1799
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1800
+			[],
1801
+			EVENT_ESPRESSO_VERSION,
1802
+			true
1803
+		);
1804
+		wp_register_script(
1805
+			'ee-moment',
1806
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1807
+			['ee-moment-core'],
1808
+			EVENT_ESPRESSO_VERSION,
1809
+			true
1810
+		);
1811
+		wp_register_script(
1812
+			'ee-datepicker',
1813
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1814
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1815
+			EVENT_ESPRESSO_VERSION,
1816
+			true
1817
+		);
1818
+		// google charts
1819
+		wp_register_script(
1820
+			'google-charts',
1821
+			'https://www.gstatic.com/charts/loader.js',
1822
+			[],
1823
+			EVENT_ESPRESSO_VERSION
1824
+		);
1825
+		// ENQUEUE ALL BASICS BY DEFAULT
1826
+		wp_enqueue_style('ee-admin-css');
1827
+		wp_enqueue_script('ee_admin_js');
1828
+		wp_enqueue_script('ee-accounting');
1829
+		wp_enqueue_script('jquery-validate');
1830
+		// taking care of metaboxes
1831
+		if (
1832
+			empty($this->_cpt_route)
1833
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1834
+		) {
1835
+			wp_enqueue_script('dashboard');
1836
+		}
1837
+		// LOCALIZED DATA
1838
+		// localize script for ajax lazy loading
1839
+		$lazy_loader_container_ids = apply_filters(
1840
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1841
+			['espresso_news_post_box_content']
1842
+		);
1843
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1844
+		add_filter(
1845
+			'admin_body_class',
1846
+			function ($classes) {
1847
+				if (strpos($classes, 'espresso-admin') === false) {
1848
+					$classes .= ' espresso-admin';
1849
+				}
1850
+				return $classes;
1851
+			}
1852
+		);
1853
+	}
1854
+
1855
+
1856
+	/**
1857
+	 *        admin_footer_scripts_eei18n_js_strings
1858
+	 *
1859
+	 * @return        void
1860
+	 */
1861
+	public function admin_footer_scripts_eei18n_js_strings()
1862
+	{
1863
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1864
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1865
+			__(
1866
+				'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
1867
+				'event_espresso'
1868
+			)
1869
+		);
1870
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1871
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1872
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1873
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1874
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1875
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1876
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1877
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1878
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1879
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1880
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1881
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1882
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1883
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1884
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1885
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1886
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1887
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1888
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1889
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1890
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1891
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1892
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1893
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1894
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1895
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1896
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1897
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1898
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1899
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1900
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1901
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1902
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1903
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1904
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1905
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1906
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1907
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1908
+	}
1909
+
1910
+
1911
+	/**
1912
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1913
+	 *
1914
+	 * @return        void
1915
+	 */
1916
+	public function add_xdebug_style()
1917
+	{
1918
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1919
+	}
1920
+
1921
+
1922
+	/************************/
1923
+	/** LIST TABLE METHODS **/
1924
+	/************************/
1925
+	/**
1926
+	 * this sets up the list table if the current view requires it.
1927
+	 *
1928
+	 * @return void
1929
+	 * @throws EE_Error
1930
+	 */
1931
+	protected function _set_list_table()
1932
+	{
1933
+		// first is this a list_table view?
1934
+		if (! isset($this->_route_config['list_table'])) {
1935
+			return;
1936
+		} //not a list_table view so get out.
1937
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
1938
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
1939
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1940
+			// user error msg
1941
+			$error_msg = esc_html__(
1942
+				'An error occurred. The requested list table views could not be found.',
1943
+				'event_espresso'
1944
+			);
1945
+			// developer error msg
1946
+			$error_msg .= '||'
1947
+						  . sprintf(
1948
+							  esc_html__(
1949
+								  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
1950
+								  'event_espresso'
1951
+							  ),
1952
+							  $this->_req_action,
1953
+							  $list_table_view
1954
+						  );
1955
+			throw new EE_Error($error_msg);
1956
+		}
1957
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1958
+		$this->_views = apply_filters(
1959
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1960
+			$this->_views
1961
+		);
1962
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1963
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1964
+		$this->_set_list_table_view();
1965
+		$this->_set_list_table_object();
1966
+	}
1967
+
1968
+
1969
+	/**
1970
+	 * set current view for List Table
1971
+	 *
1972
+	 * @return void
1973
+	 */
1974
+	protected function _set_list_table_view()
1975
+	{
1976
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1977
+		$status = $this->request->getRequestParam('status', null, 'key');
1978
+		$this->_view = $status && array_key_exists($status, $this->_views)
1979
+			? $status
1980
+			: $this->_view;
1981
+	}
1982
+
1983
+
1984
+	/**
1985
+	 * _set_list_table_object
1986
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1987
+	 *
1988
+	 * @throws InvalidInterfaceException
1989
+	 * @throws InvalidArgumentException
1990
+	 * @throws InvalidDataTypeException
1991
+	 * @throws EE_Error
1992
+	 * @throws InvalidInterfaceException
1993
+	 */
1994
+	protected function _set_list_table_object()
1995
+	{
1996
+		if (isset($this->_route_config['list_table'])) {
1997
+			if (! class_exists($this->_route_config['list_table'])) {
1998
+				throw new EE_Error(
1999
+					sprintf(
2000
+						esc_html__(
2001
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2002
+							'event_espresso'
2003
+						),
2004
+						$this->_route_config['list_table'],
2005
+						get_class($this)
2006
+					)
2007
+				);
2008
+			}
2009
+			$this->_list_table_object = $this->loader->getShared(
2010
+				$this->_route_config['list_table'],
2011
+				[$this]
2012
+			);
2013
+		}
2014
+	}
2015
+
2016
+
2017
+	/**
2018
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2019
+	 *
2020
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2021
+	 *                                                    urls.  The array should be indexed by the view it is being
2022
+	 *                                                    added to.
2023
+	 * @return array
2024
+	 */
2025
+	public function get_list_table_view_RLs($extra_query_args = [])
2026
+	{
2027
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2028
+		if (empty($this->_views)) {
2029
+			$this->_views = [];
2030
+		}
2031
+		// cycle thru views
2032
+		foreach ($this->_views as $key => $view) {
2033
+			$query_args = [];
2034
+			// check for current view
2035
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2036
+			$query_args['action']                        = $this->_req_action;
2037
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2038
+			$query_args['status']                        = $view['slug'];
2039
+			// merge any other arguments sent in.
2040
+			if (isset($extra_query_args[ $view['slug'] ])) {
2041
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2042
+			}
2043
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2044
+		}
2045
+		return $this->_views;
2046
+	}
2047
+
2048
+
2049
+	/**
2050
+	 * _entries_per_page_dropdown
2051
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2052
+	 *
2053
+	 * @param int $max_entries total number of rows in the table
2054
+	 * @return string
2055
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2056
+	 *         WP does it.
2057
+	 */
2058
+	protected function _entries_per_page_dropdown($max_entries = 0)
2059
+	{
2060
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2061
+		$values   = [10, 25, 50, 100];
2062
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2063
+		if ($max_entries) {
2064
+			$values[] = $max_entries;
2065
+			sort($values);
2066
+		}
2067
+		$entries_per_page_dropdown = '
2068 2068
 			<div id="entries-per-page-dv" class="alignleft actions">
2069 2069
 				<label class="hide-if-no-js">
2070 2070
 					Show
2071 2071
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2072
-        foreach ($values as $value) {
2073
-            if ($value < $max_entries) {
2074
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2075
-                $entries_per_page_dropdown .= '
2072
+		foreach ($values as $value) {
2073
+			if ($value < $max_entries) {
2074
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2075
+				$entries_per_page_dropdown .= '
2076 2076
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2077
-            }
2078
-        }
2079
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2080
-        $entries_per_page_dropdown .= '
2077
+			}
2078
+		}
2079
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2080
+		$entries_per_page_dropdown .= '
2081 2081
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2082
-        $entries_per_page_dropdown .= '
2082
+		$entries_per_page_dropdown .= '
2083 2083
 					</select>
2084 2084
 					entries
2085 2085
 				</label>
2086 2086
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2087 2087
 			</div>
2088 2088
 		';
2089
-        return $entries_per_page_dropdown;
2090
-    }
2091
-
2092
-
2093
-    /**
2094
-     *        _set_search_attributes
2095
-     *
2096
-     * @return        void
2097
-     */
2098
-    public function _set_search_attributes()
2099
-    {
2100
-        $this->_template_args['search']['btn_label'] = sprintf(
2101
-            esc_html__('Search %s', 'event_espresso'),
2102
-            empty($this->_search_btn_label) ? $this->page_label
2103
-                : $this->_search_btn_label
2104
-        );
2105
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2106
-    }
2107
-
2108
-
2109
-
2110
-    /*** END LIST TABLE METHODS **/
2111
-
2112
-
2113
-    /**
2114
-     * _add_registered_metaboxes
2115
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2116
-     *
2117
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2118
-     * @return void
2119
-     * @throws EE_Error
2120
-     */
2121
-    private function _add_registered_meta_boxes()
2122
-    {
2123
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2124
-        // we only add meta boxes if the page_route calls for it
2125
-        if (
2126
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2127
-            && is_array(
2128
-                $this->_route_config['metaboxes']
2129
-            )
2130
-        ) {
2131
-            // this simply loops through the callbacks provided
2132
-            // and checks if there is a corresponding callback registered by the child
2133
-            // if there is then we go ahead and process the metabox loader.
2134
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2135
-                // first check for Closures
2136
-                if ($metabox_callback instanceof Closure) {
2137
-                    $result = $metabox_callback();
2138
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2139
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2140
-                } else {
2141
-                    $result = call_user_func([$this, &$metabox_callback]);
2142
-                }
2143
-                if ($result === false) {
2144
-                    // user error msg
2145
-                    $error_msg = esc_html__(
2146
-                        'An error occurred. The  requested metabox could not be found.',
2147
-                        'event_espresso'
2148
-                    );
2149
-                    // developer error msg
2150
-                    $error_msg .= '||'
2151
-                                  . sprintf(
2152
-                                      esc_html__(
2153
-                                          'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2154
-                                          'event_espresso'
2155
-                                      ),
2156
-                                      $metabox_callback
2157
-                                  );
2158
-                    throw new EE_Error($error_msg);
2159
-                }
2160
-            }
2161
-        }
2162
-    }
2163
-
2164
-
2165
-    /**
2166
-     * _add_screen_columns
2167
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2168
-     * the dynamic column template and we'll setup the column options for the page.
2169
-     *
2170
-     * @return void
2171
-     */
2172
-    private function _add_screen_columns()
2173
-    {
2174
-        if (
2175
-            is_array($this->_route_config)
2176
-            && isset($this->_route_config['columns'])
2177
-            && is_array($this->_route_config['columns'])
2178
-            && count($this->_route_config['columns']) === 2
2179
-        ) {
2180
-            add_screen_option(
2181
-                'layout_columns',
2182
-                [
2183
-                    'max'     => (int) $this->_route_config['columns'][0],
2184
-                    'default' => (int) $this->_route_config['columns'][1],
2185
-                ]
2186
-            );
2187
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2188
-            $screen_id                                           = $this->_current_screen->id;
2189
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2190
-            $total_columns                                       = ! empty($screen_columns)
2191
-                ? $screen_columns
2192
-                : $this->_route_config['columns'][1];
2193
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2194
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2195
-            $this->_template_args['screen']                      = $this->_current_screen;
2196
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2197
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2198
-            // finally if we don't have has_metaboxes set in the route config
2199
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2200
-            $this->_route_config['has_metaboxes'] = true;
2201
-        }
2202
-    }
2203
-
2204
-
2205
-
2206
-    /** GLOBALLY AVAILABLE METABOXES **/
2207
-
2208
-
2209
-    /**
2210
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2211
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2212
-     * these get loaded on.
2213
-     */
2214
-    private function _espresso_news_post_box()
2215
-    {
2216
-        $news_box_title = apply_filters(
2217
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2218
-            esc_html__('New @ Event Espresso', 'event_espresso')
2219
-        );
2220
-        add_meta_box(
2221
-            'espresso_news_post_box',
2222
-            $news_box_title,
2223
-            [
2224
-                $this,
2225
-                'espresso_news_post_box',
2226
-            ],
2227
-            $this->_wp_page_slug,
2228
-            'side'
2229
-        );
2230
-    }
2231
-
2232
-
2233
-    /**
2234
-     * Code for setting up espresso ratings request metabox.
2235
-     */
2236
-    protected function _espresso_ratings_request()
2237
-    {
2238
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2239
-            return;
2240
-        }
2241
-        $ratings_box_title = apply_filters(
2242
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2243
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2244
-        );
2245
-        add_meta_box(
2246
-            'espresso_ratings_request',
2247
-            $ratings_box_title,
2248
-            [
2249
-                $this,
2250
-                'espresso_ratings_request',
2251
-            ],
2252
-            $this->_wp_page_slug,
2253
-            'side'
2254
-        );
2255
-    }
2256
-
2257
-
2258
-    /**
2259
-     * Code for setting up espresso ratings request metabox content.
2260
-     *
2261
-     * @throws DomainException
2262
-     */
2263
-    public function espresso_ratings_request()
2264
-    {
2265
-        EEH_Template::display_template(
2266
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2267
-            []
2268
-        );
2269
-    }
2270
-
2271
-
2272
-    public static function cached_rss_display($rss_id, $url)
2273
-    {
2274
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2275
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2276
-                     . '</p><p class="hide-if-js">'
2277
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2278
-                     . '</p>';
2279
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2280
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2281
-        $post      = '</div>' . "\n";
2282
-        $cache_key = 'ee_rss_' . md5($rss_id);
2283
-        $output    = get_transient($cache_key);
2284
-        if ($output !== false) {
2285
-            echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2286
-            return true;
2287
-        }
2288
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2289
-            echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2290
-            return false;
2291
-        }
2292
-        ob_start();
2293
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2294
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2295
-        return true;
2296
-    }
2297
-
2298
-
2299
-    public function espresso_news_post_box()
2300
-    {
2301
-        ?>
2089
+		return $entries_per_page_dropdown;
2090
+	}
2091
+
2092
+
2093
+	/**
2094
+	 *        _set_search_attributes
2095
+	 *
2096
+	 * @return        void
2097
+	 */
2098
+	public function _set_search_attributes()
2099
+	{
2100
+		$this->_template_args['search']['btn_label'] = sprintf(
2101
+			esc_html__('Search %s', 'event_espresso'),
2102
+			empty($this->_search_btn_label) ? $this->page_label
2103
+				: $this->_search_btn_label
2104
+		);
2105
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2106
+	}
2107
+
2108
+
2109
+
2110
+	/*** END LIST TABLE METHODS **/
2111
+
2112
+
2113
+	/**
2114
+	 * _add_registered_metaboxes
2115
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2116
+	 *
2117
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2118
+	 * @return void
2119
+	 * @throws EE_Error
2120
+	 */
2121
+	private function _add_registered_meta_boxes()
2122
+	{
2123
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2124
+		// we only add meta boxes if the page_route calls for it
2125
+		if (
2126
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2127
+			&& is_array(
2128
+				$this->_route_config['metaboxes']
2129
+			)
2130
+		) {
2131
+			// this simply loops through the callbacks provided
2132
+			// and checks if there is a corresponding callback registered by the child
2133
+			// if there is then we go ahead and process the metabox loader.
2134
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2135
+				// first check for Closures
2136
+				if ($metabox_callback instanceof Closure) {
2137
+					$result = $metabox_callback();
2138
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2139
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2140
+				} else {
2141
+					$result = call_user_func([$this, &$metabox_callback]);
2142
+				}
2143
+				if ($result === false) {
2144
+					// user error msg
2145
+					$error_msg = esc_html__(
2146
+						'An error occurred. The  requested metabox could not be found.',
2147
+						'event_espresso'
2148
+					);
2149
+					// developer error msg
2150
+					$error_msg .= '||'
2151
+								  . sprintf(
2152
+									  esc_html__(
2153
+										  'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2154
+										  'event_espresso'
2155
+									  ),
2156
+									  $metabox_callback
2157
+								  );
2158
+					throw new EE_Error($error_msg);
2159
+				}
2160
+			}
2161
+		}
2162
+	}
2163
+
2164
+
2165
+	/**
2166
+	 * _add_screen_columns
2167
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2168
+	 * the dynamic column template and we'll setup the column options for the page.
2169
+	 *
2170
+	 * @return void
2171
+	 */
2172
+	private function _add_screen_columns()
2173
+	{
2174
+		if (
2175
+			is_array($this->_route_config)
2176
+			&& isset($this->_route_config['columns'])
2177
+			&& is_array($this->_route_config['columns'])
2178
+			&& count($this->_route_config['columns']) === 2
2179
+		) {
2180
+			add_screen_option(
2181
+				'layout_columns',
2182
+				[
2183
+					'max'     => (int) $this->_route_config['columns'][0],
2184
+					'default' => (int) $this->_route_config['columns'][1],
2185
+				]
2186
+			);
2187
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2188
+			$screen_id                                           = $this->_current_screen->id;
2189
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2190
+			$total_columns                                       = ! empty($screen_columns)
2191
+				? $screen_columns
2192
+				: $this->_route_config['columns'][1];
2193
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2194
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2195
+			$this->_template_args['screen']                      = $this->_current_screen;
2196
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2197
+																   . 'admin_details_metabox_column_wrapper.template.php';
2198
+			// finally if we don't have has_metaboxes set in the route config
2199
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2200
+			$this->_route_config['has_metaboxes'] = true;
2201
+		}
2202
+	}
2203
+
2204
+
2205
+
2206
+	/** GLOBALLY AVAILABLE METABOXES **/
2207
+
2208
+
2209
+	/**
2210
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2211
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2212
+	 * these get loaded on.
2213
+	 */
2214
+	private function _espresso_news_post_box()
2215
+	{
2216
+		$news_box_title = apply_filters(
2217
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2218
+			esc_html__('New @ Event Espresso', 'event_espresso')
2219
+		);
2220
+		add_meta_box(
2221
+			'espresso_news_post_box',
2222
+			$news_box_title,
2223
+			[
2224
+				$this,
2225
+				'espresso_news_post_box',
2226
+			],
2227
+			$this->_wp_page_slug,
2228
+			'side'
2229
+		);
2230
+	}
2231
+
2232
+
2233
+	/**
2234
+	 * Code for setting up espresso ratings request metabox.
2235
+	 */
2236
+	protected function _espresso_ratings_request()
2237
+	{
2238
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2239
+			return;
2240
+		}
2241
+		$ratings_box_title = apply_filters(
2242
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2243
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2244
+		);
2245
+		add_meta_box(
2246
+			'espresso_ratings_request',
2247
+			$ratings_box_title,
2248
+			[
2249
+				$this,
2250
+				'espresso_ratings_request',
2251
+			],
2252
+			$this->_wp_page_slug,
2253
+			'side'
2254
+		);
2255
+	}
2256
+
2257
+
2258
+	/**
2259
+	 * Code for setting up espresso ratings request metabox content.
2260
+	 *
2261
+	 * @throws DomainException
2262
+	 */
2263
+	public function espresso_ratings_request()
2264
+	{
2265
+		EEH_Template::display_template(
2266
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2267
+			[]
2268
+		);
2269
+	}
2270
+
2271
+
2272
+	public static function cached_rss_display($rss_id, $url)
2273
+	{
2274
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2275
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2276
+					 . '</p><p class="hide-if-js">'
2277
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2278
+					 . '</p>';
2279
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2280
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2281
+		$post      = '</div>' . "\n";
2282
+		$cache_key = 'ee_rss_' . md5($rss_id);
2283
+		$output    = get_transient($cache_key);
2284
+		if ($output !== false) {
2285
+			echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2286
+			return true;
2287
+		}
2288
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2289
+			echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2290
+			return false;
2291
+		}
2292
+		ob_start();
2293
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2294
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2295
+		return true;
2296
+	}
2297
+
2298
+
2299
+	public function espresso_news_post_box()
2300
+	{
2301
+		?>
2302 2302
         <div class="padding">
2303 2303
             <div id="espresso_news_post_box_content" class="infolinks">
2304 2304
                 <?php
2305
-                // Get RSS Feed(s)
2306
-                self::cached_rss_display(
2307
-                    'espresso_news_post_box_content',
2308
-                    esc_url_raw(
2309
-                        apply_filters(
2310
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2311
-                            'https://eventespresso.com/feed/'
2312
-                        )
2313
-                    )
2314
-                );
2315
-                ?>
2305
+				// Get RSS Feed(s)
2306
+				self::cached_rss_display(
2307
+					'espresso_news_post_box_content',
2308
+					esc_url_raw(
2309
+						apply_filters(
2310
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2311
+							'https://eventespresso.com/feed/'
2312
+						)
2313
+					)
2314
+				);
2315
+				?>
2316 2316
             </div>
2317 2317
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2318 2318
         </div>
2319 2319
         <?php
2320
-    }
2321
-
2322
-
2323
-    private function _espresso_links_post_box()
2324
-    {
2325
-        // Hiding until we actually have content to put in here...
2326
-        // add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2327
-    }
2328
-
2329
-
2330
-    public function espresso_links_post_box()
2331
-    {
2332
-        // Hiding until we actually have content to put in here...
2333
-        // EEH_Template::display_template(
2334
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2335
-        // );
2336
-    }
2337
-
2338
-
2339
-    protected function _espresso_sponsors_post_box()
2340
-    {
2341
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2342
-            add_meta_box(
2343
-                'espresso_sponsors_post_box',
2344
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2345
-                [$this, 'espresso_sponsors_post_box'],
2346
-                $this->_wp_page_slug,
2347
-                'side'
2348
-            );
2349
-        }
2350
-    }
2351
-
2352
-
2353
-    public function espresso_sponsors_post_box()
2354
-    {
2355
-        EEH_Template::display_template(
2356
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2357
-        );
2358
-    }
2359
-
2360
-
2361
-    private function _publish_post_box()
2362
-    {
2363
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2364
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2365
-        // then we'll use that for the metabox label.
2366
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2367
-        if (! empty($this->_labels['publishbox'])) {
2368
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2369
-                : $this->_labels['publishbox'];
2370
-        } else {
2371
-            $box_label = esc_html__('Publish', 'event_espresso');
2372
-        }
2373
-        $box_label = apply_filters(
2374
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2375
-            $box_label,
2376
-            $this->_req_action,
2377
-            $this
2378
-        );
2379
-        add_meta_box(
2380
-            $meta_box_ref,
2381
-            $box_label,
2382
-            [$this, 'editor_overview'],
2383
-            $this->_current_screen->id,
2384
-            'side',
2385
-            'high'
2386
-        );
2387
-    }
2388
-
2389
-
2390
-    public function editor_overview()
2391
-    {
2392
-        // if we have extra content set let's add it in if not make sure its empty
2393
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2394
-            ? $this->_template_args['publish_box_extra_content']
2395
-            : '';
2396
-        echo EEH_Template::display_template(
2397
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2398
-            $this->_template_args,
2399
-            true
2400
-        );
2401
-    }
2402
-
2403
-
2404
-    /** end of globally available metaboxes section **/
2405
-
2406
-
2407
-    /**
2408
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2409
-     * protected method.
2410
-     *
2411
-     * @param string $name
2412
-     * @param int    $id
2413
-     * @param bool   $delete
2414
-     * @param string $save_close_redirect_URL
2415
-     * @param bool   $both_btns
2416
-     * @throws EE_Error
2417
-     * @throws InvalidArgumentException
2418
-     * @throws InvalidDataTypeException
2419
-     * @throws InvalidInterfaceException
2420
-     * @see   $this->_set_publish_post_box_vars for param details
2421
-     * @since 4.6.0
2422
-     */
2423
-    public function set_publish_post_box_vars(
2424
-        $name = '',
2425
-        $id = 0,
2426
-        $delete = false,
2427
-        $save_close_redirect_URL = '',
2428
-        $both_btns = true
2429
-    ) {
2430
-        $this->_set_publish_post_box_vars(
2431
-            $name,
2432
-            $id,
2433
-            $delete,
2434
-            $save_close_redirect_URL,
2435
-            $both_btns
2436
-        );
2437
-    }
2438
-
2439
-
2440
-    /**
2441
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2442
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2443
-     * save, and save and close buttons to work properly, then you will want to include a
2444
-     * values for the name and id arguments.
2445
-     *
2446
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2447
-     * @param int     $id                         id attached to the item published
2448
-     * @param string  $delete                     page route callback for the delete action
2449
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2450
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2451
-     *                                            the Save button
2452
-     * @throws EE_Error
2453
-     * @throws InvalidArgumentException
2454
-     * @throws InvalidDataTypeException
2455
-     * @throws InvalidInterfaceException
2456
-     * @todo  Add in validation for name/id arguments.
2457
-     */
2458
-    protected function _set_publish_post_box_vars(
2459
-        $name = '',
2460
-        $id = 0,
2461
-        $delete = '',
2462
-        $save_close_redirect_URL = '',
2463
-        $both_btns = true
2464
-    ) {
2465
-        // if Save & Close, use a custom redirect URL or default to the main page?
2466
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2467
-            ? $save_close_redirect_URL
2468
-            : $this->_admin_base_url;
2469
-        // create the Save & Close and Save buttons
2470
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2471
-        // if we have extra content set let's add it in if not make sure its empty
2472
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2473
-            ? $this->_template_args['publish_box_extra_content']
2474
-            : '';
2475
-        if ($delete && ! empty($id)) {
2476
-            // make sure we have a default if just true is sent.
2477
-            $delete           = ! empty($delete) ? $delete : 'delete';
2478
-            $delete_link_args = [$name => $id];
2479
-            $delete           = $this->get_action_link_or_button(
2480
-                $delete,
2481
-                $delete,
2482
-                $delete_link_args,
2483
-                'submitdelete deletion',
2484
-                '',
2485
-                false
2486
-            );
2487
-        }
2488
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2489
-        if (! empty($name) && ! empty($id)) {
2490
-            $hidden_field_arr[ $name ] = [
2491
-                'type'  => 'hidden',
2492
-                'value' => $id,
2493
-            ];
2494
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2495
-        } else {
2496
-            $hf = '';
2497
-        }
2498
-        // add hidden field
2499
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2500
-            ? $hf[ $name ]['field']
2501
-            : $hf;
2502
-    }
2503
-
2504
-
2505
-    /**
2506
-     * displays an error message to ppl who have javascript disabled
2507
-     *
2508
-     * @return void
2509
-     */
2510
-    private function _display_no_javascript_warning()
2511
-    {
2512
-        ?>
2320
+	}
2321
+
2322
+
2323
+	private function _espresso_links_post_box()
2324
+	{
2325
+		// Hiding until we actually have content to put in here...
2326
+		// add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2327
+	}
2328
+
2329
+
2330
+	public function espresso_links_post_box()
2331
+	{
2332
+		// Hiding until we actually have content to put in here...
2333
+		// EEH_Template::display_template(
2334
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2335
+		// );
2336
+	}
2337
+
2338
+
2339
+	protected function _espresso_sponsors_post_box()
2340
+	{
2341
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2342
+			add_meta_box(
2343
+				'espresso_sponsors_post_box',
2344
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2345
+				[$this, 'espresso_sponsors_post_box'],
2346
+				$this->_wp_page_slug,
2347
+				'side'
2348
+			);
2349
+		}
2350
+	}
2351
+
2352
+
2353
+	public function espresso_sponsors_post_box()
2354
+	{
2355
+		EEH_Template::display_template(
2356
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2357
+		);
2358
+	}
2359
+
2360
+
2361
+	private function _publish_post_box()
2362
+	{
2363
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2364
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2365
+		// then we'll use that for the metabox label.
2366
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2367
+		if (! empty($this->_labels['publishbox'])) {
2368
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2369
+				: $this->_labels['publishbox'];
2370
+		} else {
2371
+			$box_label = esc_html__('Publish', 'event_espresso');
2372
+		}
2373
+		$box_label = apply_filters(
2374
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2375
+			$box_label,
2376
+			$this->_req_action,
2377
+			$this
2378
+		);
2379
+		add_meta_box(
2380
+			$meta_box_ref,
2381
+			$box_label,
2382
+			[$this, 'editor_overview'],
2383
+			$this->_current_screen->id,
2384
+			'side',
2385
+			'high'
2386
+		);
2387
+	}
2388
+
2389
+
2390
+	public function editor_overview()
2391
+	{
2392
+		// if we have extra content set let's add it in if not make sure its empty
2393
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2394
+			? $this->_template_args['publish_box_extra_content']
2395
+			: '';
2396
+		echo EEH_Template::display_template(
2397
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2398
+			$this->_template_args,
2399
+			true
2400
+		);
2401
+	}
2402
+
2403
+
2404
+	/** end of globally available metaboxes section **/
2405
+
2406
+
2407
+	/**
2408
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2409
+	 * protected method.
2410
+	 *
2411
+	 * @param string $name
2412
+	 * @param int    $id
2413
+	 * @param bool   $delete
2414
+	 * @param string $save_close_redirect_URL
2415
+	 * @param bool   $both_btns
2416
+	 * @throws EE_Error
2417
+	 * @throws InvalidArgumentException
2418
+	 * @throws InvalidDataTypeException
2419
+	 * @throws InvalidInterfaceException
2420
+	 * @see   $this->_set_publish_post_box_vars for param details
2421
+	 * @since 4.6.0
2422
+	 */
2423
+	public function set_publish_post_box_vars(
2424
+		$name = '',
2425
+		$id = 0,
2426
+		$delete = false,
2427
+		$save_close_redirect_URL = '',
2428
+		$both_btns = true
2429
+	) {
2430
+		$this->_set_publish_post_box_vars(
2431
+			$name,
2432
+			$id,
2433
+			$delete,
2434
+			$save_close_redirect_URL,
2435
+			$both_btns
2436
+		);
2437
+	}
2438
+
2439
+
2440
+	/**
2441
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2442
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2443
+	 * save, and save and close buttons to work properly, then you will want to include a
2444
+	 * values for the name and id arguments.
2445
+	 *
2446
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2447
+	 * @param int     $id                         id attached to the item published
2448
+	 * @param string  $delete                     page route callback for the delete action
2449
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2450
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2451
+	 *                                            the Save button
2452
+	 * @throws EE_Error
2453
+	 * @throws InvalidArgumentException
2454
+	 * @throws InvalidDataTypeException
2455
+	 * @throws InvalidInterfaceException
2456
+	 * @todo  Add in validation for name/id arguments.
2457
+	 */
2458
+	protected function _set_publish_post_box_vars(
2459
+		$name = '',
2460
+		$id = 0,
2461
+		$delete = '',
2462
+		$save_close_redirect_URL = '',
2463
+		$both_btns = true
2464
+	) {
2465
+		// if Save & Close, use a custom redirect URL or default to the main page?
2466
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2467
+			? $save_close_redirect_URL
2468
+			: $this->_admin_base_url;
2469
+		// create the Save & Close and Save buttons
2470
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2471
+		// if we have extra content set let's add it in if not make sure its empty
2472
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2473
+			? $this->_template_args['publish_box_extra_content']
2474
+			: '';
2475
+		if ($delete && ! empty($id)) {
2476
+			// make sure we have a default if just true is sent.
2477
+			$delete           = ! empty($delete) ? $delete : 'delete';
2478
+			$delete_link_args = [$name => $id];
2479
+			$delete           = $this->get_action_link_or_button(
2480
+				$delete,
2481
+				$delete,
2482
+				$delete_link_args,
2483
+				'submitdelete deletion',
2484
+				'',
2485
+				false
2486
+			);
2487
+		}
2488
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2489
+		if (! empty($name) && ! empty($id)) {
2490
+			$hidden_field_arr[ $name ] = [
2491
+				'type'  => 'hidden',
2492
+				'value' => $id,
2493
+			];
2494
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2495
+		} else {
2496
+			$hf = '';
2497
+		}
2498
+		// add hidden field
2499
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2500
+			? $hf[ $name ]['field']
2501
+			: $hf;
2502
+	}
2503
+
2504
+
2505
+	/**
2506
+	 * displays an error message to ppl who have javascript disabled
2507
+	 *
2508
+	 * @return void
2509
+	 */
2510
+	private function _display_no_javascript_warning()
2511
+	{
2512
+		?>
2513 2513
         <noscript>
2514 2514
             <div id="no-js-message" class="error">
2515 2515
                 <p style="font-size:1.3em;">
2516 2516
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2517 2517
                     <?php esc_html_e(
2518
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2519
-                        'event_espresso'
2520
-                    ); ?>
2518
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2519
+						'event_espresso'
2520
+					); ?>
2521 2521
                 </p>
2522 2522
             </div>
2523 2523
         </noscript>
2524 2524
         <?php
2525
-    }
2526
-
2527
-
2528
-    /**
2529
-     * displays espresso success and/or error notices
2530
-     *
2531
-     * @return void
2532
-     */
2533
-    protected function _display_espresso_notices()
2534
-    {
2535
-        $notices = $this->_get_transient(true);
2536
-        echo stripslashes($notices);
2537
-    }
2538
-
2539
-
2540
-    /**
2541
-     * spinny things pacify the masses
2542
-     *
2543
-     * @return void
2544
-     */
2545
-    protected function _add_admin_page_ajax_loading_img()
2546
-    {
2547
-        ?>
2525
+	}
2526
+
2527
+
2528
+	/**
2529
+	 * displays espresso success and/or error notices
2530
+	 *
2531
+	 * @return void
2532
+	 */
2533
+	protected function _display_espresso_notices()
2534
+	{
2535
+		$notices = $this->_get_transient(true);
2536
+		echo stripslashes($notices);
2537
+	}
2538
+
2539
+
2540
+	/**
2541
+	 * spinny things pacify the masses
2542
+	 *
2543
+	 * @return void
2544
+	 */
2545
+	protected function _add_admin_page_ajax_loading_img()
2546
+	{
2547
+		?>
2548 2548
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2549 2549
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2550
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2550
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2551 2551
         </div>
2552 2552
         <?php
2553
-    }
2553
+	}
2554 2554
 
2555 2555
 
2556
-    /**
2557
-     * add admin page overlay for modal boxes
2558
-     *
2559
-     * @return void
2560
-     */
2561
-    protected function _add_admin_page_overlay()
2562
-    {
2563
-        ?>
2556
+	/**
2557
+	 * add admin page overlay for modal boxes
2558
+	 *
2559
+	 * @return void
2560
+	 */
2561
+	protected function _add_admin_page_overlay()
2562
+	{
2563
+		?>
2564 2564
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2565 2565
         <?php
2566
-    }
2567
-
2568
-
2569
-    /**
2570
-     * facade for add_meta_box
2571
-     *
2572
-     * @param string  $action        where the metabox gets displayed
2573
-     * @param string  $title         Title of Metabox (output in metabox header)
2574
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2575
-     *                               instead of the one created in here.
2576
-     * @param array   $callback_args an array of args supplied for the metabox
2577
-     * @param string  $column        what metabox column
2578
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2579
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2580
-     *                               created but just set our own callback for wp's add_meta_box.
2581
-     * @throws DomainException
2582
-     */
2583
-    public function _add_admin_page_meta_box(
2584
-        $action,
2585
-        $title,
2586
-        $callback,
2587
-        $callback_args,
2588
-        $column = 'normal',
2589
-        $priority = 'high',
2590
-        $create_func = true
2591
-    ) {
2592
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2593
-        // if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2594
-        if (empty($callback_args) && $create_func) {
2595
-            $callback_args = [
2596
-                'template_path' => $this->_template_path,
2597
-                'template_args' => $this->_template_args,
2598
-            ];
2599
-        }
2600
-        // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2601
-        $call_back_func = $create_func
2602
-            ? function ($post, $metabox) {
2603
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2604
-                echo EEH_Template::display_template(
2605
-                    $metabox['args']['template_path'],
2606
-                    $metabox['args']['template_args'],
2607
-                    true
2608
-                );
2609
-            }
2610
-            : $callback;
2611
-        add_meta_box(
2612
-            str_replace('_', '-', $action) . '-mbox',
2613
-            $title,
2614
-            $call_back_func,
2615
-            $this->_wp_page_slug,
2616
-            $column,
2617
-            $priority,
2618
-            $callback_args
2619
-        );
2620
-    }
2621
-
2622
-
2623
-    /**
2624
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2625
-     *
2626
-     * @throws DomainException
2627
-     * @throws EE_Error
2628
-     */
2629
-    public function display_admin_page_with_metabox_columns()
2630
-    {
2631
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2632
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2633
-            $this->_column_template_path,
2634
-            $this->_template_args,
2635
-            true
2636
-        );
2637
-        // the final wrapper
2638
-        $this->admin_page_wrapper();
2639
-    }
2640
-
2641
-
2642
-    /**
2643
-     * generates  HTML wrapper for an admin details page
2644
-     *
2645
-     * @return void
2646
-     * @throws EE_Error
2647
-     * @throws DomainException
2648
-     */
2649
-    public function display_admin_page_with_sidebar()
2650
-    {
2651
-        $this->_display_admin_page(true);
2652
-    }
2653
-
2654
-
2655
-    /**
2656
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2657
-     *
2658
-     * @return void
2659
-     * @throws EE_Error
2660
-     * @throws DomainException
2661
-     */
2662
-    public function display_admin_page_with_no_sidebar()
2663
-    {
2664
-        $this->_display_admin_page();
2665
-    }
2666
-
2667
-
2668
-    /**
2669
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2670
-     *
2671
-     * @return void
2672
-     * @throws EE_Error
2673
-     * @throws DomainException
2674
-     */
2675
-    public function display_about_admin_page()
2676
-    {
2677
-        $this->_display_admin_page(false, true);
2678
-    }
2679
-
2680
-
2681
-    /**
2682
-     * display_admin_page
2683
-     * contains the code for actually displaying an admin page
2684
-     *
2685
-     * @param boolean $sidebar true with sidebar, false without
2686
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2687
-     * @return void
2688
-     * @throws DomainException
2689
-     * @throws EE_Error
2690
-     */
2691
-    private function _display_admin_page($sidebar = false, $about = false)
2692
-    {
2693
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2694
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2695
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2696
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2697
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2698
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2699
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2700
-            ? 'poststuff'
2701
-            : 'espresso-default-admin';
2702
-        $template_path                                     = $sidebar
2703
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2704
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2705
-        if ($this->request->isAjax()) {
2706
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2707
-        }
2708
-        $template_path                                     = ! empty($this->_column_template_path)
2709
-            ? $this->_column_template_path : $template_path;
2710
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2711
-            ? $this->_template_args['admin_page_content']
2712
-            : '';
2713
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2714
-            ? $this->_template_args['before_admin_page_content']
2715
-            : '';
2716
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2717
-            ? $this->_template_args['after_admin_page_content']
2718
-            : '';
2719
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2720
-            $template_path,
2721
-            $this->_template_args,
2722
-            true
2723
-        );
2724
-        // the final template wrapper
2725
-        $this->admin_page_wrapper($about);
2726
-    }
2727
-
2728
-
2729
-    /**
2730
-     * This is used to display caf preview pages.
2731
-     *
2732
-     * @param string $utm_campaign_source what is the key used for google analytics link
2733
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2734
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2735
-     * @return void
2736
-     * @throws DomainException
2737
-     * @throws EE_Error
2738
-     * @throws InvalidArgumentException
2739
-     * @throws InvalidDataTypeException
2740
-     * @throws InvalidInterfaceException
2741
-     * @since 4.3.2
2742
-     */
2743
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2744
-    {
2745
-        // let's generate a default preview action button if there isn't one already present.
2746
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2747
-            'Upgrade to Event Espresso 4 Right Now',
2748
-            'event_espresso'
2749
-        );
2750
-        $buy_now_url                                   = add_query_arg(
2751
-            [
2752
-                'ee_ver'       => 'ee4',
2753
-                'utm_source'   => 'ee4_plugin_admin',
2754
-                'utm_medium'   => 'link',
2755
-                'utm_campaign' => $utm_campaign_source,
2756
-                'utm_content'  => 'buy_now_button',
2757
-            ],
2758
-            'https://eventespresso.com/pricing/'
2759
-        );
2760
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2761
-            ? $this->get_action_link_or_button(
2762
-                '',
2763
-                'buy_now',
2764
-                [],
2765
-                'button-primary button-large',
2766
-                esc_url_raw($buy_now_url),
2767
-                true
2768
-            )
2769
-            : $this->_template_args['preview_action_button'];
2770
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2771
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2772
-            $this->_template_args,
2773
-            true
2774
-        );
2775
-        $this->_display_admin_page($display_sidebar);
2776
-    }
2777
-
2778
-
2779
-    /**
2780
-     * display_admin_list_table_page_with_sidebar
2781
-     * generates HTML wrapper for an admin_page with list_table
2782
-     *
2783
-     * @return void
2784
-     * @throws EE_Error
2785
-     * @throws DomainException
2786
-     */
2787
-    public function display_admin_list_table_page_with_sidebar()
2788
-    {
2789
-        $this->_display_admin_list_table_page(true);
2790
-    }
2791
-
2792
-
2793
-    /**
2794
-     * display_admin_list_table_page_with_no_sidebar
2795
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2796
-     *
2797
-     * @return void
2798
-     * @throws EE_Error
2799
-     * @throws DomainException
2800
-     */
2801
-    public function display_admin_list_table_page_with_no_sidebar()
2802
-    {
2803
-        $this->_display_admin_list_table_page();
2804
-    }
2805
-
2806
-
2807
-    /**
2808
-     * generates html wrapper for an admin_list_table page
2809
-     *
2810
-     * @param boolean $sidebar whether to display with sidebar or not.
2811
-     * @return void
2812
-     * @throws DomainException
2813
-     * @throws EE_Error
2814
-     */
2815
-    private function _display_admin_list_table_page($sidebar = false)
2816
-    {
2817
-        // setup search attributes
2818
-        $this->_set_search_attributes();
2819
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2820
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2821
-        $this->_template_args['table_url']        = $this->request->isAjax()
2822
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2823
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2824
-        $this->_template_args['list_table']       = $this->_list_table_object;
2825
-        $this->_template_args['current_route']    = $this->_req_action;
2826
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2827
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2828
-        if (! empty($ajax_sorting_callback)) {
2829
-            $sortable_list_table_form_fields = wp_nonce_field(
2830
-                $ajax_sorting_callback . '_nonce',
2831
-                $ajax_sorting_callback . '_nonce',
2832
-                false,
2833
-                false
2834
-            );
2835
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2836
-                                                . $this->page_slug
2837
-                                                . '" />';
2838
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2839
-                                                . $ajax_sorting_callback
2840
-                                                . '" />';
2841
-        } else {
2842
-            $sortable_list_table_form_fields = '';
2843
-        }
2844
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2845
-        $hidden_form_fields                                      =
2846
-            isset($this->_template_args['list_table_hidden_fields'])
2847
-                ? $this->_template_args['list_table_hidden_fields']
2848
-                : '';
2849
-
2850
-        $nonce_ref          = $this->_req_action . '_nonce';
2851
-        $hidden_form_fields .= '
2566
+	}
2567
+
2568
+
2569
+	/**
2570
+	 * facade for add_meta_box
2571
+	 *
2572
+	 * @param string  $action        where the metabox gets displayed
2573
+	 * @param string  $title         Title of Metabox (output in metabox header)
2574
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2575
+	 *                               instead of the one created in here.
2576
+	 * @param array   $callback_args an array of args supplied for the metabox
2577
+	 * @param string  $column        what metabox column
2578
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2579
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2580
+	 *                               created but just set our own callback for wp's add_meta_box.
2581
+	 * @throws DomainException
2582
+	 */
2583
+	public function _add_admin_page_meta_box(
2584
+		$action,
2585
+		$title,
2586
+		$callback,
2587
+		$callback_args,
2588
+		$column = 'normal',
2589
+		$priority = 'high',
2590
+		$create_func = true
2591
+	) {
2592
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2593
+		// if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2594
+		if (empty($callback_args) && $create_func) {
2595
+			$callback_args = [
2596
+				'template_path' => $this->_template_path,
2597
+				'template_args' => $this->_template_args,
2598
+			];
2599
+		}
2600
+		// if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2601
+		$call_back_func = $create_func
2602
+			? function ($post, $metabox) {
2603
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2604
+				echo EEH_Template::display_template(
2605
+					$metabox['args']['template_path'],
2606
+					$metabox['args']['template_args'],
2607
+					true
2608
+				);
2609
+			}
2610
+			: $callback;
2611
+		add_meta_box(
2612
+			str_replace('_', '-', $action) . '-mbox',
2613
+			$title,
2614
+			$call_back_func,
2615
+			$this->_wp_page_slug,
2616
+			$column,
2617
+			$priority,
2618
+			$callback_args
2619
+		);
2620
+	}
2621
+
2622
+
2623
+	/**
2624
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2625
+	 *
2626
+	 * @throws DomainException
2627
+	 * @throws EE_Error
2628
+	 */
2629
+	public function display_admin_page_with_metabox_columns()
2630
+	{
2631
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2632
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2633
+			$this->_column_template_path,
2634
+			$this->_template_args,
2635
+			true
2636
+		);
2637
+		// the final wrapper
2638
+		$this->admin_page_wrapper();
2639
+	}
2640
+
2641
+
2642
+	/**
2643
+	 * generates  HTML wrapper for an admin details page
2644
+	 *
2645
+	 * @return void
2646
+	 * @throws EE_Error
2647
+	 * @throws DomainException
2648
+	 */
2649
+	public function display_admin_page_with_sidebar()
2650
+	{
2651
+		$this->_display_admin_page(true);
2652
+	}
2653
+
2654
+
2655
+	/**
2656
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2657
+	 *
2658
+	 * @return void
2659
+	 * @throws EE_Error
2660
+	 * @throws DomainException
2661
+	 */
2662
+	public function display_admin_page_with_no_sidebar()
2663
+	{
2664
+		$this->_display_admin_page();
2665
+	}
2666
+
2667
+
2668
+	/**
2669
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2670
+	 *
2671
+	 * @return void
2672
+	 * @throws EE_Error
2673
+	 * @throws DomainException
2674
+	 */
2675
+	public function display_about_admin_page()
2676
+	{
2677
+		$this->_display_admin_page(false, true);
2678
+	}
2679
+
2680
+
2681
+	/**
2682
+	 * display_admin_page
2683
+	 * contains the code for actually displaying an admin page
2684
+	 *
2685
+	 * @param boolean $sidebar true with sidebar, false without
2686
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2687
+	 * @return void
2688
+	 * @throws DomainException
2689
+	 * @throws EE_Error
2690
+	 */
2691
+	private function _display_admin_page($sidebar = false, $about = false)
2692
+	{
2693
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2694
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2695
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2696
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2697
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2698
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2699
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2700
+			? 'poststuff'
2701
+			: 'espresso-default-admin';
2702
+		$template_path                                     = $sidebar
2703
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2704
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2705
+		if ($this->request->isAjax()) {
2706
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2707
+		}
2708
+		$template_path                                     = ! empty($this->_column_template_path)
2709
+			? $this->_column_template_path : $template_path;
2710
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2711
+			? $this->_template_args['admin_page_content']
2712
+			: '';
2713
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2714
+			? $this->_template_args['before_admin_page_content']
2715
+			: '';
2716
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2717
+			? $this->_template_args['after_admin_page_content']
2718
+			: '';
2719
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2720
+			$template_path,
2721
+			$this->_template_args,
2722
+			true
2723
+		);
2724
+		// the final template wrapper
2725
+		$this->admin_page_wrapper($about);
2726
+	}
2727
+
2728
+
2729
+	/**
2730
+	 * This is used to display caf preview pages.
2731
+	 *
2732
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2733
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2734
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2735
+	 * @return void
2736
+	 * @throws DomainException
2737
+	 * @throws EE_Error
2738
+	 * @throws InvalidArgumentException
2739
+	 * @throws InvalidDataTypeException
2740
+	 * @throws InvalidInterfaceException
2741
+	 * @since 4.3.2
2742
+	 */
2743
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2744
+	{
2745
+		// let's generate a default preview action button if there isn't one already present.
2746
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2747
+			'Upgrade to Event Espresso 4 Right Now',
2748
+			'event_espresso'
2749
+		);
2750
+		$buy_now_url                                   = add_query_arg(
2751
+			[
2752
+				'ee_ver'       => 'ee4',
2753
+				'utm_source'   => 'ee4_plugin_admin',
2754
+				'utm_medium'   => 'link',
2755
+				'utm_campaign' => $utm_campaign_source,
2756
+				'utm_content'  => 'buy_now_button',
2757
+			],
2758
+			'https://eventespresso.com/pricing/'
2759
+		);
2760
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2761
+			? $this->get_action_link_or_button(
2762
+				'',
2763
+				'buy_now',
2764
+				[],
2765
+				'button-primary button-large',
2766
+				esc_url_raw($buy_now_url),
2767
+				true
2768
+			)
2769
+			: $this->_template_args['preview_action_button'];
2770
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2771
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2772
+			$this->_template_args,
2773
+			true
2774
+		);
2775
+		$this->_display_admin_page($display_sidebar);
2776
+	}
2777
+
2778
+
2779
+	/**
2780
+	 * display_admin_list_table_page_with_sidebar
2781
+	 * generates HTML wrapper for an admin_page with list_table
2782
+	 *
2783
+	 * @return void
2784
+	 * @throws EE_Error
2785
+	 * @throws DomainException
2786
+	 */
2787
+	public function display_admin_list_table_page_with_sidebar()
2788
+	{
2789
+		$this->_display_admin_list_table_page(true);
2790
+	}
2791
+
2792
+
2793
+	/**
2794
+	 * display_admin_list_table_page_with_no_sidebar
2795
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2796
+	 *
2797
+	 * @return void
2798
+	 * @throws EE_Error
2799
+	 * @throws DomainException
2800
+	 */
2801
+	public function display_admin_list_table_page_with_no_sidebar()
2802
+	{
2803
+		$this->_display_admin_list_table_page();
2804
+	}
2805
+
2806
+
2807
+	/**
2808
+	 * generates html wrapper for an admin_list_table page
2809
+	 *
2810
+	 * @param boolean $sidebar whether to display with sidebar or not.
2811
+	 * @return void
2812
+	 * @throws DomainException
2813
+	 * @throws EE_Error
2814
+	 */
2815
+	private function _display_admin_list_table_page($sidebar = false)
2816
+	{
2817
+		// setup search attributes
2818
+		$this->_set_search_attributes();
2819
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2820
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2821
+		$this->_template_args['table_url']        = $this->request->isAjax()
2822
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2823
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2824
+		$this->_template_args['list_table']       = $this->_list_table_object;
2825
+		$this->_template_args['current_route']    = $this->_req_action;
2826
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2827
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2828
+		if (! empty($ajax_sorting_callback)) {
2829
+			$sortable_list_table_form_fields = wp_nonce_field(
2830
+				$ajax_sorting_callback . '_nonce',
2831
+				$ajax_sorting_callback . '_nonce',
2832
+				false,
2833
+				false
2834
+			);
2835
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2836
+												. $this->page_slug
2837
+												. '" />';
2838
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2839
+												. $ajax_sorting_callback
2840
+												. '" />';
2841
+		} else {
2842
+			$sortable_list_table_form_fields = '';
2843
+		}
2844
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2845
+		$hidden_form_fields                                      =
2846
+			isset($this->_template_args['list_table_hidden_fields'])
2847
+				? $this->_template_args['list_table_hidden_fields']
2848
+				: '';
2849
+
2850
+		$nonce_ref          = $this->_req_action . '_nonce';
2851
+		$hidden_form_fields .= '
2852 2852
             <input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2853 2853
 
2854
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2855
-        // display message about search results?
2856
-        $search = $this->request->getRequestParam('s');
2857
-        $this->_template_args['before_list_table'] .= ! empty($search)
2858
-            ? '<p class="ee-search-results">' . sprintf(
2859
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2860
-                trim($search, '%')
2861
-            ) . '</p>'
2862
-            : '';
2863
-        // filter before_list_table template arg
2864
-        $this->_template_args['before_list_table'] = apply_filters(
2865
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2866
-            $this->_template_args['before_list_table'],
2867
-            $this->page_slug,
2868
-            $this->request->requestParams(),
2869
-            $this->_req_action
2870
-        );
2871
-        // convert to array and filter again
2872
-        // arrays are easier to inject new items in a specific location,
2873
-        // but would not be backwards compatible, so we have to add a new filter
2874
-        $this->_template_args['before_list_table'] = implode(
2875
-            " \n",
2876
-            (array) apply_filters(
2877
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2878
-                (array) $this->_template_args['before_list_table'],
2879
-                $this->page_slug,
2880
-                $this->request->requestParams(),
2881
-                $this->_req_action
2882
-            )
2883
-        );
2884
-        // filter after_list_table template arg
2885
-        $this->_template_args['after_list_table'] = apply_filters(
2886
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2887
-            $this->_template_args['after_list_table'],
2888
-            $this->page_slug,
2889
-            $this->request->requestParams(),
2890
-            $this->_req_action
2891
-        );
2892
-        // convert to array and filter again
2893
-        // arrays are easier to inject new items in a specific location,
2894
-        // but would not be backwards compatible, so we have to add a new filter
2895
-        $this->_template_args['after_list_table']   = implode(
2896
-            " \n",
2897
-            (array) apply_filters(
2898
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2899
-                (array) $this->_template_args['after_list_table'],
2900
-                $this->page_slug,
2901
-                $this->request->requestParams(),
2902
-                $this->_req_action
2903
-            )
2904
-        );
2905
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2906
-            $template_path,
2907
-            $this->_template_args,
2908
-            true
2909
-        );
2910
-        // the final template wrapper
2911
-        if ($sidebar) {
2912
-            $this->display_admin_page_with_sidebar();
2913
-        } else {
2914
-            $this->display_admin_page_with_no_sidebar();
2915
-        }
2916
-    }
2917
-
2918
-
2919
-    /**
2920
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2921
-     * html string for the legend.
2922
-     * $items are expected in an array in the following format:
2923
-     * $legend_items = array(
2924
-     *        'item_id' => array(
2925
-     *            'icon' => 'http://url_to_icon_being_described.png',
2926
-     *            'desc' => esc_html__('localized description of item');
2927
-     *        )
2928
-     * );
2929
-     *
2930
-     * @param array $items see above for format of array
2931
-     * @return string html string of legend
2932
-     * @throws DomainException
2933
-     */
2934
-    protected function _display_legend($items)
2935
-    {
2936
-        $this->_template_args['items'] = apply_filters(
2937
-            'FHEE__EE_Admin_Page___display_legend__items',
2938
-            (array) $items,
2939
-            $this
2940
-        );
2941
-        return EEH_Template::display_template(
2942
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2943
-            $this->_template_args,
2944
-            true
2945
-        );
2946
-    }
2947
-
2948
-
2949
-    /**
2950
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2951
-     * The returned json object is created from an array in the following format:
2952
-     * array(
2953
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2954
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
2955
-     *  'notices' => '', // - contains any EE_Error formatted notices
2956
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2957
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2958
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
2959
-     *  that might be included in here)
2960
-     * )
2961
-     * The json object is populated by whatever is set in the $_template_args property.
2962
-     *
2963
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2964
-     *                                 instead of displayed.
2965
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2966
-     * @return void
2967
-     * @throws EE_Error
2968
-     */
2969
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
2970
-    {
2971
-        // make sure any EE_Error notices have been handled.
2972
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
2973
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2974
-        unset($this->_template_args['data']);
2975
-        $json = [
2976
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2977
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2978
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2979
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2980
-            'notices'   => EE_Error::get_notices(),
2981
-            'content'   => isset($this->_template_args['admin_page_content'])
2982
-                ? $this->_template_args['admin_page_content'] : '',
2983
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2984
-            'isEEajax'  => true
2985
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2986
-        ];
2987
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2988
-        if (null === error_get_last() || ! headers_sent()) {
2989
-            header('Content-Type: application/json; charset=UTF-8');
2990
-        }
2991
-        echo wp_json_encode($json);
2992
-        exit();
2993
-    }
2994
-
2995
-
2996
-    /**
2997
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2998
-     *
2999
-     * @return void
3000
-     * @throws EE_Error
3001
-     */
3002
-    public function return_json()
3003
-    {
3004
-        if ($this->request->isAjax()) {
3005
-            $this->_return_json();
3006
-        } else {
3007
-            throw new EE_Error(
3008
-                sprintf(
3009
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3010
-                    __FUNCTION__
3011
-                )
3012
-            );
3013
-        }
3014
-    }
3015
-
3016
-
3017
-    /**
3018
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3019
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3020
-     *
3021
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3022
-     */
3023
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3024
-    {
3025
-        $this->_hook_obj = $hook_obj;
3026
-    }
3027
-
3028
-
3029
-    /**
3030
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3031
-     *
3032
-     * @param boolean $about whether to use the special about page wrapper or default.
3033
-     * @return void
3034
-     * @throws DomainException
3035
-     * @throws EE_Error
3036
-     */
3037
-    public function admin_page_wrapper($about = false)
3038
-    {
3039
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3040
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3041
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3042
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3043
-
3044
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3045
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3046
-            isset($this->_template_args['before_admin_page_content'])
3047
-                ? $this->_template_args['before_admin_page_content']
3048
-                : ''
3049
-        );
3050
-
3051
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3052
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3053
-            isset($this->_template_args['after_admin_page_content'])
3054
-                ? $this->_template_args['after_admin_page_content']
3055
-                : ''
3056
-        );
3057
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3058
-
3059
-        if ($this->request->isAjax()) {
3060
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3061
-                // $template_path,
3062
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3063
-                $this->_template_args,
3064
-                true
3065
-            );
3066
-            $this->_return_json();
3067
-        }
3068
-        // load settings page wrapper template
3069
-        $template_path = $about
3070
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3071
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3072
-
3073
-        EEH_Template::display_template($template_path, $this->_template_args);
3074
-    }
3075
-
3076
-
3077
-    /**
3078
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3079
-     *
3080
-     * @return string html
3081
-     * @throws EE_Error
3082
-     */
3083
-    protected function _get_main_nav_tabs()
3084
-    {
3085
-        // let's generate the html using the EEH_Tabbed_Content helper.
3086
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3087
-        // (rather than setting in the page_routes array)
3088
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3089
-    }
3090
-
3091
-
3092
-    /**
3093
-     *        sort nav tabs
3094
-     *
3095
-     * @param $a
3096
-     * @param $b
3097
-     * @return int
3098
-     */
3099
-    private function _sort_nav_tabs($a, $b)
3100
-    {
3101
-        if ($a['order'] === $b['order']) {
3102
-            return 0;
3103
-        }
3104
-        return ($a['order'] < $b['order']) ? -1 : 1;
3105
-    }
3106
-
3107
-
3108
-    /**
3109
-     *    generates HTML for the forms used on admin pages
3110
-     *
3111
-     * @param array  $input_vars   - array of input field details
3112
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3113
-     *                             use)
3114
-     * @param bool   $id
3115
-     * @return array|string
3116
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3117
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3118
-     */
3119
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3120
-    {
3121
-        return $generator === 'string'
3122
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3123
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3124
-    }
3125
-
3126
-
3127
-    /**
3128
-     * generates the "Save" and "Save & Close" buttons for edit forms
3129
-     *
3130
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3131
-     *                                   Close" button.
3132
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3133
-     *                                   'Save', [1] => 'save & close')
3134
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3135
-     *                                   via the "name" value in the button).  We can also use this to just dump
3136
-     *                                   default actions by submitting some other value.
3137
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3138
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3139
-     *                                   close (normal form handling).
3140
-     */
3141
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3142
-    {
3143
-        // make sure $text and $actions are in an array
3144
-        $text          = (array) $text;
3145
-        $actions       = (array) $actions;
3146
-        $referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3147
-        $button_text   = ! empty($text)
3148
-            ? $text
3149
-            : [
3150
-                esc_html__('Save', 'event_espresso'),
3151
-                esc_html__('Save and Close', 'event_espresso'),
3152
-            ];
3153
-        $default_names = ['save', 'save_and_close'];
3154
-        $buttons = '';
3155
-        foreach ($button_text as $key => $button) {
3156
-            $ref     = $default_names[ $key ];
3157
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3158
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3159
-                        . 'value="' . $button . '" name="' . $name . '" '
3160
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3161
-            if (! $both) {
3162
-                break;
3163
-            }
3164
-        }
3165
-        // add in a hidden index for the current page (so save and close redirects properly)
3166
-        $buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3167
-                   . $referrer_url
3168
-                   . '" />';
3169
-        $this->_template_args['save_buttons'] = $buttons;
3170
-    }
3171
-
3172
-
3173
-    /**
3174
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3175
-     *
3176
-     * @param string $route
3177
-     * @param array  $additional_hidden_fields
3178
-     * @see   $this->_set_add_edit_form_tags() for details on params
3179
-     * @since 4.6.0
3180
-     */
3181
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3182
-    {
3183
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3184
-    }
3185
-
3186
-
3187
-    /**
3188
-     * set form open and close tags on add/edit pages.
3189
-     *
3190
-     * @param string $route                    the route you want the form to direct to
3191
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3192
-     * @return void
3193
-     */
3194
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3195
-    {
3196
-        if (empty($route)) {
3197
-            $user_msg = esc_html__(
3198
-                'An error occurred. No action was set for this page\'s form.',
3199
-                'event_espresso'
3200
-            );
3201
-            $dev_msg  = $user_msg . "\n"
3202
-                        . sprintf(
3203
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3204
-                            __FUNCTION__,
3205
-                            __CLASS__
3206
-                        );
3207
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3208
-        }
3209
-        // open form
3210
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3211
-                                                             . $this->_admin_base_url
3212
-                                                             . '" id="'
3213
-                                                             . $route
3214
-                                                             . '_event_form" >';
3215
-        // add nonce
3216
-        $nonce                                             =
3217
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3218
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3219
-        // add REQUIRED form action
3220
-        $hidden_fields = [
3221
-            'action' => ['type' => 'hidden', 'value' => $route],
3222
-        ];
3223
-        // merge arrays
3224
-        $hidden_fields = is_array($additional_hidden_fields)
3225
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3226
-            : $hidden_fields;
3227
-        // generate form fields
3228
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3229
-        // add fields to form
3230
-        foreach ((array) $form_fields as $form_field) {
3231
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3232
-        }
3233
-        // close form
3234
-        $this->_template_args['after_admin_page_content'] = '</form>';
3235
-    }
3236
-
3237
-
3238
-    /**
3239
-     * Public Wrapper for _redirect_after_action() method since its
3240
-     * discovered it would be useful for external code to have access.
3241
-     *
3242
-     * @param bool   $success
3243
-     * @param string $what
3244
-     * @param string $action_desc
3245
-     * @param array  $query_args
3246
-     * @param bool   $override_overwrite
3247
-     * @throws EE_Error
3248
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3249
-     * @since 4.5.0
3250
-     */
3251
-    public function redirect_after_action(
3252
-        $success = false,
3253
-        $what = 'item',
3254
-        $action_desc = 'processed',
3255
-        $query_args = [],
3256
-        $override_overwrite = false
3257
-    ) {
3258
-        $this->_redirect_after_action(
3259
-            $success,
3260
-            $what,
3261
-            $action_desc,
3262
-            $query_args,
3263
-            $override_overwrite
3264
-        );
3265
-    }
3266
-
3267
-
3268
-    /**
3269
-     * Helper method for merging existing request data with the returned redirect url.
3270
-     *
3271
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3272
-     * filters are still applied.
3273
-     *
3274
-     * @param array $new_route_data
3275
-     * @return array
3276
-     */
3277
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3278
-    {
3279
-        foreach ($this->request->requestParams() as $ref => $value) {
3280
-            // unset nonces
3281
-            if (strpos($ref, 'nonce') !== false) {
3282
-                $this->request->unSetRequestParam($ref);
3283
-                continue;
3284
-            }
3285
-            // urlencode values.
3286
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3287
-            $this->request->setRequestParam($ref, $value);
3288
-        }
3289
-        return array_merge($this->request->requestParams(), $new_route_data);
3290
-    }
3291
-
3292
-
3293
-    /**
3294
-     *    _redirect_after_action
3295
-     *
3296
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3297
-     * @param string $what               - what the action was performed on
3298
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3299
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3300
-     *                                   action is completed
3301
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3302
-     *                                   override this so that they show.
3303
-     * @return void
3304
-     * @throws EE_Error
3305
-     */
3306
-    protected function _redirect_after_action(
3307
-        $success = 0,
3308
-        $what = 'item',
3309
-        $action_desc = 'processed',
3310
-        $query_args = [],
3311
-        $override_overwrite = false
3312
-    ) {
3313
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3314
-        // class name for actions/filters.
3315
-        $classname = get_class($this);
3316
-        // set redirect url.
3317
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3318
-        // otherwise we go with whatever is set as the _admin_base_url
3319
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3320
-        $notices      = EE_Error::get_notices(false);
3321
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3322
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3323
-            EE_Error::overwrite_success();
3324
-        }
3325
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3326
-            // how many records affected ? more than one record ? or just one ?
3327
-            if ($success > 1) {
3328
-                // set plural msg
3329
-                EE_Error::add_success(
3330
-                    sprintf(
3331
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3332
-                        $what,
3333
-                        $action_desc
3334
-                    ),
3335
-                    __FILE__,
3336
-                    __FUNCTION__,
3337
-                    __LINE__
3338
-                );
3339
-            } elseif ($success === 1) {
3340
-                // set singular msg
3341
-                EE_Error::add_success(
3342
-                    sprintf(
3343
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3344
-                        $what,
3345
-                        $action_desc
3346
-                    ),
3347
-                    __FILE__,
3348
-                    __FUNCTION__,
3349
-                    __LINE__
3350
-                );
3351
-            }
3352
-        }
3353
-        // check that $query_args isn't something crazy
3354
-        if (! is_array($query_args)) {
3355
-            $query_args = [];
3356
-        }
3357
-        /**
3358
-         * Allow injecting actions before the query_args are modified for possible different
3359
-         * redirections on save and close actions
3360
-         *
3361
-         * @param array $query_args       The original query_args array coming into the
3362
-         *                                method.
3363
-         * @since 4.2.0
3364
-         */
3365
-        do_action(
3366
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3367
-            $query_args
3368
-        );
3369
-        // calculate where we're going (if we have a "save and close" button pushed)
3370
-
3371
-        if (
3372
-            $this->request->requestParamIsSet('save_and_close')
3373
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3374
-        ) {
3375
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3376
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3377
-            // regenerate query args array from referrer URL
3378
-            parse_str($parsed_url['query'], $query_args);
3379
-            // correct page and action will be in the query args now
3380
-            $redirect_url = admin_url('admin.php');
3381
-        }
3382
-        // merge any default query_args set in _default_route_query_args property
3383
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3384
-            $args_to_merge = [];
3385
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3386
-                // is there a wp_referer array in our _default_route_query_args property?
3387
-                if ($query_param === 'wp_referer') {
3388
-                    $query_value = (array) $query_value;
3389
-                    foreach ($query_value as $reference => $value) {
3390
-                        if (strpos($reference, 'nonce') !== false) {
3391
-                            continue;
3392
-                        }
3393
-                        // finally we will override any arguments in the referer with
3394
-                        // what might be set on the _default_route_query_args array.
3395
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3396
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3397
-                        } else {
3398
-                            $args_to_merge[ $reference ] = urlencode($value);
3399
-                        }
3400
-                    }
3401
-                    continue;
3402
-                }
3403
-                $args_to_merge[ $query_param ] = $query_value;
3404
-            }
3405
-            // now let's merge these arguments but override with what was specifically sent in to the
3406
-            // redirect.
3407
-            $query_args = array_merge($args_to_merge, $query_args);
3408
-        }
3409
-        $this->_process_notices($query_args);
3410
-        // generate redirect url
3411
-        // if redirecting to anything other than the main page, add a nonce
3412
-        if (isset($query_args['action'])) {
3413
-            // manually generate wp_nonce and merge that with the query vars
3414
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3415
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3416
-        }
3417
-        // we're adding some hooks and filters in here for processing any things just before redirects
3418
-        // (example: an admin page has done an insert or update and we want to run something after that).
3419
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3420
-        $redirect_url = apply_filters(
3421
-            'FHEE_redirect_' . $classname . $this->_req_action,
3422
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3423
-            $query_args
3424
-        );
3425
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3426
-        if ($this->request->isAjax()) {
3427
-            $default_data                    = [
3428
-                'close'        => true,
3429
-                'redirect_url' => $redirect_url,
3430
-                'where'        => 'main',
3431
-                'what'         => 'append',
3432
-            ];
3433
-            $this->_template_args['success'] = $success;
3434
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3435
-                $default_data,
3436
-                $this->_template_args['data']
3437
-            ) : $default_data;
3438
-            $this->_return_json();
3439
-        }
3440
-        wp_safe_redirect($redirect_url);
3441
-        exit();
3442
-    }
3443
-
3444
-
3445
-    /**
3446
-     * process any notices before redirecting (or returning ajax request)
3447
-     * This method sets the $this->_template_args['notices'] attribute;
3448
-     *
3449
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3450
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3451
-     *                                  page_routes haven't been defined yet.
3452
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3453
-     *                                  still save a transient for the notice.
3454
-     * @return void
3455
-     * @throws EE_Error
3456
-     */
3457
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3458
-    {
3459
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3460
-        if ($this->request->isAjax()) {
3461
-            $notices = EE_Error::get_notices(false);
3462
-            if (empty($this->_template_args['success'])) {
3463
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3464
-            }
3465
-            if (empty($this->_template_args['errors'])) {
3466
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3467
-            }
3468
-            if (empty($this->_template_args['attention'])) {
3469
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3470
-            }
3471
-        }
3472
-        $this->_template_args['notices'] = EE_Error::get_notices();
3473
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3474
-        if (! $this->request->isAjax() || $sticky_notices) {
3475
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3476
-            $this->_add_transient(
3477
-                $route,
3478
-                $this->_template_args['notices'],
3479
-                true,
3480
-                $skip_route_verify
3481
-            );
3482
-        }
3483
-    }
3484
-
3485
-
3486
-    /**
3487
-     * get_action_link_or_button
3488
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3489
-     *
3490
-     * @param string $action        use this to indicate which action the url is generated with.
3491
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3492
-     *                              property.
3493
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3494
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3495
-     * @param string $base_url      If this is not provided
3496
-     *                              the _admin_base_url will be used as the default for the button base_url.
3497
-     *                              Otherwise this value will be used.
3498
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3499
-     * @return string
3500
-     * @throws InvalidArgumentException
3501
-     * @throws InvalidInterfaceException
3502
-     * @throws InvalidDataTypeException
3503
-     * @throws EE_Error
3504
-     */
3505
-    public function get_action_link_or_button(
3506
-        $action,
3507
-        $type = 'add',
3508
-        $extra_request = [],
3509
-        $class = 'button button--primary',
3510
-        $base_url = '',
3511
-        $exclude_nonce = false
3512
-    ) {
3513
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3514
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3515
-            throw new EE_Error(
3516
-                sprintf(
3517
-                    esc_html__(
3518
-                        'There is no page route for given action for the button.  This action was given: %s',
3519
-                        'event_espresso'
3520
-                    ),
3521
-                    $action
3522
-                )
3523
-            );
3524
-        }
3525
-        if (! isset($this->_labels['buttons'][ $type ])) {
3526
-            throw new EE_Error(
3527
-                sprintf(
3528
-                    esc_html__(
3529
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3530
-                        'event_espresso'
3531
-                    ),
3532
-                    $type
3533
-                )
3534
-            );
3535
-        }
3536
-        // finally check user access for this button.
3537
-        $has_access = $this->check_user_access($action, true);
3538
-        if (! $has_access) {
3539
-            return '';
3540
-        }
3541
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3542
-        $query_args = [
3543
-            'action' => $action,
3544
-        ];
3545
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3546
-        if (! empty($extra_request)) {
3547
-            $query_args = array_merge($extra_request, $query_args);
3548
-        }
3549
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3550
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3551
-    }
3552
-
3553
-
3554
-    /**
3555
-     * _per_page_screen_option
3556
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3557
-     *
3558
-     * @return void
3559
-     * @throws InvalidArgumentException
3560
-     * @throws InvalidInterfaceException
3561
-     * @throws InvalidDataTypeException
3562
-     */
3563
-    protected function _per_page_screen_option()
3564
-    {
3565
-        $option = 'per_page';
3566
-        $args   = [
3567
-            'label'   => apply_filters(
3568
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3569
-                $this->_admin_page_title,
3570
-                $this
3571
-            ),
3572
-            'default' => (int) apply_filters(
3573
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3574
-                20
3575
-            ),
3576
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3577
-        ];
3578
-        // ONLY add the screen option if the user has access to it.
3579
-        if ($this->check_user_access($this->_current_view, true)) {
3580
-            add_screen_option($option, $args);
3581
-        }
3582
-    }
3583
-
3584
-
3585
-    /**
3586
-     * set_per_page_screen_option
3587
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3588
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3589
-     * admin_menu.
3590
-     *
3591
-     * @return void
3592
-     */
3593
-    private function _set_per_page_screen_options()
3594
-    {
3595
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3596
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3597
-            if (! $user = wp_get_current_user()) {
3598
-                return;
3599
-            }
3600
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3601
-            if (! $option) {
3602
-                return;
3603
-            }
3604
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3605
-            $map_option = $option;
3606
-            $option     = str_replace('-', '_', $option);
3607
-            switch ($map_option) {
3608
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3609
-                    $max_value = apply_filters(
3610
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3611
-                        999,
3612
-                        $this->_current_page,
3613
-                        $this->_current_view
3614
-                    );
3615
-                    if ($value < 1) {
3616
-                        return;
3617
-                    }
3618
-                    $value = min($value, $max_value);
3619
-                    break;
3620
-                default:
3621
-                    $value = apply_filters(
3622
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3623
-                        false,
3624
-                        $option,
3625
-                        $value
3626
-                    );
3627
-                    if (false === $value) {
3628
-                        return;
3629
-                    }
3630
-                    break;
3631
-            }
3632
-            update_user_meta($user->ID, $option, $value);
3633
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3634
-            exit;
3635
-        }
3636
-    }
3637
-
3638
-
3639
-    /**
3640
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3641
-     *
3642
-     * @param array $data array that will be assigned to template args.
3643
-     */
3644
-    public function set_template_args($data)
3645
-    {
3646
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3647
-    }
3648
-
3649
-
3650
-    /**
3651
-     * This makes available the WP transient system for temporarily moving data between routes
3652
-     *
3653
-     * @param string $route             the route that should receive the transient
3654
-     * @param array  $data              the data that gets sent
3655
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3656
-     *                                  normal route transient.
3657
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3658
-     *                                  when we are adding a transient before page_routes have been defined.
3659
-     * @return void
3660
-     * @throws EE_Error
3661
-     */
3662
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3663
-    {
3664
-        $user_id = get_current_user_id();
3665
-        if (! $skip_route_verify) {
3666
-            $this->_verify_route($route);
3667
-        }
3668
-        // now let's set the string for what kind of transient we're setting
3669
-        $transient = $notices
3670
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3671
-            : 'rte_tx_' . $route . '_' . $user_id;
3672
-        $data      = $notices ? ['notices' => $data] : $data;
3673
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3674
-        $existing = is_multisite() && is_network_admin()
3675
-            ? get_site_transient($transient)
3676
-            : get_transient($transient);
3677
-        if ($existing) {
3678
-            $data = array_merge((array) $data, (array) $existing);
3679
-        }
3680
-        if (is_multisite() && is_network_admin()) {
3681
-            set_site_transient($transient, $data, 8);
3682
-        } else {
3683
-            set_transient($transient, $data, 8);
3684
-        }
3685
-    }
3686
-
3687
-
3688
-    /**
3689
-     * this retrieves the temporary transient that has been set for moving data between routes.
3690
-     *
3691
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3692
-     * @param string $route
3693
-     * @return mixed data
3694
-     */
3695
-    protected function _get_transient($notices = false, $route = '')
3696
-    {
3697
-        $user_id   = get_current_user_id();
3698
-        $route     = ! $route ? $this->_req_action : $route;
3699
-        $transient = $notices
3700
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3701
-            : 'rte_tx_' . $route . '_' . $user_id;
3702
-        $data      = is_multisite() && is_network_admin()
3703
-            ? get_site_transient($transient)
3704
-            : get_transient($transient);
3705
-        // delete transient after retrieval (just in case it hasn't expired);
3706
-        if (is_multisite() && is_network_admin()) {
3707
-            delete_site_transient($transient);
3708
-        } else {
3709
-            delete_transient($transient);
3710
-        }
3711
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3712
-    }
3713
-
3714
-
3715
-    /**
3716
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3717
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3718
-     * default route callback on the EE_Admin page you want it run.)
3719
-     *
3720
-     * @return void
3721
-     */
3722
-    protected function _transient_garbage_collection()
3723
-    {
3724
-        global $wpdb;
3725
-        // retrieve all existing transients
3726
-        $query =
3727
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3728
-        if ($results = $wpdb->get_results($query)) {
3729
-            foreach ($results as $result) {
3730
-                $transient = str_replace('_transient_', '', $result->option_name);
3731
-                get_transient($transient);
3732
-                if (is_multisite() && is_network_admin()) {
3733
-                    get_site_transient($transient);
3734
-                }
3735
-            }
3736
-        }
3737
-    }
3738
-
3739
-
3740
-    /**
3741
-     * get_view
3742
-     *
3743
-     * @return string content of _view property
3744
-     */
3745
-    public function get_view()
3746
-    {
3747
-        return $this->_view;
3748
-    }
3749
-
3750
-
3751
-    /**
3752
-     * getter for the protected $_views property
3753
-     *
3754
-     * @return array
3755
-     */
3756
-    public function get_views()
3757
-    {
3758
-        return $this->_views;
3759
-    }
3760
-
3761
-
3762
-    /**
3763
-     * get_current_page
3764
-     *
3765
-     * @return string _current_page property value
3766
-     */
3767
-    public function get_current_page()
3768
-    {
3769
-        return $this->_current_page;
3770
-    }
3771
-
3772
-
3773
-    /**
3774
-     * get_current_view
3775
-     *
3776
-     * @return string _current_view property value
3777
-     */
3778
-    public function get_current_view()
3779
-    {
3780
-        return $this->_current_view;
3781
-    }
3782
-
3783
-
3784
-    /**
3785
-     * get_current_screen
3786
-     *
3787
-     * @return object The current WP_Screen object
3788
-     */
3789
-    public function get_current_screen()
3790
-    {
3791
-        return $this->_current_screen;
3792
-    }
3793
-
3794
-
3795
-    /**
3796
-     * get_current_page_view_url
3797
-     *
3798
-     * @return string This returns the url for the current_page_view.
3799
-     */
3800
-    public function get_current_page_view_url()
3801
-    {
3802
-        return $this->_current_page_view_url;
3803
-    }
3804
-
3805
-
3806
-    /**
3807
-     * just returns the Request
3808
-     *
3809
-     * @return RequestInterface
3810
-     */
3811
-    public function get_request()
3812
-    {
3813
-        return $this->request;
3814
-    }
3815
-
3816
-
3817
-    /**
3818
-     * just returns the _req_data property
3819
-     *
3820
-     * @return array
3821
-     */
3822
-    public function get_request_data()
3823
-    {
3824
-        return $this->request->requestParams();
3825
-    }
3826
-
3827
-
3828
-    /**
3829
-     * returns the _req_data protected property
3830
-     *
3831
-     * @return string
3832
-     */
3833
-    public function get_req_action()
3834
-    {
3835
-        return $this->_req_action;
3836
-    }
3837
-
3838
-
3839
-    /**
3840
-     * @return bool  value of $_is_caf property
3841
-     */
3842
-    public function is_caf()
3843
-    {
3844
-        return $this->_is_caf;
3845
-    }
3846
-
3847
-
3848
-    /**
3849
-     * @return mixed
3850
-     */
3851
-    public function default_espresso_metaboxes()
3852
-    {
3853
-        return $this->_default_espresso_metaboxes;
3854
-    }
3855
-
3856
-
3857
-    /**
3858
-     * @return mixed
3859
-     */
3860
-    public function admin_base_url()
3861
-    {
3862
-        return $this->_admin_base_url;
3863
-    }
3864
-
3865
-
3866
-    /**
3867
-     * @return mixed
3868
-     */
3869
-    public function wp_page_slug()
3870
-    {
3871
-        return $this->_wp_page_slug;
3872
-    }
3873
-
3874
-
3875
-    /**
3876
-     * updates  espresso configuration settings
3877
-     *
3878
-     * @param string                   $tab
3879
-     * @param EE_Config_Base|EE_Config $config
3880
-     * @param string                   $file file where error occurred
3881
-     * @param string                   $func function  where error occurred
3882
-     * @param string                   $line line no where error occurred
3883
-     * @return boolean
3884
-     */
3885
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3886
-    {
3887
-        // remove any options that are NOT going to be saved with the config settings.
3888
-        if (isset($config->core->ee_ueip_optin)) {
3889
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3890
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3891
-            update_option('ee_ueip_has_notified', true);
3892
-        }
3893
-        // and save it (note we're also doing the network save here)
3894
-        $net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3895
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3896
-        if ($config_saved && $net_saved) {
3897
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3898
-            return true;
3899
-        }
3900
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3901
-        return false;
3902
-    }
3903
-
3904
-
3905
-    /**
3906
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3907
-     *
3908
-     * @return array
3909
-     */
3910
-    public function get_yes_no_values()
3911
-    {
3912
-        return $this->_yes_no_values;
3913
-    }
3914
-
3915
-
3916
-    protected function _get_dir()
3917
-    {
3918
-        $reflector = new ReflectionClass(get_class($this));
3919
-        return dirname($reflector->getFileName());
3920
-    }
3921
-
3922
-
3923
-    /**
3924
-     * A helper for getting a "next link".
3925
-     *
3926
-     * @param string $url   The url to link to
3927
-     * @param string $class The class to use.
3928
-     * @return string
3929
-     */
3930
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3931
-    {
3932
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3933
-    }
3934
-
3935
-
3936
-    /**
3937
-     * A helper for getting a "previous link".
3938
-     *
3939
-     * @param string $url   The url to link to
3940
-     * @param string $class The class to use.
3941
-     * @return string
3942
-     */
3943
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3944
-    {
3945
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3946
-    }
3947
-
3948
-
3949
-
3950
-
3951
-
3952
-
3953
-
3954
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3955
-
3956
-
3957
-    /**
3958
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3959
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
3960
-     * _req_data array.
3961
-     *
3962
-     * @return bool success/fail
3963
-     * @throws EE_Error
3964
-     * @throws InvalidArgumentException
3965
-     * @throws ReflectionException
3966
-     * @throws InvalidDataTypeException
3967
-     * @throws InvalidInterfaceException
3968
-     */
3969
-    protected function _process_resend_registration()
3970
-    {
3971
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3972
-        do_action(
3973
-            'AHEE__EE_Admin_Page___process_resend_registration',
3974
-            $this->_template_args['success'],
3975
-            $this->request->requestParams()
3976
-        );
3977
-        return $this->_template_args['success'];
3978
-    }
3979
-
3980
-
3981
-    /**
3982
-     * This automatically processes any payment message notifications when manual payment has been applied.
3983
-     *
3984
-     * @param EE_Payment $payment
3985
-     * @return bool success/fail
3986
-     */
3987
-    protected function _process_payment_notification(EE_Payment $payment)
3988
-    {
3989
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3990
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3991
-        $this->_template_args['success'] = apply_filters(
3992
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3993
-            false,
3994
-            $payment
3995
-        );
3996
-        return $this->_template_args['success'];
3997
-    }
3998
-
3999
-
4000
-    /**
4001
-     * @param EEM_Base      $entity_model
4002
-     * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4003
-     * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4004
-     * @param string        $delete_column  name of the field that denotes whether entity is trashed
4005
-     * @param callable|null $callback       called after entity is trashed, restored, or deleted
4006
-     * @return int|float
4007
-     * @throws EE_Error
4008
-     */
4009
-    protected function trashRestoreDeleteEntities(
4010
-        EEM_Base $entity_model,
4011
-        $entity_PK_name,
4012
-        $action = EE_Admin_List_Table::ACTION_DELETE,
4013
-        $delete_column = '',
4014
-        callable $callback = null
4015
-    ) {
4016
-        $entity_PK      = $entity_model->get_primary_key_field();
4017
-        $entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4018
-        $entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4019
-        // grab ID if deleting a single entity
4020
-        if ($this->request->requestParamIsSet($entity_PK_name)) {
4021
-            $ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4022
-            return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4023
-        }
4024
-        // or grab checkbox array if bulk deleting
4025
-        $checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4026
-        if (empty($checkboxes)) {
4027
-            return 0;
4028
-        }
4029
-        $success = 0;
4030
-        $IDs     = array_keys($checkboxes);
4031
-        // cycle thru bulk action checkboxes
4032
-        foreach ($IDs as $ID) {
4033
-            // increment $success
4034
-            if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4035
-                $success++;
4036
-            }
4037
-        }
4038
-        $count = (int) count($checkboxes);
4039
-        // if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4040
-        // otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4041
-        return $success === $count ? $count : $success / $count;
4042
-    }
4043
-
4044
-
4045
-    /**
4046
-     * @param EE_Primary_Key_Field_Base $entity_PK
4047
-     * @return string
4048
-     * @throws EE_Error
4049
-     * @since   4.10.30.p
4050
-     */
4051
-    private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK)
4052
-    {
4053
-        $entity_PK_type = $entity_PK->getSchemaType();
4054
-        switch ($entity_PK_type) {
4055
-            case 'boolean':
4056
-                return 'bool';
4057
-            case 'integer':
4058
-                return 'int';
4059
-            case 'number':
4060
-                return 'float';
4061
-            case 'string':
4062
-                return 'string';
4063
-        }
4064
-        throw new RuntimeException(
4065
-            sprintf(
4066
-                esc_html__(
4067
-                    '"%1$s" is an invalid schema type for the %2$s primary key.',
4068
-                    'event_espresso'
4069
-                ),
4070
-                $entity_PK_type,
4071
-                $entity_PK->get_name()
4072
-            )
4073
-        );
4074
-    }
4075
-
4076
-
4077
-    /**
4078
-     * @param EEM_Base      $entity_model
4079
-     * @param int|string    $entity_ID
4080
-     * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4081
-     * @param string        $delete_column name of the field that denotes whether entity is trashed
4082
-     * @param callable|null $callback      called after entity is trashed, restored, or deleted
4083
-     * @return bool
4084
-     */
4085
-    protected function trashRestoreDeleteEntity(
4086
-        EEM_Base $entity_model,
4087
-        $entity_ID,
4088
-        $action,
4089
-        $delete_column,
4090
-        callable $callback = null
4091
-    ) {
4092
-        $entity_ID = absint($entity_ID);
4093
-        if (! $entity_ID) {
4094
-            $this->trashRestoreDeleteError($action, $entity_model);
4095
-        }
4096
-        $result = 0;
4097
-        try {
4098
-            $entity = $entity_model->get_one_by_ID($entity_ID);
4099
-            if (! $entity instanceof EE_Base_Class) {
4100
-                throw new DomainException(
4101
-                    sprintf(
4102
-                        esc_html__(
4103
-                            'Missing or invalid %1$s entity with ID of "%2$s" returned from db.',
4104
-                            'event_espresso'
4105
-                        ),
4106
-                        str_replace('EEM_', '', $entity_model->get_this_model_name()),
4107
-                        $entity_ID
4108
-                    )
4109
-                );
4110
-            }
4111
-            switch ($action) {
4112
-                case EE_Admin_List_Table::ACTION_DELETE:
4113
-                    $result = (bool) $entity->delete_permanently();
4114
-                    break;
4115
-                case EE_Admin_List_Table::ACTION_RESTORE:
4116
-                    $result = $entity->delete_or_restore(false);
4117
-                    break;
4118
-                case EE_Admin_List_Table::ACTION_TRASH:
4119
-                    $result = $entity->delete_or_restore();
4120
-                    break;
4121
-            }
4122
-        } catch (Exception $exception) {
4123
-            $this->trashRestoreDeleteError($action, $entity_model, $exception);
4124
-        }
4125
-        if (is_callable($callback)) {
4126
-            call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4127
-        }
4128
-        return $result;
4129
-    }
4130
-
4131
-
4132
-    /**
4133
-     * @param EEM_Base $entity_model
4134
-     * @param string   $delete_column
4135
-     * @since 4.10.30.p
4136
-     */
4137
-    private function validateDeleteColumn(EEM_Base $entity_model, $delete_column)
4138
-    {
4139
-        if (empty($delete_column)) {
4140
-            throw new DomainException(
4141
-                sprintf(
4142
-                    esc_html__(
4143
-                        'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4144
-                        'event_espresso'
4145
-                    ),
4146
-                    $entity_model->get_this_model_name()
4147
-                )
4148
-            );
4149
-        }
4150
-        if (! $entity_model->has_field($delete_column)) {
4151
-            throw new DomainException(
4152
-                sprintf(
4153
-                    esc_html__(
4154
-                        'The %1$s field does not exist on the %2$s model.',
4155
-                        'event_espresso'
4156
-                    ),
4157
-                    $delete_column,
4158
-                    $entity_model->get_this_model_name()
4159
-                )
4160
-            );
4161
-        }
4162
-    }
4163
-
4164
-
4165
-    /**
4166
-     * @param EEM_Base       $entity_model
4167
-     * @param Exception|null $exception
4168
-     * @param string         $action
4169
-     * @since 4.10.30.p
4170
-     */
4171
-    private function trashRestoreDeleteError($action, EEM_Base $entity_model, Exception $exception = null)
4172
-    {
4173
-        if ($exception instanceof Exception) {
4174
-            throw new RuntimeException(
4175
-                sprintf(
4176
-                    esc_html__(
4177
-                        'Could not %1$s the %2$s because the following error occurred: %3$s',
4178
-                        'event_espresso'
4179
-                    ),
4180
-                    $action,
4181
-                    $entity_model->get_this_model_name(),
4182
-                    $exception->getMessage()
4183
-                )
4184
-            );
4185
-        }
4186
-        throw new RuntimeException(
4187
-            sprintf(
4188
-                esc_html__(
4189
-                    'Could not %1$s the %2$s because an invalid ID was received.',
4190
-                    'event_espresso'
4191
-                ),
4192
-                $action,
4193
-                $entity_model->get_this_model_name()
4194
-            )
4195
-        );
4196
-    }
2854
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2855
+		// display message about search results?
2856
+		$search = $this->request->getRequestParam('s');
2857
+		$this->_template_args['before_list_table'] .= ! empty($search)
2858
+			? '<p class="ee-search-results">' . sprintf(
2859
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2860
+				trim($search, '%')
2861
+			) . '</p>'
2862
+			: '';
2863
+		// filter before_list_table template arg
2864
+		$this->_template_args['before_list_table'] = apply_filters(
2865
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2866
+			$this->_template_args['before_list_table'],
2867
+			$this->page_slug,
2868
+			$this->request->requestParams(),
2869
+			$this->_req_action
2870
+		);
2871
+		// convert to array and filter again
2872
+		// arrays are easier to inject new items in a specific location,
2873
+		// but would not be backwards compatible, so we have to add a new filter
2874
+		$this->_template_args['before_list_table'] = implode(
2875
+			" \n",
2876
+			(array) apply_filters(
2877
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2878
+				(array) $this->_template_args['before_list_table'],
2879
+				$this->page_slug,
2880
+				$this->request->requestParams(),
2881
+				$this->_req_action
2882
+			)
2883
+		);
2884
+		// filter after_list_table template arg
2885
+		$this->_template_args['after_list_table'] = apply_filters(
2886
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2887
+			$this->_template_args['after_list_table'],
2888
+			$this->page_slug,
2889
+			$this->request->requestParams(),
2890
+			$this->_req_action
2891
+		);
2892
+		// convert to array and filter again
2893
+		// arrays are easier to inject new items in a specific location,
2894
+		// but would not be backwards compatible, so we have to add a new filter
2895
+		$this->_template_args['after_list_table']   = implode(
2896
+			" \n",
2897
+			(array) apply_filters(
2898
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2899
+				(array) $this->_template_args['after_list_table'],
2900
+				$this->page_slug,
2901
+				$this->request->requestParams(),
2902
+				$this->_req_action
2903
+			)
2904
+		);
2905
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2906
+			$template_path,
2907
+			$this->_template_args,
2908
+			true
2909
+		);
2910
+		// the final template wrapper
2911
+		if ($sidebar) {
2912
+			$this->display_admin_page_with_sidebar();
2913
+		} else {
2914
+			$this->display_admin_page_with_no_sidebar();
2915
+		}
2916
+	}
2917
+
2918
+
2919
+	/**
2920
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2921
+	 * html string for the legend.
2922
+	 * $items are expected in an array in the following format:
2923
+	 * $legend_items = array(
2924
+	 *        'item_id' => array(
2925
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2926
+	 *            'desc' => esc_html__('localized description of item');
2927
+	 *        )
2928
+	 * );
2929
+	 *
2930
+	 * @param array $items see above for format of array
2931
+	 * @return string html string of legend
2932
+	 * @throws DomainException
2933
+	 */
2934
+	protected function _display_legend($items)
2935
+	{
2936
+		$this->_template_args['items'] = apply_filters(
2937
+			'FHEE__EE_Admin_Page___display_legend__items',
2938
+			(array) $items,
2939
+			$this
2940
+		);
2941
+		return EEH_Template::display_template(
2942
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2943
+			$this->_template_args,
2944
+			true
2945
+		);
2946
+	}
2947
+
2948
+
2949
+	/**
2950
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2951
+	 * The returned json object is created from an array in the following format:
2952
+	 * array(
2953
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2954
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
2955
+	 *  'notices' => '', // - contains any EE_Error formatted notices
2956
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2957
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2958
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
2959
+	 *  that might be included in here)
2960
+	 * )
2961
+	 * The json object is populated by whatever is set in the $_template_args property.
2962
+	 *
2963
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2964
+	 *                                 instead of displayed.
2965
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2966
+	 * @return void
2967
+	 * @throws EE_Error
2968
+	 */
2969
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
2970
+	{
2971
+		// make sure any EE_Error notices have been handled.
2972
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
2973
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2974
+		unset($this->_template_args['data']);
2975
+		$json = [
2976
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2977
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2978
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2979
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2980
+			'notices'   => EE_Error::get_notices(),
2981
+			'content'   => isset($this->_template_args['admin_page_content'])
2982
+				? $this->_template_args['admin_page_content'] : '',
2983
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2984
+			'isEEajax'  => true
2985
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2986
+		];
2987
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2988
+		if (null === error_get_last() || ! headers_sent()) {
2989
+			header('Content-Type: application/json; charset=UTF-8');
2990
+		}
2991
+		echo wp_json_encode($json);
2992
+		exit();
2993
+	}
2994
+
2995
+
2996
+	/**
2997
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2998
+	 *
2999
+	 * @return void
3000
+	 * @throws EE_Error
3001
+	 */
3002
+	public function return_json()
3003
+	{
3004
+		if ($this->request->isAjax()) {
3005
+			$this->_return_json();
3006
+		} else {
3007
+			throw new EE_Error(
3008
+				sprintf(
3009
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3010
+					__FUNCTION__
3011
+				)
3012
+			);
3013
+		}
3014
+	}
3015
+
3016
+
3017
+	/**
3018
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3019
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3020
+	 *
3021
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3022
+	 */
3023
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3024
+	{
3025
+		$this->_hook_obj = $hook_obj;
3026
+	}
3027
+
3028
+
3029
+	/**
3030
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3031
+	 *
3032
+	 * @param boolean $about whether to use the special about page wrapper or default.
3033
+	 * @return void
3034
+	 * @throws DomainException
3035
+	 * @throws EE_Error
3036
+	 */
3037
+	public function admin_page_wrapper($about = false)
3038
+	{
3039
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3040
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3041
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3042
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3043
+
3044
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3045
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3046
+			isset($this->_template_args['before_admin_page_content'])
3047
+				? $this->_template_args['before_admin_page_content']
3048
+				: ''
3049
+		);
3050
+
3051
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3052
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3053
+			isset($this->_template_args['after_admin_page_content'])
3054
+				? $this->_template_args['after_admin_page_content']
3055
+				: ''
3056
+		);
3057
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3058
+
3059
+		if ($this->request->isAjax()) {
3060
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3061
+				// $template_path,
3062
+				EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3063
+				$this->_template_args,
3064
+				true
3065
+			);
3066
+			$this->_return_json();
3067
+		}
3068
+		// load settings page wrapper template
3069
+		$template_path = $about
3070
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3071
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3072
+
3073
+		EEH_Template::display_template($template_path, $this->_template_args);
3074
+	}
3075
+
3076
+
3077
+	/**
3078
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3079
+	 *
3080
+	 * @return string html
3081
+	 * @throws EE_Error
3082
+	 */
3083
+	protected function _get_main_nav_tabs()
3084
+	{
3085
+		// let's generate the html using the EEH_Tabbed_Content helper.
3086
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3087
+		// (rather than setting in the page_routes array)
3088
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3089
+	}
3090
+
3091
+
3092
+	/**
3093
+	 *        sort nav tabs
3094
+	 *
3095
+	 * @param $a
3096
+	 * @param $b
3097
+	 * @return int
3098
+	 */
3099
+	private function _sort_nav_tabs($a, $b)
3100
+	{
3101
+		if ($a['order'] === $b['order']) {
3102
+			return 0;
3103
+		}
3104
+		return ($a['order'] < $b['order']) ? -1 : 1;
3105
+	}
3106
+
3107
+
3108
+	/**
3109
+	 *    generates HTML for the forms used on admin pages
3110
+	 *
3111
+	 * @param array  $input_vars   - array of input field details
3112
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3113
+	 *                             use)
3114
+	 * @param bool   $id
3115
+	 * @return array|string
3116
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3117
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3118
+	 */
3119
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3120
+	{
3121
+		return $generator === 'string'
3122
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3123
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3124
+	}
3125
+
3126
+
3127
+	/**
3128
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3129
+	 *
3130
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3131
+	 *                                   Close" button.
3132
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3133
+	 *                                   'Save', [1] => 'save & close')
3134
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3135
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3136
+	 *                                   default actions by submitting some other value.
3137
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3138
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3139
+	 *                                   close (normal form handling).
3140
+	 */
3141
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3142
+	{
3143
+		// make sure $text and $actions are in an array
3144
+		$text          = (array) $text;
3145
+		$actions       = (array) $actions;
3146
+		$referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3147
+		$button_text   = ! empty($text)
3148
+			? $text
3149
+			: [
3150
+				esc_html__('Save', 'event_espresso'),
3151
+				esc_html__('Save and Close', 'event_espresso'),
3152
+			];
3153
+		$default_names = ['save', 'save_and_close'];
3154
+		$buttons = '';
3155
+		foreach ($button_text as $key => $button) {
3156
+			$ref     = $default_names[ $key ];
3157
+			$name    = ! empty($actions) ? $actions[ $key ] : $ref;
3158
+			$buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3159
+						. 'value="' . $button . '" name="' . $name . '" '
3160
+						. 'id="' . $this->_current_view . '_' . $ref . '" />';
3161
+			if (! $both) {
3162
+				break;
3163
+			}
3164
+		}
3165
+		// add in a hidden index for the current page (so save and close redirects properly)
3166
+		$buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3167
+				   . $referrer_url
3168
+				   . '" />';
3169
+		$this->_template_args['save_buttons'] = $buttons;
3170
+	}
3171
+
3172
+
3173
+	/**
3174
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3175
+	 *
3176
+	 * @param string $route
3177
+	 * @param array  $additional_hidden_fields
3178
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3179
+	 * @since 4.6.0
3180
+	 */
3181
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3182
+	{
3183
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3184
+	}
3185
+
3186
+
3187
+	/**
3188
+	 * set form open and close tags on add/edit pages.
3189
+	 *
3190
+	 * @param string $route                    the route you want the form to direct to
3191
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3192
+	 * @return void
3193
+	 */
3194
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3195
+	{
3196
+		if (empty($route)) {
3197
+			$user_msg = esc_html__(
3198
+				'An error occurred. No action was set for this page\'s form.',
3199
+				'event_espresso'
3200
+			);
3201
+			$dev_msg  = $user_msg . "\n"
3202
+						. sprintf(
3203
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3204
+							__FUNCTION__,
3205
+							__CLASS__
3206
+						);
3207
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3208
+		}
3209
+		// open form
3210
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3211
+															 . $this->_admin_base_url
3212
+															 . '" id="'
3213
+															 . $route
3214
+															 . '_event_form" >';
3215
+		// add nonce
3216
+		$nonce                                             =
3217
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3218
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3219
+		// add REQUIRED form action
3220
+		$hidden_fields = [
3221
+			'action' => ['type' => 'hidden', 'value' => $route],
3222
+		];
3223
+		// merge arrays
3224
+		$hidden_fields = is_array($additional_hidden_fields)
3225
+			? array_merge($hidden_fields, $additional_hidden_fields)
3226
+			: $hidden_fields;
3227
+		// generate form fields
3228
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3229
+		// add fields to form
3230
+		foreach ((array) $form_fields as $form_field) {
3231
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3232
+		}
3233
+		// close form
3234
+		$this->_template_args['after_admin_page_content'] = '</form>';
3235
+	}
3236
+
3237
+
3238
+	/**
3239
+	 * Public Wrapper for _redirect_after_action() method since its
3240
+	 * discovered it would be useful for external code to have access.
3241
+	 *
3242
+	 * @param bool   $success
3243
+	 * @param string $what
3244
+	 * @param string $action_desc
3245
+	 * @param array  $query_args
3246
+	 * @param bool   $override_overwrite
3247
+	 * @throws EE_Error
3248
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3249
+	 * @since 4.5.0
3250
+	 */
3251
+	public function redirect_after_action(
3252
+		$success = false,
3253
+		$what = 'item',
3254
+		$action_desc = 'processed',
3255
+		$query_args = [],
3256
+		$override_overwrite = false
3257
+	) {
3258
+		$this->_redirect_after_action(
3259
+			$success,
3260
+			$what,
3261
+			$action_desc,
3262
+			$query_args,
3263
+			$override_overwrite
3264
+		);
3265
+	}
3266
+
3267
+
3268
+	/**
3269
+	 * Helper method for merging existing request data with the returned redirect url.
3270
+	 *
3271
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3272
+	 * filters are still applied.
3273
+	 *
3274
+	 * @param array $new_route_data
3275
+	 * @return array
3276
+	 */
3277
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3278
+	{
3279
+		foreach ($this->request->requestParams() as $ref => $value) {
3280
+			// unset nonces
3281
+			if (strpos($ref, 'nonce') !== false) {
3282
+				$this->request->unSetRequestParam($ref);
3283
+				continue;
3284
+			}
3285
+			// urlencode values.
3286
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3287
+			$this->request->setRequestParam($ref, $value);
3288
+		}
3289
+		return array_merge($this->request->requestParams(), $new_route_data);
3290
+	}
3291
+
3292
+
3293
+	/**
3294
+	 *    _redirect_after_action
3295
+	 *
3296
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3297
+	 * @param string $what               - what the action was performed on
3298
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3299
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3300
+	 *                                   action is completed
3301
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3302
+	 *                                   override this so that they show.
3303
+	 * @return void
3304
+	 * @throws EE_Error
3305
+	 */
3306
+	protected function _redirect_after_action(
3307
+		$success = 0,
3308
+		$what = 'item',
3309
+		$action_desc = 'processed',
3310
+		$query_args = [],
3311
+		$override_overwrite = false
3312
+	) {
3313
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3314
+		// class name for actions/filters.
3315
+		$classname = get_class($this);
3316
+		// set redirect url.
3317
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3318
+		// otherwise we go with whatever is set as the _admin_base_url
3319
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3320
+		$notices      = EE_Error::get_notices(false);
3321
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3322
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3323
+			EE_Error::overwrite_success();
3324
+		}
3325
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3326
+			// how many records affected ? more than one record ? or just one ?
3327
+			if ($success > 1) {
3328
+				// set plural msg
3329
+				EE_Error::add_success(
3330
+					sprintf(
3331
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3332
+						$what,
3333
+						$action_desc
3334
+					),
3335
+					__FILE__,
3336
+					__FUNCTION__,
3337
+					__LINE__
3338
+				);
3339
+			} elseif ($success === 1) {
3340
+				// set singular msg
3341
+				EE_Error::add_success(
3342
+					sprintf(
3343
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3344
+						$what,
3345
+						$action_desc
3346
+					),
3347
+					__FILE__,
3348
+					__FUNCTION__,
3349
+					__LINE__
3350
+				);
3351
+			}
3352
+		}
3353
+		// check that $query_args isn't something crazy
3354
+		if (! is_array($query_args)) {
3355
+			$query_args = [];
3356
+		}
3357
+		/**
3358
+		 * Allow injecting actions before the query_args are modified for possible different
3359
+		 * redirections on save and close actions
3360
+		 *
3361
+		 * @param array $query_args       The original query_args array coming into the
3362
+		 *                                method.
3363
+		 * @since 4.2.0
3364
+		 */
3365
+		do_action(
3366
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3367
+			$query_args
3368
+		);
3369
+		// calculate where we're going (if we have a "save and close" button pushed)
3370
+
3371
+		if (
3372
+			$this->request->requestParamIsSet('save_and_close')
3373
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3374
+		) {
3375
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3376
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3377
+			// regenerate query args array from referrer URL
3378
+			parse_str($parsed_url['query'], $query_args);
3379
+			// correct page and action will be in the query args now
3380
+			$redirect_url = admin_url('admin.php');
3381
+		}
3382
+		// merge any default query_args set in _default_route_query_args property
3383
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3384
+			$args_to_merge = [];
3385
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3386
+				// is there a wp_referer array in our _default_route_query_args property?
3387
+				if ($query_param === 'wp_referer') {
3388
+					$query_value = (array) $query_value;
3389
+					foreach ($query_value as $reference => $value) {
3390
+						if (strpos($reference, 'nonce') !== false) {
3391
+							continue;
3392
+						}
3393
+						// finally we will override any arguments in the referer with
3394
+						// what might be set on the _default_route_query_args array.
3395
+						if (isset($this->_default_route_query_args[ $reference ])) {
3396
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3397
+						} else {
3398
+							$args_to_merge[ $reference ] = urlencode($value);
3399
+						}
3400
+					}
3401
+					continue;
3402
+				}
3403
+				$args_to_merge[ $query_param ] = $query_value;
3404
+			}
3405
+			// now let's merge these arguments but override with what was specifically sent in to the
3406
+			// redirect.
3407
+			$query_args = array_merge($args_to_merge, $query_args);
3408
+		}
3409
+		$this->_process_notices($query_args);
3410
+		// generate redirect url
3411
+		// if redirecting to anything other than the main page, add a nonce
3412
+		if (isset($query_args['action'])) {
3413
+			// manually generate wp_nonce and merge that with the query vars
3414
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3415
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3416
+		}
3417
+		// we're adding some hooks and filters in here for processing any things just before redirects
3418
+		// (example: an admin page has done an insert or update and we want to run something after that).
3419
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3420
+		$redirect_url = apply_filters(
3421
+			'FHEE_redirect_' . $classname . $this->_req_action,
3422
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3423
+			$query_args
3424
+		);
3425
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3426
+		if ($this->request->isAjax()) {
3427
+			$default_data                    = [
3428
+				'close'        => true,
3429
+				'redirect_url' => $redirect_url,
3430
+				'where'        => 'main',
3431
+				'what'         => 'append',
3432
+			];
3433
+			$this->_template_args['success'] = $success;
3434
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3435
+				$default_data,
3436
+				$this->_template_args['data']
3437
+			) : $default_data;
3438
+			$this->_return_json();
3439
+		}
3440
+		wp_safe_redirect($redirect_url);
3441
+		exit();
3442
+	}
3443
+
3444
+
3445
+	/**
3446
+	 * process any notices before redirecting (or returning ajax request)
3447
+	 * This method sets the $this->_template_args['notices'] attribute;
3448
+	 *
3449
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3450
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3451
+	 *                                  page_routes haven't been defined yet.
3452
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3453
+	 *                                  still save a transient for the notice.
3454
+	 * @return void
3455
+	 * @throws EE_Error
3456
+	 */
3457
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3458
+	{
3459
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3460
+		if ($this->request->isAjax()) {
3461
+			$notices = EE_Error::get_notices(false);
3462
+			if (empty($this->_template_args['success'])) {
3463
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3464
+			}
3465
+			if (empty($this->_template_args['errors'])) {
3466
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3467
+			}
3468
+			if (empty($this->_template_args['attention'])) {
3469
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3470
+			}
3471
+		}
3472
+		$this->_template_args['notices'] = EE_Error::get_notices();
3473
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3474
+		if (! $this->request->isAjax() || $sticky_notices) {
3475
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3476
+			$this->_add_transient(
3477
+				$route,
3478
+				$this->_template_args['notices'],
3479
+				true,
3480
+				$skip_route_verify
3481
+			);
3482
+		}
3483
+	}
3484
+
3485
+
3486
+	/**
3487
+	 * get_action_link_or_button
3488
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3489
+	 *
3490
+	 * @param string $action        use this to indicate which action the url is generated with.
3491
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3492
+	 *                              property.
3493
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3494
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3495
+	 * @param string $base_url      If this is not provided
3496
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3497
+	 *                              Otherwise this value will be used.
3498
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3499
+	 * @return string
3500
+	 * @throws InvalidArgumentException
3501
+	 * @throws InvalidInterfaceException
3502
+	 * @throws InvalidDataTypeException
3503
+	 * @throws EE_Error
3504
+	 */
3505
+	public function get_action_link_or_button(
3506
+		$action,
3507
+		$type = 'add',
3508
+		$extra_request = [],
3509
+		$class = 'button button--primary',
3510
+		$base_url = '',
3511
+		$exclude_nonce = false
3512
+	) {
3513
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3514
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3515
+			throw new EE_Error(
3516
+				sprintf(
3517
+					esc_html__(
3518
+						'There is no page route for given action for the button.  This action was given: %s',
3519
+						'event_espresso'
3520
+					),
3521
+					$action
3522
+				)
3523
+			);
3524
+		}
3525
+		if (! isset($this->_labels['buttons'][ $type ])) {
3526
+			throw new EE_Error(
3527
+				sprintf(
3528
+					esc_html__(
3529
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3530
+						'event_espresso'
3531
+					),
3532
+					$type
3533
+				)
3534
+			);
3535
+		}
3536
+		// finally check user access for this button.
3537
+		$has_access = $this->check_user_access($action, true);
3538
+		if (! $has_access) {
3539
+			return '';
3540
+		}
3541
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3542
+		$query_args = [
3543
+			'action' => $action,
3544
+		];
3545
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3546
+		if (! empty($extra_request)) {
3547
+			$query_args = array_merge($extra_request, $query_args);
3548
+		}
3549
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3550
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3551
+	}
3552
+
3553
+
3554
+	/**
3555
+	 * _per_page_screen_option
3556
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3557
+	 *
3558
+	 * @return void
3559
+	 * @throws InvalidArgumentException
3560
+	 * @throws InvalidInterfaceException
3561
+	 * @throws InvalidDataTypeException
3562
+	 */
3563
+	protected function _per_page_screen_option()
3564
+	{
3565
+		$option = 'per_page';
3566
+		$args   = [
3567
+			'label'   => apply_filters(
3568
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3569
+				$this->_admin_page_title,
3570
+				$this
3571
+			),
3572
+			'default' => (int) apply_filters(
3573
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3574
+				20
3575
+			),
3576
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3577
+		];
3578
+		// ONLY add the screen option if the user has access to it.
3579
+		if ($this->check_user_access($this->_current_view, true)) {
3580
+			add_screen_option($option, $args);
3581
+		}
3582
+	}
3583
+
3584
+
3585
+	/**
3586
+	 * set_per_page_screen_option
3587
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3588
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3589
+	 * admin_menu.
3590
+	 *
3591
+	 * @return void
3592
+	 */
3593
+	private function _set_per_page_screen_options()
3594
+	{
3595
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3596
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3597
+			if (! $user = wp_get_current_user()) {
3598
+				return;
3599
+			}
3600
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3601
+			if (! $option) {
3602
+				return;
3603
+			}
3604
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3605
+			$map_option = $option;
3606
+			$option     = str_replace('-', '_', $option);
3607
+			switch ($map_option) {
3608
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3609
+					$max_value = apply_filters(
3610
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3611
+						999,
3612
+						$this->_current_page,
3613
+						$this->_current_view
3614
+					);
3615
+					if ($value < 1) {
3616
+						return;
3617
+					}
3618
+					$value = min($value, $max_value);
3619
+					break;
3620
+				default:
3621
+					$value = apply_filters(
3622
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3623
+						false,
3624
+						$option,
3625
+						$value
3626
+					);
3627
+					if (false === $value) {
3628
+						return;
3629
+					}
3630
+					break;
3631
+			}
3632
+			update_user_meta($user->ID, $option, $value);
3633
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3634
+			exit;
3635
+		}
3636
+	}
3637
+
3638
+
3639
+	/**
3640
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3641
+	 *
3642
+	 * @param array $data array that will be assigned to template args.
3643
+	 */
3644
+	public function set_template_args($data)
3645
+	{
3646
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3647
+	}
3648
+
3649
+
3650
+	/**
3651
+	 * This makes available the WP transient system for temporarily moving data between routes
3652
+	 *
3653
+	 * @param string $route             the route that should receive the transient
3654
+	 * @param array  $data              the data that gets sent
3655
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3656
+	 *                                  normal route transient.
3657
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3658
+	 *                                  when we are adding a transient before page_routes have been defined.
3659
+	 * @return void
3660
+	 * @throws EE_Error
3661
+	 */
3662
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3663
+	{
3664
+		$user_id = get_current_user_id();
3665
+		if (! $skip_route_verify) {
3666
+			$this->_verify_route($route);
3667
+		}
3668
+		// now let's set the string for what kind of transient we're setting
3669
+		$transient = $notices
3670
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3671
+			: 'rte_tx_' . $route . '_' . $user_id;
3672
+		$data      = $notices ? ['notices' => $data] : $data;
3673
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3674
+		$existing = is_multisite() && is_network_admin()
3675
+			? get_site_transient($transient)
3676
+			: get_transient($transient);
3677
+		if ($existing) {
3678
+			$data = array_merge((array) $data, (array) $existing);
3679
+		}
3680
+		if (is_multisite() && is_network_admin()) {
3681
+			set_site_transient($transient, $data, 8);
3682
+		} else {
3683
+			set_transient($transient, $data, 8);
3684
+		}
3685
+	}
3686
+
3687
+
3688
+	/**
3689
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3690
+	 *
3691
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3692
+	 * @param string $route
3693
+	 * @return mixed data
3694
+	 */
3695
+	protected function _get_transient($notices = false, $route = '')
3696
+	{
3697
+		$user_id   = get_current_user_id();
3698
+		$route     = ! $route ? $this->_req_action : $route;
3699
+		$transient = $notices
3700
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3701
+			: 'rte_tx_' . $route . '_' . $user_id;
3702
+		$data      = is_multisite() && is_network_admin()
3703
+			? get_site_transient($transient)
3704
+			: get_transient($transient);
3705
+		// delete transient after retrieval (just in case it hasn't expired);
3706
+		if (is_multisite() && is_network_admin()) {
3707
+			delete_site_transient($transient);
3708
+		} else {
3709
+			delete_transient($transient);
3710
+		}
3711
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3712
+	}
3713
+
3714
+
3715
+	/**
3716
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3717
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3718
+	 * default route callback on the EE_Admin page you want it run.)
3719
+	 *
3720
+	 * @return void
3721
+	 */
3722
+	protected function _transient_garbage_collection()
3723
+	{
3724
+		global $wpdb;
3725
+		// retrieve all existing transients
3726
+		$query =
3727
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3728
+		if ($results = $wpdb->get_results($query)) {
3729
+			foreach ($results as $result) {
3730
+				$transient = str_replace('_transient_', '', $result->option_name);
3731
+				get_transient($transient);
3732
+				if (is_multisite() && is_network_admin()) {
3733
+					get_site_transient($transient);
3734
+				}
3735
+			}
3736
+		}
3737
+	}
3738
+
3739
+
3740
+	/**
3741
+	 * get_view
3742
+	 *
3743
+	 * @return string content of _view property
3744
+	 */
3745
+	public function get_view()
3746
+	{
3747
+		return $this->_view;
3748
+	}
3749
+
3750
+
3751
+	/**
3752
+	 * getter for the protected $_views property
3753
+	 *
3754
+	 * @return array
3755
+	 */
3756
+	public function get_views()
3757
+	{
3758
+		return $this->_views;
3759
+	}
3760
+
3761
+
3762
+	/**
3763
+	 * get_current_page
3764
+	 *
3765
+	 * @return string _current_page property value
3766
+	 */
3767
+	public function get_current_page()
3768
+	{
3769
+		return $this->_current_page;
3770
+	}
3771
+
3772
+
3773
+	/**
3774
+	 * get_current_view
3775
+	 *
3776
+	 * @return string _current_view property value
3777
+	 */
3778
+	public function get_current_view()
3779
+	{
3780
+		return $this->_current_view;
3781
+	}
3782
+
3783
+
3784
+	/**
3785
+	 * get_current_screen
3786
+	 *
3787
+	 * @return object The current WP_Screen object
3788
+	 */
3789
+	public function get_current_screen()
3790
+	{
3791
+		return $this->_current_screen;
3792
+	}
3793
+
3794
+
3795
+	/**
3796
+	 * get_current_page_view_url
3797
+	 *
3798
+	 * @return string This returns the url for the current_page_view.
3799
+	 */
3800
+	public function get_current_page_view_url()
3801
+	{
3802
+		return $this->_current_page_view_url;
3803
+	}
3804
+
3805
+
3806
+	/**
3807
+	 * just returns the Request
3808
+	 *
3809
+	 * @return RequestInterface
3810
+	 */
3811
+	public function get_request()
3812
+	{
3813
+		return $this->request;
3814
+	}
3815
+
3816
+
3817
+	/**
3818
+	 * just returns the _req_data property
3819
+	 *
3820
+	 * @return array
3821
+	 */
3822
+	public function get_request_data()
3823
+	{
3824
+		return $this->request->requestParams();
3825
+	}
3826
+
3827
+
3828
+	/**
3829
+	 * returns the _req_data protected property
3830
+	 *
3831
+	 * @return string
3832
+	 */
3833
+	public function get_req_action()
3834
+	{
3835
+		return $this->_req_action;
3836
+	}
3837
+
3838
+
3839
+	/**
3840
+	 * @return bool  value of $_is_caf property
3841
+	 */
3842
+	public function is_caf()
3843
+	{
3844
+		return $this->_is_caf;
3845
+	}
3846
+
3847
+
3848
+	/**
3849
+	 * @return mixed
3850
+	 */
3851
+	public function default_espresso_metaboxes()
3852
+	{
3853
+		return $this->_default_espresso_metaboxes;
3854
+	}
3855
+
3856
+
3857
+	/**
3858
+	 * @return mixed
3859
+	 */
3860
+	public function admin_base_url()
3861
+	{
3862
+		return $this->_admin_base_url;
3863
+	}
3864
+
3865
+
3866
+	/**
3867
+	 * @return mixed
3868
+	 */
3869
+	public function wp_page_slug()
3870
+	{
3871
+		return $this->_wp_page_slug;
3872
+	}
3873
+
3874
+
3875
+	/**
3876
+	 * updates  espresso configuration settings
3877
+	 *
3878
+	 * @param string                   $tab
3879
+	 * @param EE_Config_Base|EE_Config $config
3880
+	 * @param string                   $file file where error occurred
3881
+	 * @param string                   $func function  where error occurred
3882
+	 * @param string                   $line line no where error occurred
3883
+	 * @return boolean
3884
+	 */
3885
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3886
+	{
3887
+		// remove any options that are NOT going to be saved with the config settings.
3888
+		if (isset($config->core->ee_ueip_optin)) {
3889
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3890
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3891
+			update_option('ee_ueip_has_notified', true);
3892
+		}
3893
+		// and save it (note we're also doing the network save here)
3894
+		$net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3895
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3896
+		if ($config_saved && $net_saved) {
3897
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3898
+			return true;
3899
+		}
3900
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3901
+		return false;
3902
+	}
3903
+
3904
+
3905
+	/**
3906
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3907
+	 *
3908
+	 * @return array
3909
+	 */
3910
+	public function get_yes_no_values()
3911
+	{
3912
+		return $this->_yes_no_values;
3913
+	}
3914
+
3915
+
3916
+	protected function _get_dir()
3917
+	{
3918
+		$reflector = new ReflectionClass(get_class($this));
3919
+		return dirname($reflector->getFileName());
3920
+	}
3921
+
3922
+
3923
+	/**
3924
+	 * A helper for getting a "next link".
3925
+	 *
3926
+	 * @param string $url   The url to link to
3927
+	 * @param string $class The class to use.
3928
+	 * @return string
3929
+	 */
3930
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3931
+	{
3932
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3933
+	}
3934
+
3935
+
3936
+	/**
3937
+	 * A helper for getting a "previous link".
3938
+	 *
3939
+	 * @param string $url   The url to link to
3940
+	 * @param string $class The class to use.
3941
+	 * @return string
3942
+	 */
3943
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3944
+	{
3945
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3946
+	}
3947
+
3948
+
3949
+
3950
+
3951
+
3952
+
3953
+
3954
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3955
+
3956
+
3957
+	/**
3958
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3959
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
3960
+	 * _req_data array.
3961
+	 *
3962
+	 * @return bool success/fail
3963
+	 * @throws EE_Error
3964
+	 * @throws InvalidArgumentException
3965
+	 * @throws ReflectionException
3966
+	 * @throws InvalidDataTypeException
3967
+	 * @throws InvalidInterfaceException
3968
+	 */
3969
+	protected function _process_resend_registration()
3970
+	{
3971
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3972
+		do_action(
3973
+			'AHEE__EE_Admin_Page___process_resend_registration',
3974
+			$this->_template_args['success'],
3975
+			$this->request->requestParams()
3976
+		);
3977
+		return $this->_template_args['success'];
3978
+	}
3979
+
3980
+
3981
+	/**
3982
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3983
+	 *
3984
+	 * @param EE_Payment $payment
3985
+	 * @return bool success/fail
3986
+	 */
3987
+	protected function _process_payment_notification(EE_Payment $payment)
3988
+	{
3989
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3990
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3991
+		$this->_template_args['success'] = apply_filters(
3992
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3993
+			false,
3994
+			$payment
3995
+		);
3996
+		return $this->_template_args['success'];
3997
+	}
3998
+
3999
+
4000
+	/**
4001
+	 * @param EEM_Base      $entity_model
4002
+	 * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4003
+	 * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4004
+	 * @param string        $delete_column  name of the field that denotes whether entity is trashed
4005
+	 * @param callable|null $callback       called after entity is trashed, restored, or deleted
4006
+	 * @return int|float
4007
+	 * @throws EE_Error
4008
+	 */
4009
+	protected function trashRestoreDeleteEntities(
4010
+		EEM_Base $entity_model,
4011
+		$entity_PK_name,
4012
+		$action = EE_Admin_List_Table::ACTION_DELETE,
4013
+		$delete_column = '',
4014
+		callable $callback = null
4015
+	) {
4016
+		$entity_PK      = $entity_model->get_primary_key_field();
4017
+		$entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4018
+		$entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4019
+		// grab ID if deleting a single entity
4020
+		if ($this->request->requestParamIsSet($entity_PK_name)) {
4021
+			$ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4022
+			return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4023
+		}
4024
+		// or grab checkbox array if bulk deleting
4025
+		$checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4026
+		if (empty($checkboxes)) {
4027
+			return 0;
4028
+		}
4029
+		$success = 0;
4030
+		$IDs     = array_keys($checkboxes);
4031
+		// cycle thru bulk action checkboxes
4032
+		foreach ($IDs as $ID) {
4033
+			// increment $success
4034
+			if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4035
+				$success++;
4036
+			}
4037
+		}
4038
+		$count = (int) count($checkboxes);
4039
+		// if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4040
+		// otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4041
+		return $success === $count ? $count : $success / $count;
4042
+	}
4043
+
4044
+
4045
+	/**
4046
+	 * @param EE_Primary_Key_Field_Base $entity_PK
4047
+	 * @return string
4048
+	 * @throws EE_Error
4049
+	 * @since   4.10.30.p
4050
+	 */
4051
+	private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK)
4052
+	{
4053
+		$entity_PK_type = $entity_PK->getSchemaType();
4054
+		switch ($entity_PK_type) {
4055
+			case 'boolean':
4056
+				return 'bool';
4057
+			case 'integer':
4058
+				return 'int';
4059
+			case 'number':
4060
+				return 'float';
4061
+			case 'string':
4062
+				return 'string';
4063
+		}
4064
+		throw new RuntimeException(
4065
+			sprintf(
4066
+				esc_html__(
4067
+					'"%1$s" is an invalid schema type for the %2$s primary key.',
4068
+					'event_espresso'
4069
+				),
4070
+				$entity_PK_type,
4071
+				$entity_PK->get_name()
4072
+			)
4073
+		);
4074
+	}
4075
+
4076
+
4077
+	/**
4078
+	 * @param EEM_Base      $entity_model
4079
+	 * @param int|string    $entity_ID
4080
+	 * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4081
+	 * @param string        $delete_column name of the field that denotes whether entity is trashed
4082
+	 * @param callable|null $callback      called after entity is trashed, restored, or deleted
4083
+	 * @return bool
4084
+	 */
4085
+	protected function trashRestoreDeleteEntity(
4086
+		EEM_Base $entity_model,
4087
+		$entity_ID,
4088
+		$action,
4089
+		$delete_column,
4090
+		callable $callback = null
4091
+	) {
4092
+		$entity_ID = absint($entity_ID);
4093
+		if (! $entity_ID) {
4094
+			$this->trashRestoreDeleteError($action, $entity_model);
4095
+		}
4096
+		$result = 0;
4097
+		try {
4098
+			$entity = $entity_model->get_one_by_ID($entity_ID);
4099
+			if (! $entity instanceof EE_Base_Class) {
4100
+				throw new DomainException(
4101
+					sprintf(
4102
+						esc_html__(
4103
+							'Missing or invalid %1$s entity with ID of "%2$s" returned from db.',
4104
+							'event_espresso'
4105
+						),
4106
+						str_replace('EEM_', '', $entity_model->get_this_model_name()),
4107
+						$entity_ID
4108
+					)
4109
+				);
4110
+			}
4111
+			switch ($action) {
4112
+				case EE_Admin_List_Table::ACTION_DELETE:
4113
+					$result = (bool) $entity->delete_permanently();
4114
+					break;
4115
+				case EE_Admin_List_Table::ACTION_RESTORE:
4116
+					$result = $entity->delete_or_restore(false);
4117
+					break;
4118
+				case EE_Admin_List_Table::ACTION_TRASH:
4119
+					$result = $entity->delete_or_restore();
4120
+					break;
4121
+			}
4122
+		} catch (Exception $exception) {
4123
+			$this->trashRestoreDeleteError($action, $entity_model, $exception);
4124
+		}
4125
+		if (is_callable($callback)) {
4126
+			call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4127
+		}
4128
+		return $result;
4129
+	}
4130
+
4131
+
4132
+	/**
4133
+	 * @param EEM_Base $entity_model
4134
+	 * @param string   $delete_column
4135
+	 * @since 4.10.30.p
4136
+	 */
4137
+	private function validateDeleteColumn(EEM_Base $entity_model, $delete_column)
4138
+	{
4139
+		if (empty($delete_column)) {
4140
+			throw new DomainException(
4141
+				sprintf(
4142
+					esc_html__(
4143
+						'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4144
+						'event_espresso'
4145
+					),
4146
+					$entity_model->get_this_model_name()
4147
+				)
4148
+			);
4149
+		}
4150
+		if (! $entity_model->has_field($delete_column)) {
4151
+			throw new DomainException(
4152
+				sprintf(
4153
+					esc_html__(
4154
+						'The %1$s field does not exist on the %2$s model.',
4155
+						'event_espresso'
4156
+					),
4157
+					$delete_column,
4158
+					$entity_model->get_this_model_name()
4159
+				)
4160
+			);
4161
+		}
4162
+	}
4163
+
4164
+
4165
+	/**
4166
+	 * @param EEM_Base       $entity_model
4167
+	 * @param Exception|null $exception
4168
+	 * @param string         $action
4169
+	 * @since 4.10.30.p
4170
+	 */
4171
+	private function trashRestoreDeleteError($action, EEM_Base $entity_model, Exception $exception = null)
4172
+	{
4173
+		if ($exception instanceof Exception) {
4174
+			throw new RuntimeException(
4175
+				sprintf(
4176
+					esc_html__(
4177
+						'Could not %1$s the %2$s because the following error occurred: %3$s',
4178
+						'event_espresso'
4179
+					),
4180
+					$action,
4181
+					$entity_model->get_this_model_name(),
4182
+					$exception->getMessage()
4183
+				)
4184
+			);
4185
+		}
4186
+		throw new RuntimeException(
4187
+			sprintf(
4188
+				esc_html__(
4189
+					'Could not %1$s the %2$s because an invalid ID was received.',
4190
+					'event_espresso'
4191
+				),
4192
+				$action,
4193
+				$entity_model->get_this_model_name()
4194
+			)
4195
+		);
4196
+	}
4197 4197
 }
Please login to merge, or discard this patch.