Completed
Branch master (724475)
by
unknown
05:49
created
admin_pages/maintenance/Maintenance_Admin_Page.core.php 2 patches
Indentation   +950 added lines, -950 removed lines patch added patch discarded remove patch
@@ -15,954 +15,954 @@
 block discarded – undo
15 15
  */
16 16
 class Maintenance_Admin_Page extends EE_Admin_Page
17 17
 {
18
-    protected EE_Data_Migration_Manager $migration_manager;
19
-
20
-    protected EE_Maintenance_Mode $maintenance_mode;
21
-
22
-    protected ?EE_Form_Section_Proper $datetime_fix_offset_form = null;
23
-
24
-
25
-    /**
26
-     * @param bool $routing
27
-     * @throws ReflectionException
28
-     */
29
-    public function __construct($routing = true)
30
-    {
31
-        $this->migration_manager = EE_Data_Migration_Manager::instance();
32
-        $this->maintenance_mode  = EE_Maintenance_Mode::instance();
33
-        parent::__construct($routing);
34
-    }
35
-
36
-
37
-    protected function _init_page_props()
38
-    {
39
-        $this->page_slug        = EE_MAINTENANCE_PG_SLUG;
40
-        $this->page_label       = EE_MAINTENANCE_LABEL;
41
-        $this->_admin_base_url  = EE_MAINTENANCE_ADMIN_URL;
42
-        $this->_admin_base_path = EE_MAINTENANCE_ADMIN;
43
-    }
44
-
45
-
46
-    protected function _ajax_hooks()
47
-    {
48
-        if (! $this->capabilities->current_user_can('manage_options', 'perform-migrations')) {
49
-            return;
50
-        }
51
-        add_action('wp_ajax_migration_step', [$this, 'migration_step']);
52
-        add_action('wp_ajax_add_error_to_migrations_ran', [$this, 'add_error_to_migrations_ran']);
53
-    }
54
-
55
-
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = EE_MAINTENANCE_LABEL;
59
-        $this->_labels           = [
60
-            'buttons' => [
61
-                'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'),
62
-                'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'),
63
-            ],
64
-        ];
65
-    }
66
-
67
-
68
-    protected function _set_page_routes()
69
-    {
70
-        $this->_page_routes = [
71
-            'default'                             => [
72
-                'func'       => [$this, '_maintenance'],
73
-                'capability' => 'manage_options',
74
-            ],
75
-            'change_maintenance_level'            => [
76
-                'func'       => [$this, '_change_maintenance_level'],
77
-                'capability' => 'manage_options',
78
-                'noheader'   => true,
79
-            ],
80
-            'system_status'                       => [
81
-                'func'       => [$this, '_system_status'],
82
-                'capability' => 'manage_options',
83
-            ],
84
-            'download_system_status'              => [
85
-                'func'       => [$this, '_download_system_status'],
86
-                'capability' => 'manage_options',
87
-                'noheader'   => true,
88
-            ],
89
-            'send_migration_crash_report'         => [
90
-                'func'       => [$this, '_send_migration_crash_report'],
91
-                'capability' => 'manage_options',
92
-                'noheader'   => true,
93
-            ],
94
-            'confirm_migration_crash_report_sent' => [
95
-                'func'       => [$this, '_confirm_migration_crash_report_sent'],
96
-                'capability' => 'manage_options',
97
-            ],
98
-            'data_reset'                          => [
99
-                'func'       => [$this, '_data_reset_and_delete'],
100
-                'capability' => 'manage_options',
101
-            ],
102
-            'reset_db'                            => [
103
-                'func'       => [$this, '_reset_db'],
104
-                'capability' => 'manage_options',
105
-                'noheader'   => true,
106
-                'args'       => ['nuke_old_ee4_data' => true],
107
-            ],
108
-            'start_with_fresh_ee4_db'             => [
109
-                'func'       => [$this, '_reset_db'],
110
-                'capability' => 'manage_options',
111
-                'noheader'   => true,
112
-                'args'       => ['nuke_old_ee4_data' => false],
113
-            ],
114
-            'delete_db'                           => [
115
-                'func'       => [$this, '_delete_db'],
116
-                'capability' => 'manage_options',
117
-                'noheader'   => true,
118
-            ],
119
-            'rerun_migration_from_ee3'            => [
120
-                'func'       => [$this, '_rerun_migration_from_ee3'],
121
-                'capability' => 'manage_options',
122
-                'noheader'   => true,
123
-            ],
124
-            'reset_reservations'                  => [
125
-                'func'       => [$this, '_reset_reservations'],
126
-                'capability' => 'manage_options',
127
-                'noheader'   => true,
128
-            ],
129
-            'reset_capabilities'                  => [
130
-                'func'       => [$this, '_reset_capabilities'],
131
-                'capability' => 'manage_options',
132
-                'noheader'   => true,
133
-            ],
134
-            'reattempt_migration'                 => [
135
-                'func'       => [$this, '_reattempt_migration'],
136
-                'capability' => 'manage_options',
137
-                'noheader'   => true,
138
-            ],
139
-            'datetime_tools'                      => [
140
-                'func'       => [$this, '_datetime_tools'],
141
-                'capability' => 'manage_options',
142
-            ],
143
-            'run_datetime_offset_fix'             => [
144
-                'func'               => [$this, '_apply_datetime_offset'],
145
-                'noheader'           => true,
146
-                'headers_sent_route' => 'datetime_tools',
147
-                'capability'         => 'manage_options',
148
-            ],
149
-        ];
150
-    }
151
-
152
-
153
-    protected function _set_page_config()
154
-    {
155
-        $this->_page_config = [
156
-            'default'        => [
157
-                'nav'           => [
158
-                    'label' => esc_html__('Maintenance', 'event_espresso'),
159
-                    'icon'  => 'dashicons-admin-tools',
160
-                    'order' => 10,
161
-                ],
162
-                'require_nonce' => false,
163
-            ],
164
-            'data_reset'     => [
165
-                'nav'           => [
166
-                    'label' => esc_html__('Reset/Delete Data', 'event_espresso'),
167
-                    'icon'  => 'dashicons-trash',
168
-                    'order' => 20,
169
-                ],
170
-                'require_nonce' => false,
171
-            ],
172
-            'datetime_tools' => [
173
-                'nav'           => [
174
-                    'label' => esc_html__('Datetime Utilities', 'event_espresso'),
175
-                    'icon'  => 'dashicons-calendar-alt',
176
-                    'order' => 25,
177
-                ],
178
-                'require_nonce' => false,
179
-            ],
180
-            'system_status'  => [
181
-                'nav'           => [
182
-                    'label' => esc_html__("System Information", "event_espresso"),
183
-                    'icon'  => 'dashicons-info',
184
-                    'order' => 30,
185
-                ],
186
-                'require_nonce' => false,
187
-            ],
188
-        ];
189
-    }
190
-
191
-
192
-    /**
193
-     * default maintenance page.
194
-     * If we're in maintenance mode level 2, then we need to show the migration scripts and all that UI.
195
-     *
196
-     * @throws EE_Error
197
-     */
198
-    public function _maintenance()
199
-    {
200
-        $show_maintenance_switch         = true;
201
-        $show_backup_db_text             = false;
202
-        $show_migration_progress         = false;
203
-        $script_names                    = [];
204
-        $addons_should_be_upgraded_first = false;
205
-        // it all depends on if we're in maintenance model level 1 (frontend-only) or
206
-        // level 2 (everything except maintenance page)
207
-        try {
208
-            // get the current maintenance level and check if we are removed
209
-            $was_full_site_maintenence_mode = MaintenanceStatus::isFullSite();
210
-            $no_longer_in_maintenence_mode = ! $this->maintenance_mode->set_maintenance_mode_if_db_old();
211
-            if ($was_full_site_maintenence_mode && $no_longer_in_maintenence_mode) {
212
-                // we just took the site out of maintenance mode, so notify the user.
213
-                // unfortunately this message appears to be echoed on the NEXT page load...
214
-                // oh well, we should really be checking for this on addon deactivation anyways
215
-                EE_Error::add_attention(
216
-                    esc_html__(
217
-                        'Site taken out of maintenance mode because no data migration scripts are required',
218
-                        'event_espresso'
219
-                    )
220
-                );
221
-                $this->_process_notices(['page' => 'espresso_maintenance_settings']);
222
-            }
223
-            // in case an exception is thrown while trying to handle migrations
224
-            if (MaintenanceStatus::isFullSite()) {
225
-                $show_maintenance_switch = false;
226
-                $show_migration_progress = true;
227
-                if (! isset($this->_req_data['continue_migration'])) {
228
-                    $show_backup_db_text = true;
229
-                }
230
-                $scripts_needing_to_run          =
231
-                    $this->migration_manager->check_for_applicable_data_migration_scripts();
232
-                $addons_should_be_upgraded_first = $this->migration_manager->addons_need_updating();
233
-                $script_names                    = [];
234
-                $current_script                  = null;
235
-                foreach ($scripts_needing_to_run as $script) {
236
-                    if ($script instanceof EE_Data_Migration_Script_Base) {
237
-                        if (! $current_script) {
238
-                            $current_script = $script;
239
-                            $current_script->migration_page_hooks();
240
-                        }
241
-                        $script_names[] = $script->pretty_name();
242
-                    }
243
-                }
244
-            }
245
-            $most_recent_migration = $this->migration_manager->get_last_ran_script(true);
246
-            $exception_thrown      = false;
247
-        } catch (EE_Error $e) {
248
-            $this->migration_manager->add_error_to_migrations_ran($e->getMessage());
249
-            // now, just so we can display the page correctly, make an error migration script stage object
250
-            // and also put the error on it. It only persists for the duration of this request
251
-            $most_recent_migration = new EE_DMS_Unknown_1_0_0();
252
-            $most_recent_migration->add_error($e->getMessage());
253
-            $exception_thrown = true;
254
-        }
255
-        $current_db_state = $this->migration_manager->ensure_current_database_state_is_set();
256
-        $current_db_state = str_replace('.decaf', '', $current_db_state);
257
-        if (
258
-            $exception_thrown
259
-            || (
260
-                $most_recent_migration instanceof EE_Data_Migration_Script_Base
261
-                && $most_recent_migration->is_broken()
262
-            )
263
-        ) {
264
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
265
-
266
-            $this->_template_args['support_url'] = 'https://eventespresso.com/support/forums/';
267
-            $this->_template_args['next_url']    = EEH_URL::add_query_args_and_nonce(
268
-                [
269
-                    'action'  => 'confirm_migration_crash_report_sent',
270
-                    'success' => '0',
271
-                ],
272
-                EE_MAINTENANCE_ADMIN_URL
273
-            );
274
-        } elseif ($addons_should_be_upgraded_first) {
275
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
276
-        } else {
277
-            if (
278
-                $most_recent_migration instanceof EE_Data_Migration_Script_Base
279
-                && $most_recent_migration->can_continue()
280
-            ) {
281
-                $show_backup_db_text                    = false;
282
-                $show_continue_current_migration_script = true;
283
-                $show_most_recent_migration             = true;
284
-            } elseif (isset($this->_req_data['continue_migration'])) {
285
-                $show_most_recent_migration             = true;
286
-                $show_continue_current_migration_script = false;
287
-            } else {
288
-                $show_most_recent_migration             = false;
289
-                $show_continue_current_migration_script = false;
290
-            }
291
-            if (isset($current_script)) {
292
-                $migrates_to          = $current_script->migrates_to_version();
293
-                $plugin_slug          = $migrates_to['slug'];
294
-                $new_version          = $migrates_to['version'];
295
-                $this->_template_args = array_merge(
296
-                    $this->_template_args,
297
-                    [
298
-                        'current_db_state' => sprintf(
299
-                            esc_html__("EE%s (%s)", "event_espresso"),
300
-                            $current_db_state[ $plugin_slug ] ?? 3,
301
-                            $plugin_slug
302
-                        ),
303
-                        'next_db_state'    => sprintf(
304
-                            esc_html__("EE%s (%s)", 'event_espresso'),
305
-                            $new_version,
306
-                            $plugin_slug
307
-                        ),
308
-                    ]
309
-                );
310
-            } else {
311
-                $this->_template_args['current_db_state'] = '';
312
-                $this->_template_args['next_db_state']    = '';
313
-            }
314
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
315
-            $this->_template_args = array_merge(
316
-                $this->_template_args,
317
-                [
318
-                    'show_most_recent_migration'             => $show_most_recent_migration,
319
-                    // flag for showing the most recent migration's status and/or errors
320
-                    'show_migration_progress'                => $show_migration_progress,
321
-                    // flag for showing the option to run migrations and see their progress
322
-                    'show_backup_db_text'                    => $show_backup_db_text,
323
-                    // flag for showing text telling the user to back up their DB
324
-                    'show_maintenance_switch'                => $show_maintenance_switch,
325
-                    // flag for showing the option to change maintenance mode between levels 0 and 1
326
-                    'script_names'                           => $script_names,
327
-                    // array of names of scripts that have run
328
-                    'show_continue_current_migration_script' => $show_continue_current_migration_script,
329
-                    // flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
330
-                    'reset_db_page_link'                     => EE_Admin_Page::add_query_args_and_nonce(
331
-                        ['action' => 'reset_db'],
332
-                        EE_MAINTENANCE_ADMIN_URL
333
-                    ),
334
-                    'data_reset_page'                        => EE_Admin_Page::add_query_args_and_nonce(
335
-                        ['action' => 'data_reset'],
336
-                        EE_MAINTENANCE_ADMIN_URL
337
-                    ),
338
-                    'update_migration_script_page_link'      => EE_Admin_Page::add_query_args_and_nonce(
339
-                        ['action' => 'change_maintenance_level'],
340
-                        EE_MAINTENANCE_ADMIN_URL
341
-                    ),
342
-                    'ultimate_db_state'                      => sprintf(
343
-                        esc_html__("EE%s", 'event_espresso'),
344
-                        espresso_version()
345
-                    ),
346
-                    'real_level'                             => $this->maintenance_mode->real_level(),
347
-                ]
348
-            );
349
-        }
350
-        $this->_template_args['most_recent_migration'] =
351
-            $most_recent_migration;// the actual most recently ran migration
352
-        // now render the migration options part, and put it in a variable
353
-        $migration_options_template_file                = apply_filters(
354
-            'FHEE__ee_migration_page__migration_options_template',
355
-            EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
356
-        );
357
-        $migration_options_html                         = EEH_Template::display_template(
358
-            $migration_options_template_file,
359
-            $this->_template_args,
360
-            true
361
-        );
362
-        $this->_template_args['migration_options_html'] = $migration_options_html;
363
-        $this->_template_args['admin_page_content']     = EEH_Template::display_template(
364
-            $this->_template_path,
365
-            $this->_template_args,
366
-            true
367
-        );
368
-        $this->display_admin_page_with_sidebar();
369
-    }
370
-
371
-
372
-    /**
373
-     * returns JSON and executes another step of the currently-executing data migration (called via ajax)
374
-     *
375
-     * @throws EE_Error
376
-     */
377
-    public function migration_step()
378
-    {
379
-        if (! $this->capabilities->current_user_can('manage_options', __FUNCTION__)) {
380
-            wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso'));
381
-        }
382
-        $this->_template_args['data'] = $this->migration_manager->response_to_migration_ajax_request();
383
-        $this->_return_json();
384
-    }
385
-
386
-
387
-    /**
388
-     * Can be used by js when it notices a response with HTML in it in order
389
-     * to log the malformed response
390
-     *
391
-     * @throws EE_Error
392
-     */
393
-    public function add_error_to_migrations_ran()
394
-    {
395
-        $this->migration_manager->add_error_to_migrations_ran($this->_req_data['message']);
396
-        $this->_template_args['data'] = ['ok' => true];
397
-        $this->_return_json();
398
-    }
399
-
400
-
401
-    /**
402
-     * changes the maintenance level, provided there are still no migration scripts that should run
403
-     *
404
-     * @throws EE_Error
405
-     */
406
-    public function _change_maintenance_level()
407
-    {
408
-        $new_level = absint($this->_req_data['maintenance_mode_level']);
409
-        if (! $this->migration_manager->check_for_applicable_data_migration_scripts()) {
410
-            $this->maintenance_mode->set_maintenance_level($new_level);
411
-            $success = true;
412
-        } else {
413
-            $this->maintenance_mode->set_maintenance_mode_if_db_old();
414
-            $success = false;
415
-        }
416
-        $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso"));
417
-    }
418
-
419
-
420
-    /**
421
-     * a tab with options for resetting and/or deleting EE data
422
-     *
423
-     * @throws EE_Error
424
-     * @throws DomainException
425
-     */
426
-    public function _data_reset_and_delete()
427
-    {
428
-        $this->_template_path                              =
429
-            EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
430
-        $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button(
431
-            'reset_reservations',
432
-            'reset_reservations',
433
-            [],
434
-            'button button--caution ee-confirm'
435
-        );
436
-        $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
437
-            'reset_capabilities',
438
-            'reset_capabilities',
439
-            [],
440
-            'button button--caution ee-confirm'
441
-        );
442
-        $this->_template_args['delete_db_url']             = EE_Admin_Page::add_query_args_and_nonce(
443
-            ['action' => 'delete_db'],
444
-            EE_MAINTENANCE_ADMIN_URL
445
-        );
446
-        $this->_template_args['reset_db_url']              = EE_Admin_Page::add_query_args_and_nonce(
447
-            ['action' => 'reset_db'],
448
-            EE_MAINTENANCE_ADMIN_URL
449
-        );
450
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
451
-            $this->_template_path,
452
-            $this->_template_args,
453
-            true
454
-        );
455
-        $this->display_admin_page_with_no_sidebar();
456
-    }
457
-
458
-
459
-    /**
460
-     * @throws EE_Error
461
-     * @throws ReflectionException
462
-     */
463
-    protected function _reset_reservations()
464
-    {
465
-        if (EED_Ticket_Sales_Monitor::reset_reservation_counts()) {
466
-            EE_Error::add_success(
467
-                esc_html__(
468
-                    'Ticket and datetime reserved counts have been successfully reset.',
469
-                    'event_espresso'
470
-                )
471
-            );
472
-        } else {
473
-            EE_Error::add_success(
474
-                esc_html__(
475
-                    'Ticket and datetime reserved counts were correct and did not need resetting.',
476
-                    'event_espresso'
477
-                )
478
-            );
479
-        }
480
-        $this->_redirect_after_action(true, '', '', ['action' => 'data_reset'], true);
481
-    }
482
-
483
-
484
-    /**
485
-     * @throws EE_Error
486
-     */
487
-    protected function _reset_capabilities()
488
-    {
489
-        $this->capabilities->init_caps(true);
490
-        EE_Error::add_success(
491
-            esc_html__(
492
-                'Default Event Espresso capabilities have been restored for all current roles.',
493
-                'event_espresso'
494
-            )
495
-        );
496
-        $this->_redirect_after_action(false, '', '', ['action' => 'data_reset'], true);
497
-    }
498
-
499
-
500
-    /**
501
-     * resets the DMSs, so we can attempt to continue migrating after a fatal error
502
-     * (only a good idea when someone has somehow tried ot fix whatever caused
503
-     * the fatal error in teh first place)
504
-     *
505
-     * @throws EE_Error
506
-     */
507
-    protected function _reattempt_migration()
508
-    {
509
-        $this->migration_manager->reattempt();
510
-        $this->_redirect_after_action(false, '', '', ['action' => 'default'], true);
511
-    }
512
-
513
-
514
-    /**
515
-     * shows the big ol' System Information page
516
-     *
517
-     * @throws EE_Error
518
-     */
519
-    public function _system_status()
520
-    {
521
-        $this->_template_path                               =
522
-            EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
523
-        $this->_template_args['system_stati']               = EEM_System_Status::instance()->get_system_stati();
524
-        $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce(
525
-            [
526
-                'action' => 'download_system_status',
527
-            ],
528
-            EE_MAINTENANCE_ADMIN_URL
529
-        );
530
-        $this->_template_args['admin_page_content']         = EEH_Template::display_template(
531
-            $this->_template_path,
532
-            $this->_template_args,
533
-            true
534
-        );
535
-        $this->display_admin_page_with_no_sidebar();
536
-    }
537
-
538
-
539
-    /**
540
-     * Downloads an HTML file of the system status that can be easily stored or emailed
541
-     */
542
-    public function _download_system_status()
543
-    {
544
-        $status_info = EEM_System_Status::instance()->get_system_stati();
545
-        header('Content-Disposition: attachment');
546
-        header("Content-Disposition: attachment; filename=system_status_" . sanitize_key(site_url()) . ".html");
547
-        $output = '<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>';
548
-        $output .= '<h1>' . sprintf(
549
-            __('System Information for %1$s', 'event_espresso'),
550
-            esc_url_raw(site_url())
551
-        ) . '</h1>';
552
-        $output .= EEH_Template::layout_array_as_table($status_info);
553
-        echo esc_html($output);
554
-        die;
555
-    }
556
-
557
-
558
-    /**
559
-     * @throws EE_Error
560
-     */
561
-    public function _send_migration_crash_report()
562
-    {
563
-        $from      = $this->_req_data['from'];
564
-        $from_name = $this->_req_data['from_name'];
565
-        $body      = $this->_req_data['body'];
566
-        try {
567
-            $success = wp_mail(
568
-                EE_SUPPORT_EMAIL,
569
-                'Migration Crash Report',
570
-                $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
571
-                [
572
-                    "from:$from_name<$from>",
573
-                ]
574
-            );
575
-        } catch (Exception $e) {
576
-            $success = false;
577
-        }
578
-        $this->_redirect_after_action(
579
-            $success,
580
-            esc_html__("Migration Crash Report", "event_espresso"),
581
-            esc_html__("sent", "event_espresso"),
582
-            ['success' => $success, 'action' => 'confirm_migration_crash_report_sent']
583
-        );
584
-    }
585
-
586
-
587
-    /**
588
-     * @throws EE_Error
589
-     */
590
-    public function _confirm_migration_crash_report_sent()
591
-    {
592
-        try {
593
-            $most_recent_migration = $this->migration_manager->get_last_ran_script(true);
594
-        } catch (EE_Error $e) {
595
-            $this->migration_manager->add_error_to_migrations_ran($e->getMessage());
596
-            // now, just so we can display the page correctly, make an error migration script stage object
597
-            // and also put the error on it. It only persists for the duration of this request
598
-            $most_recent_migration = new EE_DMS_Unknown_1_0_0();
599
-            $most_recent_migration->add_error($e->getMessage());
600
-        }
601
-        $success                                       = $this->_req_data['success'] === '1';
602
-        $this->_template_args['success']               = $success;
603
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;
604
-        $this->_template_args['reset_db_action_url']   = EE_Admin_Page::add_query_args_and_nonce(
605
-            ['action' => 'reset_db'],
606
-            EE_MAINTENANCE_ADMIN_URL
607
-        );
608
-        $this->_template_args['reset_db_page_url']     = EE_Admin_Page::add_query_args_and_nonce(
609
-            ['action' => 'data_reset'],
610
-            EE_MAINTENANCE_ADMIN_URL
611
-        );
612
-        $this->_template_args['reattempt_action_url']  = EE_Admin_Page::add_query_args_and_nonce(
613
-            ['action' => 'reattempt_migration'],
614
-            EE_MAINTENANCE_ADMIN_URL
615
-        );
616
-        $this->_template_path                          =
617
-            EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
618
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
619
-            $this->_template_path,
620
-            $this->_template_args,
621
-            true
622
-        );
623
-        $this->display_admin_page_with_sidebar();
624
-    }
625
-
626
-
627
-    /**
628
-     * Resets the entire EE4 database.
629
-     * only sets up ee4 database for a fresh install-
630
-     * doesn't actually clean out the old wp options, or cpts
631
-     * (although it does erase old ee table data)
632
-     *
633
-     * @param boolean $nuke_old_ee4_data controls whether we destroy the old ee4 data,
634
-     *                                   or just try initializing ee4 default data
635
-     * @throws EE_Error
636
-     * @throws ReflectionException
637
-     */
638
-    public function _reset_db(bool $nuke_old_ee4_data = true)
639
-    {
640
-        $this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::STATUS_OFF);
641
-        if ($nuke_old_ee4_data) {
642
-            EEH_Activation::delete_all_espresso_cpt_data();
643
-            EEH_Activation::delete_all_espresso_tables_and_data(false);
644
-            EEH_Activation::remove_cron_tasks();
645
-        }
646
-        // make sure when we reset the registry's config that it
647
-        // switches to using the new singleton
648
-        EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);
649
-        EE_System::instance()->initialize_db_if_no_migrations_required(true);
650
-        EE_System::instance()->redirect_to_about_ee();
651
-    }
652
-
653
-
654
-    /**
655
-     * Deletes ALL EE tables, Records, and Options from the database.
656
-     *
657
-     * @throws EE_Error
658
-     * @throws ReflectionException
659
-     */
660
-    public function _delete_db()
661
-    {
662
-        $this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::STATUS_OFF);
663
-        EEH_Activation::delete_all_espresso_cpt_data();
664
-        EEH_Activation::delete_all_espresso_tables_and_data();
665
-        EEH_Activation::remove_cron_tasks();
666
-        EEH_Activation::deactivate_event_espresso();
667
-        wp_safe_redirect(admin_url('plugins.php'));
668
-        exit;
669
-    }
670
-
671
-
672
-    /**
673
-     * sets up EE4 to rerun the migrations from ee3 to ee4
674
-     *
675
-     * @throws EE_Error
676
-     * @throws ReflectionException
677
-     */
678
-    public function _rerun_migration_from_ee3()
679
-    {
680
-        $this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::STATUS_OFF);
681
-        EEH_Activation::delete_all_espresso_cpt_data();
682
-        EEH_Activation::delete_all_espresso_tables_and_data(false);
683
-        // set the db state to something that will require migrations
684
-        update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');
685
-        $this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::STATUS_FULL_SITE);
686
-        $this->_redirect_after_action(
687
-            true,
688
-            esc_html__("Database", 'event_espresso'),
689
-            esc_html__("reset", 'event_espresso')
690
-        );
691
-    }
692
-
693
-
694
-    // none of the below group are currently used for Gateway Settings
695
-    protected function _add_screen_options()
696
-    {
697
-    }
698
-
699
-
700
-    protected function _add_feature_pointers()
701
-    {
702
-    }
703
-
704
-
705
-    public function admin_init()
706
-    {
707
-    }
708
-
709
-
710
-    public function admin_notices()
711
-    {
712
-    }
713
-
714
-
715
-    public function admin_footer_scripts()
716
-    {
717
-    }
718
-
719
-
720
-    public function load_scripts_styles()
721
-    {
722
-        wp_enqueue_script('ee_admin_js');
723
-        wp_enqueue_script(
724
-            'ee-maintenance',
725
-            EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.js',
726
-            ['jquery'],
727
-            EVENT_ESPRESSO_VERSION,
728
-            true
729
-        );
730
-        wp_register_style(
731
-            'espresso_maintenance',
732
-            EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css',
733
-            [],
734
-            EVENT_ESPRESSO_VERSION
735
-        );
736
-        wp_enqueue_style('espresso_maintenance');
737
-        // localize script stuff
738
-        wp_localize_script(
739
-            'ee-maintenance',
740
-            'ee_maintenance',
741
-            [
742
-                'migrating'                        => wp_strip_all_tags(__("Updating Database...", "event_espresso")),
743
-                'next'                             => wp_strip_all_tags(__("Next", "event_espresso")),
744
-                'fatal_error'                      => wp_strip_all_tags(
745
-                    __(
746
-                        "A Fatal Error Has Occurred",
747
-                        "event_espresso"
748
-                    )
749
-                ),
750
-                'click_next_when_ready'            => wp_strip_all_tags(
751
-                    __(
752
-                        "The current Database Update has ended. Click 'next' when ready to proceed",
753
-                        "event_espresso"
754
-                    )
755
-                ),
756
-                'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,
757
-                'status_fatal_error'               => EE_Data_Migration_Manager::status_fatal_error,
758
-                'status_completed'                 => EE_Data_Migration_Manager::status_completed,
759
-                'confirm'                          => wp_strip_all_tags(
760
-                    __(
761
-                        'Are you sure you want to do this? It CANNOT be undone!',
762
-                        'event_espresso'
763
-                    )
764
-                ),
765
-                'confirm_skip_migration'           => wp_strip_all_tags(
766
-                    __(
767
-                        'You have chosen to NOT migrate your existing data. Are you sure you want to continue?',
768
-                        'event_espresso'
769
-                    )
770
-                ),
771
-            ]
772
-        );
773
-    }
774
-
775
-
776
-    public function load_scripts_styles_default()
777
-    {
778
-    }
779
-
780
-
781
-    /**
782
-     * Enqueue scripts and styles for the datetime tools page.
783
-     */
784
-    public function load_scripts_styles_datetime_tools()
785
-    {
786
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
787
-    }
788
-
789
-
790
-    /**
791
-     * @throws EE_Error
792
-     */
793
-    protected function _datetime_tools()
794
-    {
795
-        $form_action                                = EE_Admin_Page::add_query_args_and_nonce(
796
-            [
797
-                'action'        => 'run_datetime_offset_fix',
798
-                'return_action' => $this->_req_action,
799
-            ],
800
-            EE_MAINTENANCE_ADMIN_URL
801
-        );
802
-        $form                                       = $this->_get_datetime_offset_fix_form();
803
-        $this->_admin_page_title                    = esc_html__('Datetime Utilities', 'event_espresso');
804
-        $this->_template_args['admin_page_content'] = $form->form_open($form_action, 'post')
805
-                                                      . $form->get_html_and_js()
806
-                                                      . $form->form_close();
807
-        $this->display_admin_page_with_sidebar();
808
-    }
809
-
810
-
811
-    /**
812
-     * @throws EE_Error
813
-     */
814
-    protected function _get_datetime_offset_fix_form(): EE_Form_Section_Proper
815
-    {
816
-        if (! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) {
817
-            $this->datetime_fix_offset_form = new EE_Form_Section_Proper(
818
-                [
819
-                    'name'            => 'datetime_offset_fix_option',
820
-                    'layout_strategy' => new EE_Admin_Two_Column_Layout(),
821
-                    'subsections'     => [
822
-                        'title'                  => new EE_Form_Section_HTML(
823
-                            EEH_HTML::h2(
824
-                                esc_html__('Datetime Offset Tool', 'event_espresso')
825
-                            )
826
-                        ),
827
-                        'explanation'            => new EE_Form_Section_HTML(
828
-                            EEH_HTML::p(
829
-                                esc_html__(
830
-                                    'Use this tool to automatically apply the provided offset to all Event Espresso records in your database that involve dates and times.',
831
-                                    'event_espresso'
832
-                                )
833
-                            )
834
-                            . EEH_HTML::p(
835
-                                esc_html__(
836
-                                    'Note: If you enter 1.25, that will result in the offset of 1 hour 15 minutes being applied.  Decimals represent the fraction of hours, not minutes.',
837
-                                    'event_espresso'
838
-                                )
839
-                            )
840
-                        ),
841
-                        'offset_input'           => new EE_Float_Input(
842
-                            [
843
-                                'html_name'       => 'offset_for_datetimes',
844
-                                'html_label_text' => esc_html__(
845
-                                    'Offset to apply (in hours):',
846
-                                    'event_espresso'
847
-                                ),
848
-                                'min_value'       => '-12',
849
-                                'max_value'       => '14',
850
-                                'step_value'      => '.25',
851
-                                'default'         => DatetimeOffsetFix::getOffset(),
852
-                            ]
853
-                        ),
854
-                        'date_range_explanation' => new EE_Form_Section_HTML(
855
-                            EEH_HTML::p(
856
-                                esc_html__(
857
-                                    'Leave the following fields blank if you want the offset to be applied to all dates. If however, you want to just apply the offset to a specific range of dates you can restrict the offset application using these fields.',
858
-                                    'event_espresso'
859
-                                )
860
-                            )
861
-                            . EEH_HTML::p(
862
-                                EEH_HTML::strong(
863
-                                    sprintf(
864
-                                        esc_html__(
865
-                                            'Note: please enter the dates in UTC (You can use %1$sthis online tool%2$s to assist with conversions).',
866
-                                            'event_espresso'
867
-                                        ),
868
-                                        '<a href="https://www.timeanddate.com/worldclock/converter.html">',
869
-                                        '</a>'
870
-                                    )
871
-                                )
872
-                            )
873
-                        ),
874
-                        'date_range_start_date'  => new EE_Datepicker_Input(
875
-                            [
876
-                                'html_name'       => 'offset_date_start_range',
877
-                                'html_label_text' => esc_html__(
878
-                                    'Start Date for dates the offset applied to:',
879
-                                    'event_espresso'
880
-                                ),
881
-                            ]
882
-                        ),
883
-                        'date_range_end_date'    => new EE_Datepicker_Input(
884
-                            [
885
-                                'html_name'       => 'offset_date_end_range',
886
-                                'html_label_text' => esc_html__(
887
-                                    'End Date for dates the offset is applied to:',
888
-                                    'event_espresso'
889
-                                ),
890
-                            ]
891
-                        ),
892
-                        'submit'                 => new EE_Submit_Input(
893
-                            [
894
-                                'html_label_text' => '',
895
-                                'default'         => esc_html__('Apply Offset', 'event_espresso'),
896
-                            ]
897
-                        ),
898
-                    ],
899
-                ]
900
-            );
901
-        }
902
-        return $this->datetime_fix_offset_form;
903
-    }
904
-
905
-
906
-    /**
907
-     * Callback for the run_datetime_offset_fix route.
908
-     *
909
-     * @throws EE_Error
910
-     * @throws Exception
911
-     */
912
-    protected function _apply_datetime_offset()
913
-    {
914
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
915
-            $form = $this->_get_datetime_offset_fix_form();
916
-            $form->receive_form_submission($this->_req_data);
917
-            if ($form->is_valid()) {
918
-                // save offset data so batch processor can get it.
919
-                DatetimeOffsetFix::updateOffset((float) $form->get_input_value('offset_input'));
920
-                $utc_timezone          = new DateTimeZone('UTC');
921
-                $date_range_start_date = DateTime::createFromFormat(
922
-                    'm/d/Y H:i:s',
923
-                    $form->get_input_value('date_range_start_date') . ' 00:00:00',
924
-                    $utc_timezone
925
-                );
926
-                $date_range_end_date   = DateTime::createFromFormat(
927
-                    'm/d/Y H:i:s',
928
-                    $form->get_input_value('date_range_end_date') . ' 23:59:59',
929
-                    $utc_timezone
930
-                );
931
-                if ($date_range_start_date instanceof DateTime) {
932
-                    DatetimeOffsetFix::updateStartDateRange(DbSafeDateTime::createFromDateTime($date_range_start_date));
933
-                }
934
-                if ($date_range_end_date instanceof DateTime) {
935
-                    DatetimeOffsetFix::updateEndDateRange(DbSafeDateTime::createFromDateTime($date_range_end_date));
936
-                }
937
-                // redirect to batch tool
938
-                wp_redirect(
939
-                    EE_Admin_Page::add_query_args_and_nonce(
940
-                        [
941
-                            'page'        => EED_Batch::PAGE_SLUG,
942
-                            'batch'       => EED_Batch::batch_job,
943
-                            'label'       => esc_html__('Applying Offset', 'event_espresso'),
944
-                            'job_handler' => urlencode('EventEspresso\core\libraries\batch\JobHandlers\DatetimeOffsetFix'),
945
-                            'return_url'  => urlencode(
946
-                                add_query_arg(
947
-                                    [
948
-                                        'action' => 'datetime_tools',
949
-                                    ],
950
-                                    EEH_URL::current_url_without_query_paramaters(
951
-                                        [
952
-                                            'return_action',
953
-                                            'run_datetime_offset_fix_nonce',
954
-                                            'return',
955
-                                            'datetime_tools_nonce',
956
-                                        ]
957
-                                    )
958
-                                )
959
-                            ),
960
-                        ],
961
-                        admin_url()
962
-                    )
963
-                );
964
-                exit;
965
-            }
966
-        }
967
-    }
18
+	protected EE_Data_Migration_Manager $migration_manager;
19
+
20
+	protected EE_Maintenance_Mode $maintenance_mode;
21
+
22
+	protected ?EE_Form_Section_Proper $datetime_fix_offset_form = null;
23
+
24
+
25
+	/**
26
+	 * @param bool $routing
27
+	 * @throws ReflectionException
28
+	 */
29
+	public function __construct($routing = true)
30
+	{
31
+		$this->migration_manager = EE_Data_Migration_Manager::instance();
32
+		$this->maintenance_mode  = EE_Maintenance_Mode::instance();
33
+		parent::__construct($routing);
34
+	}
35
+
36
+
37
+	protected function _init_page_props()
38
+	{
39
+		$this->page_slug        = EE_MAINTENANCE_PG_SLUG;
40
+		$this->page_label       = EE_MAINTENANCE_LABEL;
41
+		$this->_admin_base_url  = EE_MAINTENANCE_ADMIN_URL;
42
+		$this->_admin_base_path = EE_MAINTENANCE_ADMIN;
43
+	}
44
+
45
+
46
+	protected function _ajax_hooks()
47
+	{
48
+		if (! $this->capabilities->current_user_can('manage_options', 'perform-migrations')) {
49
+			return;
50
+		}
51
+		add_action('wp_ajax_migration_step', [$this, 'migration_step']);
52
+		add_action('wp_ajax_add_error_to_migrations_ran', [$this, 'add_error_to_migrations_ran']);
53
+	}
54
+
55
+
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = EE_MAINTENANCE_LABEL;
59
+		$this->_labels           = [
60
+			'buttons' => [
61
+				'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'),
62
+				'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'),
63
+			],
64
+		];
65
+	}
66
+
67
+
68
+	protected function _set_page_routes()
69
+	{
70
+		$this->_page_routes = [
71
+			'default'                             => [
72
+				'func'       => [$this, '_maintenance'],
73
+				'capability' => 'manage_options',
74
+			],
75
+			'change_maintenance_level'            => [
76
+				'func'       => [$this, '_change_maintenance_level'],
77
+				'capability' => 'manage_options',
78
+				'noheader'   => true,
79
+			],
80
+			'system_status'                       => [
81
+				'func'       => [$this, '_system_status'],
82
+				'capability' => 'manage_options',
83
+			],
84
+			'download_system_status'              => [
85
+				'func'       => [$this, '_download_system_status'],
86
+				'capability' => 'manage_options',
87
+				'noheader'   => true,
88
+			],
89
+			'send_migration_crash_report'         => [
90
+				'func'       => [$this, '_send_migration_crash_report'],
91
+				'capability' => 'manage_options',
92
+				'noheader'   => true,
93
+			],
94
+			'confirm_migration_crash_report_sent' => [
95
+				'func'       => [$this, '_confirm_migration_crash_report_sent'],
96
+				'capability' => 'manage_options',
97
+			],
98
+			'data_reset'                          => [
99
+				'func'       => [$this, '_data_reset_and_delete'],
100
+				'capability' => 'manage_options',
101
+			],
102
+			'reset_db'                            => [
103
+				'func'       => [$this, '_reset_db'],
104
+				'capability' => 'manage_options',
105
+				'noheader'   => true,
106
+				'args'       => ['nuke_old_ee4_data' => true],
107
+			],
108
+			'start_with_fresh_ee4_db'             => [
109
+				'func'       => [$this, '_reset_db'],
110
+				'capability' => 'manage_options',
111
+				'noheader'   => true,
112
+				'args'       => ['nuke_old_ee4_data' => false],
113
+			],
114
+			'delete_db'                           => [
115
+				'func'       => [$this, '_delete_db'],
116
+				'capability' => 'manage_options',
117
+				'noheader'   => true,
118
+			],
119
+			'rerun_migration_from_ee3'            => [
120
+				'func'       => [$this, '_rerun_migration_from_ee3'],
121
+				'capability' => 'manage_options',
122
+				'noheader'   => true,
123
+			],
124
+			'reset_reservations'                  => [
125
+				'func'       => [$this, '_reset_reservations'],
126
+				'capability' => 'manage_options',
127
+				'noheader'   => true,
128
+			],
129
+			'reset_capabilities'                  => [
130
+				'func'       => [$this, '_reset_capabilities'],
131
+				'capability' => 'manage_options',
132
+				'noheader'   => true,
133
+			],
134
+			'reattempt_migration'                 => [
135
+				'func'       => [$this, '_reattempt_migration'],
136
+				'capability' => 'manage_options',
137
+				'noheader'   => true,
138
+			],
139
+			'datetime_tools'                      => [
140
+				'func'       => [$this, '_datetime_tools'],
141
+				'capability' => 'manage_options',
142
+			],
143
+			'run_datetime_offset_fix'             => [
144
+				'func'               => [$this, '_apply_datetime_offset'],
145
+				'noheader'           => true,
146
+				'headers_sent_route' => 'datetime_tools',
147
+				'capability'         => 'manage_options',
148
+			],
149
+		];
150
+	}
151
+
152
+
153
+	protected function _set_page_config()
154
+	{
155
+		$this->_page_config = [
156
+			'default'        => [
157
+				'nav'           => [
158
+					'label' => esc_html__('Maintenance', 'event_espresso'),
159
+					'icon'  => 'dashicons-admin-tools',
160
+					'order' => 10,
161
+				],
162
+				'require_nonce' => false,
163
+			],
164
+			'data_reset'     => [
165
+				'nav'           => [
166
+					'label' => esc_html__('Reset/Delete Data', 'event_espresso'),
167
+					'icon'  => 'dashicons-trash',
168
+					'order' => 20,
169
+				],
170
+				'require_nonce' => false,
171
+			],
172
+			'datetime_tools' => [
173
+				'nav'           => [
174
+					'label' => esc_html__('Datetime Utilities', 'event_espresso'),
175
+					'icon'  => 'dashicons-calendar-alt',
176
+					'order' => 25,
177
+				],
178
+				'require_nonce' => false,
179
+			],
180
+			'system_status'  => [
181
+				'nav'           => [
182
+					'label' => esc_html__("System Information", "event_espresso"),
183
+					'icon'  => 'dashicons-info',
184
+					'order' => 30,
185
+				],
186
+				'require_nonce' => false,
187
+			],
188
+		];
189
+	}
190
+
191
+
192
+	/**
193
+	 * default maintenance page.
194
+	 * If we're in maintenance mode level 2, then we need to show the migration scripts and all that UI.
195
+	 *
196
+	 * @throws EE_Error
197
+	 */
198
+	public function _maintenance()
199
+	{
200
+		$show_maintenance_switch         = true;
201
+		$show_backup_db_text             = false;
202
+		$show_migration_progress         = false;
203
+		$script_names                    = [];
204
+		$addons_should_be_upgraded_first = false;
205
+		// it all depends on if we're in maintenance model level 1 (frontend-only) or
206
+		// level 2 (everything except maintenance page)
207
+		try {
208
+			// get the current maintenance level and check if we are removed
209
+			$was_full_site_maintenence_mode = MaintenanceStatus::isFullSite();
210
+			$no_longer_in_maintenence_mode = ! $this->maintenance_mode->set_maintenance_mode_if_db_old();
211
+			if ($was_full_site_maintenence_mode && $no_longer_in_maintenence_mode) {
212
+				// we just took the site out of maintenance mode, so notify the user.
213
+				// unfortunately this message appears to be echoed on the NEXT page load...
214
+				// oh well, we should really be checking for this on addon deactivation anyways
215
+				EE_Error::add_attention(
216
+					esc_html__(
217
+						'Site taken out of maintenance mode because no data migration scripts are required',
218
+						'event_espresso'
219
+					)
220
+				);
221
+				$this->_process_notices(['page' => 'espresso_maintenance_settings']);
222
+			}
223
+			// in case an exception is thrown while trying to handle migrations
224
+			if (MaintenanceStatus::isFullSite()) {
225
+				$show_maintenance_switch = false;
226
+				$show_migration_progress = true;
227
+				if (! isset($this->_req_data['continue_migration'])) {
228
+					$show_backup_db_text = true;
229
+				}
230
+				$scripts_needing_to_run          =
231
+					$this->migration_manager->check_for_applicable_data_migration_scripts();
232
+				$addons_should_be_upgraded_first = $this->migration_manager->addons_need_updating();
233
+				$script_names                    = [];
234
+				$current_script                  = null;
235
+				foreach ($scripts_needing_to_run as $script) {
236
+					if ($script instanceof EE_Data_Migration_Script_Base) {
237
+						if (! $current_script) {
238
+							$current_script = $script;
239
+							$current_script->migration_page_hooks();
240
+						}
241
+						$script_names[] = $script->pretty_name();
242
+					}
243
+				}
244
+			}
245
+			$most_recent_migration = $this->migration_manager->get_last_ran_script(true);
246
+			$exception_thrown      = false;
247
+		} catch (EE_Error $e) {
248
+			$this->migration_manager->add_error_to_migrations_ran($e->getMessage());
249
+			// now, just so we can display the page correctly, make an error migration script stage object
250
+			// and also put the error on it. It only persists for the duration of this request
251
+			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
252
+			$most_recent_migration->add_error($e->getMessage());
253
+			$exception_thrown = true;
254
+		}
255
+		$current_db_state = $this->migration_manager->ensure_current_database_state_is_set();
256
+		$current_db_state = str_replace('.decaf', '', $current_db_state);
257
+		if (
258
+			$exception_thrown
259
+			|| (
260
+				$most_recent_migration instanceof EE_Data_Migration_Script_Base
261
+				&& $most_recent_migration->is_broken()
262
+			)
263
+		) {
264
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
265
+
266
+			$this->_template_args['support_url'] = 'https://eventespresso.com/support/forums/';
267
+			$this->_template_args['next_url']    = EEH_URL::add_query_args_and_nonce(
268
+				[
269
+					'action'  => 'confirm_migration_crash_report_sent',
270
+					'success' => '0',
271
+				],
272
+				EE_MAINTENANCE_ADMIN_URL
273
+			);
274
+		} elseif ($addons_should_be_upgraded_first) {
275
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
276
+		} else {
277
+			if (
278
+				$most_recent_migration instanceof EE_Data_Migration_Script_Base
279
+				&& $most_recent_migration->can_continue()
280
+			) {
281
+				$show_backup_db_text                    = false;
282
+				$show_continue_current_migration_script = true;
283
+				$show_most_recent_migration             = true;
284
+			} elseif (isset($this->_req_data['continue_migration'])) {
285
+				$show_most_recent_migration             = true;
286
+				$show_continue_current_migration_script = false;
287
+			} else {
288
+				$show_most_recent_migration             = false;
289
+				$show_continue_current_migration_script = false;
290
+			}
291
+			if (isset($current_script)) {
292
+				$migrates_to          = $current_script->migrates_to_version();
293
+				$plugin_slug          = $migrates_to['slug'];
294
+				$new_version          = $migrates_to['version'];
295
+				$this->_template_args = array_merge(
296
+					$this->_template_args,
297
+					[
298
+						'current_db_state' => sprintf(
299
+							esc_html__("EE%s (%s)", "event_espresso"),
300
+							$current_db_state[ $plugin_slug ] ?? 3,
301
+							$plugin_slug
302
+						),
303
+						'next_db_state'    => sprintf(
304
+							esc_html__("EE%s (%s)", 'event_espresso'),
305
+							$new_version,
306
+							$plugin_slug
307
+						),
308
+					]
309
+				);
310
+			} else {
311
+				$this->_template_args['current_db_state'] = '';
312
+				$this->_template_args['next_db_state']    = '';
313
+			}
314
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
315
+			$this->_template_args = array_merge(
316
+				$this->_template_args,
317
+				[
318
+					'show_most_recent_migration'             => $show_most_recent_migration,
319
+					// flag for showing the most recent migration's status and/or errors
320
+					'show_migration_progress'                => $show_migration_progress,
321
+					// flag for showing the option to run migrations and see their progress
322
+					'show_backup_db_text'                    => $show_backup_db_text,
323
+					// flag for showing text telling the user to back up their DB
324
+					'show_maintenance_switch'                => $show_maintenance_switch,
325
+					// flag for showing the option to change maintenance mode between levels 0 and 1
326
+					'script_names'                           => $script_names,
327
+					// array of names of scripts that have run
328
+					'show_continue_current_migration_script' => $show_continue_current_migration_script,
329
+					// flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
330
+					'reset_db_page_link'                     => EE_Admin_Page::add_query_args_and_nonce(
331
+						['action' => 'reset_db'],
332
+						EE_MAINTENANCE_ADMIN_URL
333
+					),
334
+					'data_reset_page'                        => EE_Admin_Page::add_query_args_and_nonce(
335
+						['action' => 'data_reset'],
336
+						EE_MAINTENANCE_ADMIN_URL
337
+					),
338
+					'update_migration_script_page_link'      => EE_Admin_Page::add_query_args_and_nonce(
339
+						['action' => 'change_maintenance_level'],
340
+						EE_MAINTENANCE_ADMIN_URL
341
+					),
342
+					'ultimate_db_state'                      => sprintf(
343
+						esc_html__("EE%s", 'event_espresso'),
344
+						espresso_version()
345
+					),
346
+					'real_level'                             => $this->maintenance_mode->real_level(),
347
+				]
348
+			);
349
+		}
350
+		$this->_template_args['most_recent_migration'] =
351
+			$most_recent_migration;// the actual most recently ran migration
352
+		// now render the migration options part, and put it in a variable
353
+		$migration_options_template_file                = apply_filters(
354
+			'FHEE__ee_migration_page__migration_options_template',
355
+			EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
356
+		);
357
+		$migration_options_html                         = EEH_Template::display_template(
358
+			$migration_options_template_file,
359
+			$this->_template_args,
360
+			true
361
+		);
362
+		$this->_template_args['migration_options_html'] = $migration_options_html;
363
+		$this->_template_args['admin_page_content']     = EEH_Template::display_template(
364
+			$this->_template_path,
365
+			$this->_template_args,
366
+			true
367
+		);
368
+		$this->display_admin_page_with_sidebar();
369
+	}
370
+
371
+
372
+	/**
373
+	 * returns JSON and executes another step of the currently-executing data migration (called via ajax)
374
+	 *
375
+	 * @throws EE_Error
376
+	 */
377
+	public function migration_step()
378
+	{
379
+		if (! $this->capabilities->current_user_can('manage_options', __FUNCTION__)) {
380
+			wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso'));
381
+		}
382
+		$this->_template_args['data'] = $this->migration_manager->response_to_migration_ajax_request();
383
+		$this->_return_json();
384
+	}
385
+
386
+
387
+	/**
388
+	 * Can be used by js when it notices a response with HTML in it in order
389
+	 * to log the malformed response
390
+	 *
391
+	 * @throws EE_Error
392
+	 */
393
+	public function add_error_to_migrations_ran()
394
+	{
395
+		$this->migration_manager->add_error_to_migrations_ran($this->_req_data['message']);
396
+		$this->_template_args['data'] = ['ok' => true];
397
+		$this->_return_json();
398
+	}
399
+
400
+
401
+	/**
402
+	 * changes the maintenance level, provided there are still no migration scripts that should run
403
+	 *
404
+	 * @throws EE_Error
405
+	 */
406
+	public function _change_maintenance_level()
407
+	{
408
+		$new_level = absint($this->_req_data['maintenance_mode_level']);
409
+		if (! $this->migration_manager->check_for_applicable_data_migration_scripts()) {
410
+			$this->maintenance_mode->set_maintenance_level($new_level);
411
+			$success = true;
412
+		} else {
413
+			$this->maintenance_mode->set_maintenance_mode_if_db_old();
414
+			$success = false;
415
+		}
416
+		$this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso"));
417
+	}
418
+
419
+
420
+	/**
421
+	 * a tab with options for resetting and/or deleting EE data
422
+	 *
423
+	 * @throws EE_Error
424
+	 * @throws DomainException
425
+	 */
426
+	public function _data_reset_and_delete()
427
+	{
428
+		$this->_template_path                              =
429
+			EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
430
+		$this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button(
431
+			'reset_reservations',
432
+			'reset_reservations',
433
+			[],
434
+			'button button--caution ee-confirm'
435
+		);
436
+		$this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
437
+			'reset_capabilities',
438
+			'reset_capabilities',
439
+			[],
440
+			'button button--caution ee-confirm'
441
+		);
442
+		$this->_template_args['delete_db_url']             = EE_Admin_Page::add_query_args_and_nonce(
443
+			['action' => 'delete_db'],
444
+			EE_MAINTENANCE_ADMIN_URL
445
+		);
446
+		$this->_template_args['reset_db_url']              = EE_Admin_Page::add_query_args_and_nonce(
447
+			['action' => 'reset_db'],
448
+			EE_MAINTENANCE_ADMIN_URL
449
+		);
450
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
451
+			$this->_template_path,
452
+			$this->_template_args,
453
+			true
454
+		);
455
+		$this->display_admin_page_with_no_sidebar();
456
+	}
457
+
458
+
459
+	/**
460
+	 * @throws EE_Error
461
+	 * @throws ReflectionException
462
+	 */
463
+	protected function _reset_reservations()
464
+	{
465
+		if (EED_Ticket_Sales_Monitor::reset_reservation_counts()) {
466
+			EE_Error::add_success(
467
+				esc_html__(
468
+					'Ticket and datetime reserved counts have been successfully reset.',
469
+					'event_espresso'
470
+				)
471
+			);
472
+		} else {
473
+			EE_Error::add_success(
474
+				esc_html__(
475
+					'Ticket and datetime reserved counts were correct and did not need resetting.',
476
+					'event_espresso'
477
+				)
478
+			);
479
+		}
480
+		$this->_redirect_after_action(true, '', '', ['action' => 'data_reset'], true);
481
+	}
482
+
483
+
484
+	/**
485
+	 * @throws EE_Error
486
+	 */
487
+	protected function _reset_capabilities()
488
+	{
489
+		$this->capabilities->init_caps(true);
490
+		EE_Error::add_success(
491
+			esc_html__(
492
+				'Default Event Espresso capabilities have been restored for all current roles.',
493
+				'event_espresso'
494
+			)
495
+		);
496
+		$this->_redirect_after_action(false, '', '', ['action' => 'data_reset'], true);
497
+	}
498
+
499
+
500
+	/**
501
+	 * resets the DMSs, so we can attempt to continue migrating after a fatal error
502
+	 * (only a good idea when someone has somehow tried ot fix whatever caused
503
+	 * the fatal error in teh first place)
504
+	 *
505
+	 * @throws EE_Error
506
+	 */
507
+	protected function _reattempt_migration()
508
+	{
509
+		$this->migration_manager->reattempt();
510
+		$this->_redirect_after_action(false, '', '', ['action' => 'default'], true);
511
+	}
512
+
513
+
514
+	/**
515
+	 * shows the big ol' System Information page
516
+	 *
517
+	 * @throws EE_Error
518
+	 */
519
+	public function _system_status()
520
+	{
521
+		$this->_template_path                               =
522
+			EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
523
+		$this->_template_args['system_stati']               = EEM_System_Status::instance()->get_system_stati();
524
+		$this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce(
525
+			[
526
+				'action' => 'download_system_status',
527
+			],
528
+			EE_MAINTENANCE_ADMIN_URL
529
+		);
530
+		$this->_template_args['admin_page_content']         = EEH_Template::display_template(
531
+			$this->_template_path,
532
+			$this->_template_args,
533
+			true
534
+		);
535
+		$this->display_admin_page_with_no_sidebar();
536
+	}
537
+
538
+
539
+	/**
540
+	 * Downloads an HTML file of the system status that can be easily stored or emailed
541
+	 */
542
+	public function _download_system_status()
543
+	{
544
+		$status_info = EEM_System_Status::instance()->get_system_stati();
545
+		header('Content-Disposition: attachment');
546
+		header("Content-Disposition: attachment; filename=system_status_" . sanitize_key(site_url()) . ".html");
547
+		$output = '<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>';
548
+		$output .= '<h1>' . sprintf(
549
+			__('System Information for %1$s', 'event_espresso'),
550
+			esc_url_raw(site_url())
551
+		) . '</h1>';
552
+		$output .= EEH_Template::layout_array_as_table($status_info);
553
+		echo esc_html($output);
554
+		die;
555
+	}
556
+
557
+
558
+	/**
559
+	 * @throws EE_Error
560
+	 */
561
+	public function _send_migration_crash_report()
562
+	{
563
+		$from      = $this->_req_data['from'];
564
+		$from_name = $this->_req_data['from_name'];
565
+		$body      = $this->_req_data['body'];
566
+		try {
567
+			$success = wp_mail(
568
+				EE_SUPPORT_EMAIL,
569
+				'Migration Crash Report',
570
+				$body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
571
+				[
572
+					"from:$from_name<$from>",
573
+				]
574
+			);
575
+		} catch (Exception $e) {
576
+			$success = false;
577
+		}
578
+		$this->_redirect_after_action(
579
+			$success,
580
+			esc_html__("Migration Crash Report", "event_espresso"),
581
+			esc_html__("sent", "event_espresso"),
582
+			['success' => $success, 'action' => 'confirm_migration_crash_report_sent']
583
+		);
584
+	}
585
+
586
+
587
+	/**
588
+	 * @throws EE_Error
589
+	 */
590
+	public function _confirm_migration_crash_report_sent()
591
+	{
592
+		try {
593
+			$most_recent_migration = $this->migration_manager->get_last_ran_script(true);
594
+		} catch (EE_Error $e) {
595
+			$this->migration_manager->add_error_to_migrations_ran($e->getMessage());
596
+			// now, just so we can display the page correctly, make an error migration script stage object
597
+			// and also put the error on it. It only persists for the duration of this request
598
+			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
599
+			$most_recent_migration->add_error($e->getMessage());
600
+		}
601
+		$success                                       = $this->_req_data['success'] === '1';
602
+		$this->_template_args['success']               = $success;
603
+		$this->_template_args['most_recent_migration'] = $most_recent_migration;
604
+		$this->_template_args['reset_db_action_url']   = EE_Admin_Page::add_query_args_and_nonce(
605
+			['action' => 'reset_db'],
606
+			EE_MAINTENANCE_ADMIN_URL
607
+		);
608
+		$this->_template_args['reset_db_page_url']     = EE_Admin_Page::add_query_args_and_nonce(
609
+			['action' => 'data_reset'],
610
+			EE_MAINTENANCE_ADMIN_URL
611
+		);
612
+		$this->_template_args['reattempt_action_url']  = EE_Admin_Page::add_query_args_and_nonce(
613
+			['action' => 'reattempt_migration'],
614
+			EE_MAINTENANCE_ADMIN_URL
615
+		);
616
+		$this->_template_path                          =
617
+			EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
618
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
619
+			$this->_template_path,
620
+			$this->_template_args,
621
+			true
622
+		);
623
+		$this->display_admin_page_with_sidebar();
624
+	}
625
+
626
+
627
+	/**
628
+	 * Resets the entire EE4 database.
629
+	 * only sets up ee4 database for a fresh install-
630
+	 * doesn't actually clean out the old wp options, or cpts
631
+	 * (although it does erase old ee table data)
632
+	 *
633
+	 * @param boolean $nuke_old_ee4_data controls whether we destroy the old ee4 data,
634
+	 *                                   or just try initializing ee4 default data
635
+	 * @throws EE_Error
636
+	 * @throws ReflectionException
637
+	 */
638
+	public function _reset_db(bool $nuke_old_ee4_data = true)
639
+	{
640
+		$this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::STATUS_OFF);
641
+		if ($nuke_old_ee4_data) {
642
+			EEH_Activation::delete_all_espresso_cpt_data();
643
+			EEH_Activation::delete_all_espresso_tables_and_data(false);
644
+			EEH_Activation::remove_cron_tasks();
645
+		}
646
+		// make sure when we reset the registry's config that it
647
+		// switches to using the new singleton
648
+		EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);
649
+		EE_System::instance()->initialize_db_if_no_migrations_required(true);
650
+		EE_System::instance()->redirect_to_about_ee();
651
+	}
652
+
653
+
654
+	/**
655
+	 * Deletes ALL EE tables, Records, and Options from the database.
656
+	 *
657
+	 * @throws EE_Error
658
+	 * @throws ReflectionException
659
+	 */
660
+	public function _delete_db()
661
+	{
662
+		$this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::STATUS_OFF);
663
+		EEH_Activation::delete_all_espresso_cpt_data();
664
+		EEH_Activation::delete_all_espresso_tables_and_data();
665
+		EEH_Activation::remove_cron_tasks();
666
+		EEH_Activation::deactivate_event_espresso();
667
+		wp_safe_redirect(admin_url('plugins.php'));
668
+		exit;
669
+	}
670
+
671
+
672
+	/**
673
+	 * sets up EE4 to rerun the migrations from ee3 to ee4
674
+	 *
675
+	 * @throws EE_Error
676
+	 * @throws ReflectionException
677
+	 */
678
+	public function _rerun_migration_from_ee3()
679
+	{
680
+		$this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::STATUS_OFF);
681
+		EEH_Activation::delete_all_espresso_cpt_data();
682
+		EEH_Activation::delete_all_espresso_tables_and_data(false);
683
+		// set the db state to something that will require migrations
684
+		update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');
685
+		$this->maintenance_mode->set_maintenance_level(EE_Maintenance_Mode::STATUS_FULL_SITE);
686
+		$this->_redirect_after_action(
687
+			true,
688
+			esc_html__("Database", 'event_espresso'),
689
+			esc_html__("reset", 'event_espresso')
690
+		);
691
+	}
692
+
693
+
694
+	// none of the below group are currently used for Gateway Settings
695
+	protected function _add_screen_options()
696
+	{
697
+	}
698
+
699
+
700
+	protected function _add_feature_pointers()
701
+	{
702
+	}
703
+
704
+
705
+	public function admin_init()
706
+	{
707
+	}
708
+
709
+
710
+	public function admin_notices()
711
+	{
712
+	}
713
+
714
+
715
+	public function admin_footer_scripts()
716
+	{
717
+	}
718
+
719
+
720
+	public function load_scripts_styles()
721
+	{
722
+		wp_enqueue_script('ee_admin_js');
723
+		wp_enqueue_script(
724
+			'ee-maintenance',
725
+			EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.js',
726
+			['jquery'],
727
+			EVENT_ESPRESSO_VERSION,
728
+			true
729
+		);
730
+		wp_register_style(
731
+			'espresso_maintenance',
732
+			EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css',
733
+			[],
734
+			EVENT_ESPRESSO_VERSION
735
+		);
736
+		wp_enqueue_style('espresso_maintenance');
737
+		// localize script stuff
738
+		wp_localize_script(
739
+			'ee-maintenance',
740
+			'ee_maintenance',
741
+			[
742
+				'migrating'                        => wp_strip_all_tags(__("Updating Database...", "event_espresso")),
743
+				'next'                             => wp_strip_all_tags(__("Next", "event_espresso")),
744
+				'fatal_error'                      => wp_strip_all_tags(
745
+					__(
746
+						"A Fatal Error Has Occurred",
747
+						"event_espresso"
748
+					)
749
+				),
750
+				'click_next_when_ready'            => wp_strip_all_tags(
751
+					__(
752
+						"The current Database Update has ended. Click 'next' when ready to proceed",
753
+						"event_espresso"
754
+					)
755
+				),
756
+				'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,
757
+				'status_fatal_error'               => EE_Data_Migration_Manager::status_fatal_error,
758
+				'status_completed'                 => EE_Data_Migration_Manager::status_completed,
759
+				'confirm'                          => wp_strip_all_tags(
760
+					__(
761
+						'Are you sure you want to do this? It CANNOT be undone!',
762
+						'event_espresso'
763
+					)
764
+				),
765
+				'confirm_skip_migration'           => wp_strip_all_tags(
766
+					__(
767
+						'You have chosen to NOT migrate your existing data. Are you sure you want to continue?',
768
+						'event_espresso'
769
+					)
770
+				),
771
+			]
772
+		);
773
+	}
774
+
775
+
776
+	public function load_scripts_styles_default()
777
+	{
778
+	}
779
+
780
+
781
+	/**
782
+	 * Enqueue scripts and styles for the datetime tools page.
783
+	 */
784
+	public function load_scripts_styles_datetime_tools()
785
+	{
786
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
787
+	}
788
+
789
+
790
+	/**
791
+	 * @throws EE_Error
792
+	 */
793
+	protected function _datetime_tools()
794
+	{
795
+		$form_action                                = EE_Admin_Page::add_query_args_and_nonce(
796
+			[
797
+				'action'        => 'run_datetime_offset_fix',
798
+				'return_action' => $this->_req_action,
799
+			],
800
+			EE_MAINTENANCE_ADMIN_URL
801
+		);
802
+		$form                                       = $this->_get_datetime_offset_fix_form();
803
+		$this->_admin_page_title                    = esc_html__('Datetime Utilities', 'event_espresso');
804
+		$this->_template_args['admin_page_content'] = $form->form_open($form_action, 'post')
805
+													  . $form->get_html_and_js()
806
+													  . $form->form_close();
807
+		$this->display_admin_page_with_sidebar();
808
+	}
809
+
810
+
811
+	/**
812
+	 * @throws EE_Error
813
+	 */
814
+	protected function _get_datetime_offset_fix_form(): EE_Form_Section_Proper
815
+	{
816
+		if (! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) {
817
+			$this->datetime_fix_offset_form = new EE_Form_Section_Proper(
818
+				[
819
+					'name'            => 'datetime_offset_fix_option',
820
+					'layout_strategy' => new EE_Admin_Two_Column_Layout(),
821
+					'subsections'     => [
822
+						'title'                  => new EE_Form_Section_HTML(
823
+							EEH_HTML::h2(
824
+								esc_html__('Datetime Offset Tool', 'event_espresso')
825
+							)
826
+						),
827
+						'explanation'            => new EE_Form_Section_HTML(
828
+							EEH_HTML::p(
829
+								esc_html__(
830
+									'Use this tool to automatically apply the provided offset to all Event Espresso records in your database that involve dates and times.',
831
+									'event_espresso'
832
+								)
833
+							)
834
+							. EEH_HTML::p(
835
+								esc_html__(
836
+									'Note: If you enter 1.25, that will result in the offset of 1 hour 15 minutes being applied.  Decimals represent the fraction of hours, not minutes.',
837
+									'event_espresso'
838
+								)
839
+							)
840
+						),
841
+						'offset_input'           => new EE_Float_Input(
842
+							[
843
+								'html_name'       => 'offset_for_datetimes',
844
+								'html_label_text' => esc_html__(
845
+									'Offset to apply (in hours):',
846
+									'event_espresso'
847
+								),
848
+								'min_value'       => '-12',
849
+								'max_value'       => '14',
850
+								'step_value'      => '.25',
851
+								'default'         => DatetimeOffsetFix::getOffset(),
852
+							]
853
+						),
854
+						'date_range_explanation' => new EE_Form_Section_HTML(
855
+							EEH_HTML::p(
856
+								esc_html__(
857
+									'Leave the following fields blank if you want the offset to be applied to all dates. If however, you want to just apply the offset to a specific range of dates you can restrict the offset application using these fields.',
858
+									'event_espresso'
859
+								)
860
+							)
861
+							. EEH_HTML::p(
862
+								EEH_HTML::strong(
863
+									sprintf(
864
+										esc_html__(
865
+											'Note: please enter the dates in UTC (You can use %1$sthis online tool%2$s to assist with conversions).',
866
+											'event_espresso'
867
+										),
868
+										'<a href="https://www.timeanddate.com/worldclock/converter.html">',
869
+										'</a>'
870
+									)
871
+								)
872
+							)
873
+						),
874
+						'date_range_start_date'  => new EE_Datepicker_Input(
875
+							[
876
+								'html_name'       => 'offset_date_start_range',
877
+								'html_label_text' => esc_html__(
878
+									'Start Date for dates the offset applied to:',
879
+									'event_espresso'
880
+								),
881
+							]
882
+						),
883
+						'date_range_end_date'    => new EE_Datepicker_Input(
884
+							[
885
+								'html_name'       => 'offset_date_end_range',
886
+								'html_label_text' => esc_html__(
887
+									'End Date for dates the offset is applied to:',
888
+									'event_espresso'
889
+								),
890
+							]
891
+						),
892
+						'submit'                 => new EE_Submit_Input(
893
+							[
894
+								'html_label_text' => '',
895
+								'default'         => esc_html__('Apply Offset', 'event_espresso'),
896
+							]
897
+						),
898
+					],
899
+				]
900
+			);
901
+		}
902
+		return $this->datetime_fix_offset_form;
903
+	}
904
+
905
+
906
+	/**
907
+	 * Callback for the run_datetime_offset_fix route.
908
+	 *
909
+	 * @throws EE_Error
910
+	 * @throws Exception
911
+	 */
912
+	protected function _apply_datetime_offset()
913
+	{
914
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
915
+			$form = $this->_get_datetime_offset_fix_form();
916
+			$form->receive_form_submission($this->_req_data);
917
+			if ($form->is_valid()) {
918
+				// save offset data so batch processor can get it.
919
+				DatetimeOffsetFix::updateOffset((float) $form->get_input_value('offset_input'));
920
+				$utc_timezone          = new DateTimeZone('UTC');
921
+				$date_range_start_date = DateTime::createFromFormat(
922
+					'm/d/Y H:i:s',
923
+					$form->get_input_value('date_range_start_date') . ' 00:00:00',
924
+					$utc_timezone
925
+				);
926
+				$date_range_end_date   = DateTime::createFromFormat(
927
+					'm/d/Y H:i:s',
928
+					$form->get_input_value('date_range_end_date') . ' 23:59:59',
929
+					$utc_timezone
930
+				);
931
+				if ($date_range_start_date instanceof DateTime) {
932
+					DatetimeOffsetFix::updateStartDateRange(DbSafeDateTime::createFromDateTime($date_range_start_date));
933
+				}
934
+				if ($date_range_end_date instanceof DateTime) {
935
+					DatetimeOffsetFix::updateEndDateRange(DbSafeDateTime::createFromDateTime($date_range_end_date));
936
+				}
937
+				// redirect to batch tool
938
+				wp_redirect(
939
+					EE_Admin_Page::add_query_args_and_nonce(
940
+						[
941
+							'page'        => EED_Batch::PAGE_SLUG,
942
+							'batch'       => EED_Batch::batch_job,
943
+							'label'       => esc_html__('Applying Offset', 'event_espresso'),
944
+							'job_handler' => urlencode('EventEspresso\core\libraries\batch\JobHandlers\DatetimeOffsetFix'),
945
+							'return_url'  => urlencode(
946
+								add_query_arg(
947
+									[
948
+										'action' => 'datetime_tools',
949
+									],
950
+									EEH_URL::current_url_without_query_paramaters(
951
+										[
952
+											'return_action',
953
+											'run_datetime_offset_fix_nonce',
954
+											'return',
955
+											'datetime_tools_nonce',
956
+										]
957
+									)
958
+								)
959
+							),
960
+						],
961
+						admin_url()
962
+					)
963
+				);
964
+				exit;
965
+			}
966
+		}
967
+	}
968 968
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
     protected function _ajax_hooks()
47 47
     {
48
-        if (! $this->capabilities->current_user_can('manage_options', 'perform-migrations')) {
48
+        if ( ! $this->capabilities->current_user_can('manage_options', 'perform-migrations')) {
49 49
             return;
50 50
         }
51 51
         add_action('wp_ajax_migration_step', [$this, 'migration_step']);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             if (MaintenanceStatus::isFullSite()) {
225 225
                 $show_maintenance_switch = false;
226 226
                 $show_migration_progress = true;
227
-                if (! isset($this->_req_data['continue_migration'])) {
227
+                if ( ! isset($this->_req_data['continue_migration'])) {
228 228
                     $show_backup_db_text = true;
229 229
                 }
230 230
                 $scripts_needing_to_run          =
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
                 $current_script                  = null;
235 235
                 foreach ($scripts_needing_to_run as $script) {
236 236
                     if ($script instanceof EE_Data_Migration_Script_Base) {
237
-                        if (! $current_script) {
237
+                        if ( ! $current_script) {
238 238
                             $current_script = $script;
239 239
                             $current_script->migration_page_hooks();
240 240
                         }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                 && $most_recent_migration->is_broken()
262 262
             )
263 263
         ) {
264
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
264
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_was_borked_page.template.php';
265 265
 
266 266
             $this->_template_args['support_url'] = 'https://eventespresso.com/support/forums/';
267 267
             $this->_template_args['next_url']    = EEH_URL::add_query_args_and_nonce(
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
                 EE_MAINTENANCE_ADMIN_URL
273 273
             );
274 274
         } elseif ($addons_should_be_upgraded_first) {
275
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
275
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_upgrade_addons_before_migrating.template.php';
276 276
         } else {
277 277
             if (
278 278
                 $most_recent_migration instanceof EE_Data_Migration_Script_Base
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                     [
298 298
                         'current_db_state' => sprintf(
299 299
                             esc_html__("EE%s (%s)", "event_espresso"),
300
-                            $current_db_state[ $plugin_slug ] ?? 3,
300
+                            $current_db_state[$plugin_slug] ?? 3,
301 301
                             $plugin_slug
302 302
                         ),
303 303
                         'next_db_state'    => sprintf(
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
                 $this->_template_args['current_db_state'] = '';
312 312
                 $this->_template_args['next_db_state']    = '';
313 313
             }
314
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
314
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_page.template.php';
315 315
             $this->_template_args = array_merge(
316 316
                 $this->_template_args,
317 317
                 [
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
             );
349 349
         }
350 350
         $this->_template_args['most_recent_migration'] =
351
-            $most_recent_migration;// the actual most recently ran migration
351
+            $most_recent_migration; // the actual most recently ran migration
352 352
         // now render the migration options part, and put it in a variable
353
-        $migration_options_template_file                = apply_filters(
353
+        $migration_options_template_file = apply_filters(
354 354
             'FHEE__ee_migration_page__migration_options_template',
355
-            EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'
355
+            EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee4.template.php'
356 356
         );
357
-        $migration_options_html                         = EEH_Template::display_template(
357
+        $migration_options_html = EEH_Template::display_template(
358 358
             $migration_options_template_file,
359 359
             $this->_template_args,
360 360
             true
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
      */
377 377
     public function migration_step()
378 378
     {
379
-        if (! $this->capabilities->current_user_can('manage_options', __FUNCTION__)) {
379
+        if ( ! $this->capabilities->current_user_can('manage_options', __FUNCTION__)) {
380 380
             wp_die(esc_html__('You do not have the required privileges to perform this action', 'event_espresso'));
381 381
         }
382 382
         $this->_template_args['data'] = $this->migration_manager->response_to_migration_ajax_request();
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
     public function _change_maintenance_level()
407 407
     {
408 408
         $new_level = absint($this->_req_data['maintenance_mode_level']);
409
-        if (! $this->migration_manager->check_for_applicable_data_migration_scripts()) {
409
+        if ( ! $this->migration_manager->check_for_applicable_data_migration_scripts()) {
410 410
             $this->maintenance_mode->set_maintenance_level($new_level);
411 411
             $success = true;
412 412
         } else {
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
     public function _data_reset_and_delete()
427 427
     {
428 428
         $this->_template_path                              =
429
-            EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
429
+            EE_MAINTENANCE_TEMPLATE_PATH.'ee_data_reset_and_delete.template.php';
430 430
         $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button(
431 431
             'reset_reservations',
432 432
             'reset_reservations',
@@ -439,15 +439,15 @@  discard block
 block discarded – undo
439 439
             [],
440 440
             'button button--caution ee-confirm'
441 441
         );
442
-        $this->_template_args['delete_db_url']             = EE_Admin_Page::add_query_args_and_nonce(
442
+        $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
443 443
             ['action' => 'delete_db'],
444 444
             EE_MAINTENANCE_ADMIN_URL
445 445
         );
446
-        $this->_template_args['reset_db_url']              = EE_Admin_Page::add_query_args_and_nonce(
446
+        $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
447 447
             ['action' => 'reset_db'],
448 448
             EE_MAINTENANCE_ADMIN_URL
449 449
         );
450
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
450
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
451 451
             $this->_template_path,
452 452
             $this->_template_args,
453 453
             true
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
     public function _system_status()
520 520
     {
521 521
         $this->_template_path                               =
522
-            EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
522
+            EE_MAINTENANCE_TEMPLATE_PATH.'ee_system_stati_page.template.php';
523 523
         $this->_template_args['system_stati']               = EEM_System_Status::instance()->get_system_stati();
524 524
         $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce(
525 525
             [
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
             ],
528 528
             EE_MAINTENANCE_ADMIN_URL
529 529
         );
530
-        $this->_template_args['admin_page_content']         = EEH_Template::display_template(
530
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
531 531
             $this->_template_path,
532 532
             $this->_template_args,
533 533
             true
@@ -543,12 +543,12 @@  discard block
 block discarded – undo
543 543
     {
544 544
         $status_info = EEM_System_Status::instance()->get_system_stati();
545 545
         header('Content-Disposition: attachment');
546
-        header("Content-Disposition: attachment; filename=system_status_" . sanitize_key(site_url()) . ".html");
546
+        header("Content-Disposition: attachment; filename=system_status_".sanitize_key(site_url()).".html");
547 547
         $output = '<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>';
548
-        $output .= '<h1>' . sprintf(
548
+        $output .= '<h1>'.sprintf(
549 549
             __('System Information for %1$s', 'event_espresso'),
550 550
             esc_url_raw(site_url())
551
-        ) . '</h1>';
551
+        ).'</h1>';
552 552
         $output .= EEH_Template::layout_array_as_table($status_info);
553 553
         echo esc_html($output);
554 554
         die;
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
             $success = wp_mail(
568 568
                 EE_SUPPORT_EMAIL,
569 569
                 'Migration Crash Report',
570
-                $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
570
+                $body."/r/n<br>".print_r(EEM_System_Status::instance()->get_system_stati(), true),
571 571
                 [
572 572
                     "from:$from_name<$from>",
573 573
                 ]
@@ -605,16 +605,16 @@  discard block
 block discarded – undo
605 605
             ['action' => 'reset_db'],
606 606
             EE_MAINTENANCE_ADMIN_URL
607 607
         );
608
-        $this->_template_args['reset_db_page_url']     = EE_Admin_Page::add_query_args_and_nonce(
608
+        $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(
609 609
             ['action' => 'data_reset'],
610 610
             EE_MAINTENANCE_ADMIN_URL
611 611
         );
612
-        $this->_template_args['reattempt_action_url']  = EE_Admin_Page::add_query_args_and_nonce(
612
+        $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(
613 613
             ['action' => 'reattempt_migration'],
614 614
             EE_MAINTENANCE_ADMIN_URL
615 615
         );
616 616
         $this->_template_path                          =
617
-            EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
617
+            EE_MAINTENANCE_TEMPLATE_PATH.'ee_confirm_migration_crash_report_sent.template.php';
618 618
         $this->_template_args['admin_page_content']    = EEH_Template::display_template(
619 619
             $this->_template_path,
620 620
             $this->_template_args,
@@ -722,14 +722,14 @@  discard block
 block discarded – undo
722 722
         wp_enqueue_script('ee_admin_js');
723 723
         wp_enqueue_script(
724 724
             'ee-maintenance',
725
-            EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.js',
725
+            EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.js',
726 726
             ['jquery'],
727 727
             EVENT_ESPRESSO_VERSION,
728 728
             true
729 729
         );
730 730
         wp_register_style(
731 731
             'espresso_maintenance',
732
-            EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css',
732
+            EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.css',
733 733
             [],
734 734
             EVENT_ESPRESSO_VERSION
735 735
         );
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
      */
793 793
     protected function _datetime_tools()
794 794
     {
795
-        $form_action                                = EE_Admin_Page::add_query_args_and_nonce(
795
+        $form_action = EE_Admin_Page::add_query_args_and_nonce(
796 796
             [
797 797
                 'action'        => 'run_datetime_offset_fix',
798 798
                 'return_action' => $this->_req_action,
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
      */
814 814
     protected function _get_datetime_offset_fix_form(): EE_Form_Section_Proper
815 815
     {
816
-        if (! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) {
816
+        if ( ! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) {
817 817
             $this->datetime_fix_offset_form = new EE_Form_Section_Proper(
818 818
                 [
819 819
                     'name'            => 'datetime_offset_fix_option',
@@ -920,12 +920,12 @@  discard block
 block discarded – undo
920 920
                 $utc_timezone          = new DateTimeZone('UTC');
921 921
                 $date_range_start_date = DateTime::createFromFormat(
922 922
                     'm/d/Y H:i:s',
923
-                    $form->get_input_value('date_range_start_date') . ' 00:00:00',
923
+                    $form->get_input_value('date_range_start_date').' 00:00:00',
924 924
                     $utc_timezone
925 925
                 );
926
-                $date_range_end_date   = DateTime::createFromFormat(
926
+                $date_range_end_date = DateTime::createFromFormat(
927 927
                     'm/d/Y H:i:s',
928
-                    $form->get_input_value('date_range_end_date') . ' 23:59:59',
928
+                    $form->get_input_value('date_range_end_date').' 23:59:59',
929 929
                     $utc_timezone
930 930
                 );
931 931
                 if ($date_range_start_date instanceof DateTime) {
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page_Init.core.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -18,148 +18,148 @@
 block discarded – undo
18 18
  */
19 19
 class Payments_Admin_Page_Init extends EE_Admin_Page_Init
20 20
 {
21
-    /**
22
-     * @var TableAnalysis $table_analysis
23
-     */
24
-    protected $_table_analysis;
25
-
26
-
27
-    /**
28
-     * @throws EE_Error
29
-     * @throws ReflectionException
30
-     */
31
-    public function __construct()
32
-    {
33
-        // define some page related constants
34
-        if (! defined('EE_PAYMENTS_PG_SLUG')) {
35
-            define('EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings');
36
-            define('EE_PAYMENTS_ADMIN_URL', admin_url('admin.php?page=' . EE_PAYMENTS_PG_SLUG));
37
-            define('EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES . 'payments/');
38
-            define('EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN . 'templates/');
39
-            define('EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'payments/assets/');
40
-        }
41
-        $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', [], true);
42
-        // check that there are active gateways on all admin page loads. but don't do it just yet
43
-        add_action('admin_notices', [$this, 'check_payment_gateway_setup']);
44
-
45
-        // Show/hide PP Standard alongside PP Express.
46
-        add_filter(
47
-            'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
48
-            [$this, 'unset_pp_standard']
49
-        );
50
-
51
-        parent::__construct();
52
-    }
53
-
54
-
55
-    protected function _set_init_properties()
56
-    {
57
-        $this->label = esc_html__('Payment Methods', 'event_espresso');
58
-    }
59
-
60
-
61
-    public function getMenuProperties(): array
62
-    {
63
-        return [
64
-            'menu_type'    => AdminMenuItem::TYPE_MENU_SUB_ITEM,
65
-            'menu_group'   => AdminMenuGroup::MENU_SLUG_SETTINGS,
66
-            'menu_order'   => 30,
67
-            'show_on_menu' => AdminMenuItem::DISPLAY_BLOG_ONLY,
68
-            'parent_slug'  => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
69
-            'menu_slug'    => EE_PAYMENTS_PG_SLUG,
70
-            'menu_label'   => esc_html__('Payment Methods', 'event_espresso'),
71
-            'capability'   => 'ee_manage_gateways',
72
-        ];
73
-    }
74
-
75
-
76
-    /**
77
-     * Checks that there is at least one active gateway. If not, add a notice
78
-     *
79
-     * @throws EE_Error
80
-     * @throws ReflectionException
81
-     */
82
-    public function check_payment_gateway_setup()
83
-    {
84
-        // ONLY do this check if models can query
85
-        // and avoid a bug where when we nuke EE4's data that this causes a fatal error
86
-        // because the tables are deleted just before this request runs.
87
-        // see https://events.codebasehq.com/projects/event-espresso/tickets/7539
88
-        if (
89
-            DbStatus::isOffline()
90
-            || ! $this->_get_table_analysis()->tableExists(EEM_Payment_Method::instance()->table())
91
-        ) {
92
-            return;
93
-        }
94
-
95
-        $actives = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart);
96
-        if ($actives < 1) {
97
-            $url = EE_Admin_Page::add_query_args_and_nonce([], EE_PAYMENTS_ADMIN_URL);
98
-            echo '<div class="error">
21
+	/**
22
+	 * @var TableAnalysis $table_analysis
23
+	 */
24
+	protected $_table_analysis;
25
+
26
+
27
+	/**
28
+	 * @throws EE_Error
29
+	 * @throws ReflectionException
30
+	 */
31
+	public function __construct()
32
+	{
33
+		// define some page related constants
34
+		if (! defined('EE_PAYMENTS_PG_SLUG')) {
35
+			define('EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings');
36
+			define('EE_PAYMENTS_ADMIN_URL', admin_url('admin.php?page=' . EE_PAYMENTS_PG_SLUG));
37
+			define('EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES . 'payments/');
38
+			define('EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN . 'templates/');
39
+			define('EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'payments/assets/');
40
+		}
41
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', [], true);
42
+		// check that there are active gateways on all admin page loads. but don't do it just yet
43
+		add_action('admin_notices', [$this, 'check_payment_gateway_setup']);
44
+
45
+		// Show/hide PP Standard alongside PP Express.
46
+		add_filter(
47
+			'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
48
+			[$this, 'unset_pp_standard']
49
+		);
50
+
51
+		parent::__construct();
52
+	}
53
+
54
+
55
+	protected function _set_init_properties()
56
+	{
57
+		$this->label = esc_html__('Payment Methods', 'event_espresso');
58
+	}
59
+
60
+
61
+	public function getMenuProperties(): array
62
+	{
63
+		return [
64
+			'menu_type'    => AdminMenuItem::TYPE_MENU_SUB_ITEM,
65
+			'menu_group'   => AdminMenuGroup::MENU_SLUG_SETTINGS,
66
+			'menu_order'   => 30,
67
+			'show_on_menu' => AdminMenuItem::DISPLAY_BLOG_ONLY,
68
+			'parent_slug'  => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
69
+			'menu_slug'    => EE_PAYMENTS_PG_SLUG,
70
+			'menu_label'   => esc_html__('Payment Methods', 'event_espresso'),
71
+			'capability'   => 'ee_manage_gateways',
72
+		];
73
+	}
74
+
75
+
76
+	/**
77
+	 * Checks that there is at least one active gateway. If not, add a notice
78
+	 *
79
+	 * @throws EE_Error
80
+	 * @throws ReflectionException
81
+	 */
82
+	public function check_payment_gateway_setup()
83
+	{
84
+		// ONLY do this check if models can query
85
+		// and avoid a bug where when we nuke EE4's data that this causes a fatal error
86
+		// because the tables are deleted just before this request runs.
87
+		// see https://events.codebasehq.com/projects/event-espresso/tickets/7539
88
+		if (
89
+			DbStatus::isOffline()
90
+			|| ! $this->_get_table_analysis()->tableExists(EEM_Payment_Method::instance()->table())
91
+		) {
92
+			return;
93
+		}
94
+
95
+		$actives = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart);
96
+		if ($actives < 1) {
97
+			$url = EE_Admin_Page::add_query_args_and_nonce([], EE_PAYMENTS_ADMIN_URL);
98
+			echo '<div class="error">
99 99
 				 <p>'
100
-                 . sprintf(
101
-                     esc_html__(
102
-                         "There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s",
103
-                         "event_espresso"
104
-                     ),
105
-                     "<a href='$url'>",
106
-                     "</a>"
107
-                 )
108
-                 . '</p>
100
+				 . sprintf(
101
+					 esc_html__(
102
+						 "There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s",
103
+						 "event_espresso"
104
+					 ),
105
+					 "<a href='$url'>",
106
+					 "</a>"
107
+				 )
108
+				 . '</p>
109 109
 			 </div>';
110
-        }
111
-    }
112
-
113
-
114
-    /**
115
-     * Gets the injected table analyzer, or throws an exception
116
-     *
117
-     * @return TableAnalysis
118
-     * @throws EE_Error
119
-     */
120
-    protected function _get_table_analysis()
121
-    {
122
-        if ($this->_table_analysis instanceof TableAnalysis) {
123
-            return $this->_table_analysis;
124
-        } else {
125
-            throw new EE_Error(
126
-                sprintf(
127
-                    esc_html__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
128
-                    get_class($this)
129
-                )
130
-            );
131
-        }
132
-    }
133
-
134
-
135
-    /**
136
-     * Hide PayPal Standard for "new" users.
137
-     *
138
-     * @throws EE_Error
139
-     * @throws ReflectionException
140
-     */
141
-    public static function unset_pp_standard($payment_method_types)
142
-    {
143
-        $pps                           = EEM_Payment_Method::instance()->get_one_of_type('Paypal_Standard');
144
-        $paypal_standard_active        = ! empty($pps) && $pps->active();
145
-        $paypal_standard_active_before = false;
146
-        if ($pps) {
147
-            // PP Standard used before ?
148
-            $paypal_id = $pps->get_extra_meta('paypal_id', true);
149
-            if ($paypal_id && ! empty($paypal_id)) {
150
-                $paypal_standard_active_before = true;
151
-            }
152
-        }
153
-
154
-        // Not using PP Standard? Then display only PayPal Express, do not show PayPal Standard.
155
-        if (
156
-            apply_filters(
157
-                'FHEE__EE_PMT_Paypal_Express__register_payment_methods__hide_paypal_standard',
158
-                ! $paypal_standard_active && ! $paypal_standard_active_before
159
-            )
160
-        ) {
161
-            unset($payment_method_types['paypal_standard']);
162
-        }
163
-        return $payment_method_types;
164
-    }
110
+		}
111
+	}
112
+
113
+
114
+	/**
115
+	 * Gets the injected table analyzer, or throws an exception
116
+	 *
117
+	 * @return TableAnalysis
118
+	 * @throws EE_Error
119
+	 */
120
+	protected function _get_table_analysis()
121
+	{
122
+		if ($this->_table_analysis instanceof TableAnalysis) {
123
+			return $this->_table_analysis;
124
+		} else {
125
+			throw new EE_Error(
126
+				sprintf(
127
+					esc_html__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
128
+					get_class($this)
129
+				)
130
+			);
131
+		}
132
+	}
133
+
134
+
135
+	/**
136
+	 * Hide PayPal Standard for "new" users.
137
+	 *
138
+	 * @throws EE_Error
139
+	 * @throws ReflectionException
140
+	 */
141
+	public static function unset_pp_standard($payment_method_types)
142
+	{
143
+		$pps                           = EEM_Payment_Method::instance()->get_one_of_type('Paypal_Standard');
144
+		$paypal_standard_active        = ! empty($pps) && $pps->active();
145
+		$paypal_standard_active_before = false;
146
+		if ($pps) {
147
+			// PP Standard used before ?
148
+			$paypal_id = $pps->get_extra_meta('paypal_id', true);
149
+			if ($paypal_id && ! empty($paypal_id)) {
150
+				$paypal_standard_active_before = true;
151
+			}
152
+		}
153
+
154
+		// Not using PP Standard? Then display only PayPal Express, do not show PayPal Standard.
155
+		if (
156
+			apply_filters(
157
+				'FHEE__EE_PMT_Paypal_Express__register_payment_methods__hide_paypal_standard',
158
+				! $paypal_standard_active && ! $paypal_standard_active_before
159
+			)
160
+		) {
161
+			unset($payment_method_types['paypal_standard']);
162
+		}
163
+		return $payment_method_types;
164
+	}
165 165
 }
Please login to merge, or discard this patch.
admin_pages/support/Support_Admin_Page_Init.core.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -16,38 +16,38 @@
 block discarded – undo
16 16
  */
17 17
 class Support_Admin_Page_Init extends EE_Admin_Page_Init
18 18
 {
19
-    public function __construct()
20
-    {
21
-        // define some help/support page related constants
22
-        if (! defined('EE_SUPPORT_PG_SLUG')) {
23
-            define('EE_SUPPORT_PG_SLUG', 'espresso_support');
24
-            define('EE_SUPPORT_ADMIN_URL', admin_url('admin.php?page=' . EE_SUPPORT_PG_SLUG));
25
-            define('EE_SUPPORT_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES . 'support/templates/');
26
-            define('EE_SUPPORT_ADMIN', EE_ADMIN_PAGES . 'support/');
27
-            define('EE_SUPPORT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'support/assets/');
28
-        }
29
-        parent::__construct();
30
-    }
19
+	public function __construct()
20
+	{
21
+		// define some help/support page related constants
22
+		if (! defined('EE_SUPPORT_PG_SLUG')) {
23
+			define('EE_SUPPORT_PG_SLUG', 'espresso_support');
24
+			define('EE_SUPPORT_ADMIN_URL', admin_url('admin.php?page=' . EE_SUPPORT_PG_SLUG));
25
+			define('EE_SUPPORT_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES . 'support/templates/');
26
+			define('EE_SUPPORT_ADMIN', EE_ADMIN_PAGES . 'support/');
27
+			define('EE_SUPPORT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'support/assets/');
28
+		}
29
+		parent::__construct();
30
+	}
31 31
 
32 32
 
33
-    protected function _set_init_properties()
34
-    {
35
-        $this->label = esc_html__('Help & Support', 'event_espresso');
36
-    }
33
+	protected function _set_init_properties()
34
+	{
35
+		$this->label = esc_html__('Help & Support', 'event_espresso');
36
+	}
37 37
 
38 38
 
39
-    public function getMenuProperties(): array
40
-    {
41
-        return [
42
-            'menu_type'               => AdminMenuItem::TYPE_MENU_SUB_ITEM,
43
-            'menu_group'              => AdminMenuGroup::MENU_SLUG_EXTRAS,
44
-            'menu_order'              => 30,
45
-            'show_on_menu'            => AdminMenuItem::DISPLAY_BLOG_AND_NETWORK,
46
-            'parent_slug'             => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
47
-            'menu_slug'               => EE_SUPPORT_PG_SLUG,
48
-            'menu_label'              => esc_html__('Help & Support', 'event_espresso'),
49
-            'capability'              => 'ee_read_ee',
50
-            'maintenance_mode_parent' => AdminMenuTopLevel::MENU_PARENT_MAINTENANCE,
51
-        ];
52
-    }
39
+	public function getMenuProperties(): array
40
+	{
41
+		return [
42
+			'menu_type'               => AdminMenuItem::TYPE_MENU_SUB_ITEM,
43
+			'menu_group'              => AdminMenuGroup::MENU_SLUG_EXTRAS,
44
+			'menu_order'              => 30,
45
+			'show_on_menu'            => AdminMenuItem::DISPLAY_BLOG_AND_NETWORK,
46
+			'parent_slug'             => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
47
+			'menu_slug'               => EE_SUPPORT_PG_SLUG,
48
+			'menu_label'              => esc_html__('Help & Support', 'event_espresso'),
49
+			'capability'              => 'ee_read_ee',
50
+			'maintenance_mode_parent' => AdminMenuTopLevel::MENU_PARENT_MAINTENANCE,
51
+		];
52
+	}
53 53
 }
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page_Init.core.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -13,40 +13,40 @@
 block discarded – undo
13 13
  */
14 14
 class Transactions_Admin_Page_Init extends EE_Admin_Page_Init
15 15
 {
16
-    public function __construct()
17
-    {
18
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
19
-        if (! defined('TXN_PG_SLUG')) {
20
-            define('TXN_PG_SLUG', 'espresso_transactions');
21
-            define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
22
-            define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
23
-            define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
24
-            define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
25
-            define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
26
-            define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
27
-            define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
28
-        }
29
-        parent::__construct();
30
-    }
16
+	public function __construct()
17
+	{
18
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
19
+		if (! defined('TXN_PG_SLUG')) {
20
+			define('TXN_PG_SLUG', 'espresso_transactions');
21
+			define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
22
+			define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
23
+			define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
24
+			define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
25
+			define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
26
+			define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
27
+			define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
28
+		}
29
+		parent::__construct();
30
+	}
31 31
 
32 32
 
33
-    protected function _set_init_properties()
34
-    {
35
-        $this->label = esc_html__('Transactions Overview', 'event_espresso');
36
-    }
33
+	protected function _set_init_properties()
34
+	{
35
+		$this->label = esc_html__('Transactions Overview', 'event_espresso');
36
+	}
37 37
 
38 38
 
39
-    public function getMenuProperties(): array
40
-    {
41
-        return [
42
-            'menu_type'    => AdminMenuItem::TYPE_MENU_SUB_ITEM,
43
-            'menu_group'   => AdminMenuGroup::MENU_SLUG_MAIN,
44
-            'menu_order'   => 50,
45
-            'show_on_menu' => AdminMenuItem::DISPLAY_BLOG_ONLY,
46
-            'parent_slug'  => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
47
-            'menu_slug'    => TXN_PG_SLUG,
48
-            'menu_label'   => esc_html__('Transactions', 'event_espresso'),
49
-            'capability'   => 'ee_read_transactions',
50
-        ];
51
-    }
39
+	public function getMenuProperties(): array
40
+	{
41
+		return [
42
+			'menu_type'    => AdminMenuItem::TYPE_MENU_SUB_ITEM,
43
+			'menu_group'   => AdminMenuGroup::MENU_SLUG_MAIN,
44
+			'menu_order'   => 50,
45
+			'show_on_menu' => AdminMenuItem::DISPLAY_BLOG_ONLY,
46
+			'parent_slug'  => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
47
+			'menu_slug'    => TXN_PG_SLUG,
48
+			'menu_label'   => esc_html__('Transactions', 'event_espresso'),
49
+			'capability'   => 'ee_read_transactions',
50
+		];
51
+	}
52 52
 }
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page_Init.core.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,47 +14,47 @@
 block discarded – undo
14 14
  */
15 15
 class Messages_Admin_Page_Init extends EE_Admin_Page_Init
16 16
 {
17
-    /**
18
-     *constructor
19
-     *
20
-     * @Constructor
21
-     * @access public
22
-     * @return void
23
-     */
24
-    public function __construct()
25
-    {
26
-        if (! defined('EE_MSG_PG_SLUG')) {
27
-            define('EE_MSG_PG_SLUG', 'espresso_messages');
28
-            define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
29
-            define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
30
-            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
31
-            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
32
-            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
33
-            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
34
-            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
35
-        }
17
+	/**
18
+	 *constructor
19
+	 *
20
+	 * @Constructor
21
+	 * @access public
22
+	 * @return void
23
+	 */
24
+	public function __construct()
25
+	{
26
+		if (! defined('EE_MSG_PG_SLUG')) {
27
+			define('EE_MSG_PG_SLUG', 'espresso_messages');
28
+			define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
29
+			define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
30
+			define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
31
+			define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
32
+			define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
33
+			define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
34
+			define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
35
+		}
36 36
 
37
-        parent::__construct();
38
-    }
37
+		parent::__construct();
38
+	}
39 39
 
40 40
 
41
-    protected function _set_init_properties()
42
-    {
43
-        $this->label = esc_html__('Messages System', 'event_espresso');
44
-    }
41
+	protected function _set_init_properties()
42
+	{
43
+		$this->label = esc_html__('Messages System', 'event_espresso');
44
+	}
45 45
 
46 46
 
47
-    public function getMenuProperties(): array
48
-    {
49
-        return [
50
-            'menu_type'    => AdminMenuItem::TYPE_MENU_SUB_ITEM,
51
-            'menu_group'   => AdminMenuGroup::MENU_SLUG_MANAGEMENT,
52
-            'menu_order'   => 10,
53
-            'show_on_menu' => AdminMenuItem::DISPLAY_BLOG_ONLY,
54
-            'parent_slug'  => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
55
-            'menu_slug'    => EE_MSG_PG_SLUG,
56
-            'menu_label'   => esc_html__('Messages', 'event_espresso'),
57
-            'capability'   => 'ee_read_global_messages',
58
-        ];
59
-    }
47
+	public function getMenuProperties(): array
48
+	{
49
+		return [
50
+			'menu_type'    => AdminMenuItem::TYPE_MENU_SUB_ITEM,
51
+			'menu_group'   => AdminMenuGroup::MENU_SLUG_MANAGEMENT,
52
+			'menu_order'   => 10,
53
+			'show_on_menu' => AdminMenuItem::DISPLAY_BLOG_ONLY,
54
+			'parent_slug'  => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
55
+			'menu_slug'    => EE_MSG_PG_SLUG,
56
+			'menu_label'   => esc_html__('Messages', 'event_espresso'),
57
+			'capability'   => 'ee_read_global_messages',
58
+		];
59
+	}
60 60
 }
Please login to merge, or discard this patch.
admin_pages/other_services/Other_Services_Admin_Page_Init.core.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -16,38 +16,38 @@
 block discarded – undo
16 16
  */
17 17
 class Other_Services_Admin_Page_Init extends EE_Admin_Page_Init
18 18
 {
19
-    public function __construct()
20
-    {
21
-        // define some help/support page related constants
22
-        if (! defined('EE_OTHER_SERVICES_PG_SLUG')) {
23
-            define('EE_OTHER_SERVICES_PG_SLUG', 'espresso_packages');
24
-            define('EE_OTHER_SERVICES_ADMIN_URL', admin_url('admin.php?page=' . EE_OTHER_SERVICES_PG_SLUG));
25
-            define('EE_OTHER_SERVICES_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES . 'other_services/templates/');
26
-            define('EE_OTHER_SERVICES_ADMIN', EE_ADMIN_PAGES . 'other_services/');
27
-            define('EE_OTHER_SERVICES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'other_services/assets/');
28
-        }
29
-        parent::__construct();
30
-    }
19
+	public function __construct()
20
+	{
21
+		// define some help/support page related constants
22
+		if (! defined('EE_OTHER_SERVICES_PG_SLUG')) {
23
+			define('EE_OTHER_SERVICES_PG_SLUG', 'espresso_packages');
24
+			define('EE_OTHER_SERVICES_ADMIN_URL', admin_url('admin.php?page=' . EE_OTHER_SERVICES_PG_SLUG));
25
+			define('EE_OTHER_SERVICES_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES . 'other_services/templates/');
26
+			define('EE_OTHER_SERVICES_ADMIN', EE_ADMIN_PAGES . 'other_services/');
27
+			define('EE_OTHER_SERVICES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'other_services/assets/');
28
+		}
29
+		parent::__construct();
30
+	}
31 31
 
32 32
 
33
-    protected function _set_init_properties()
34
-    {
35
-        $this->label = esc_html__('Extensions & Services', 'event_espresso');
36
-    }
33
+	protected function _set_init_properties()
34
+	{
35
+		$this->label = esc_html__('Extensions & Services', 'event_espresso');
36
+	}
37 37
 
38 38
 
39
-    public function getMenuProperties(): array
40
-    {
41
-        return [
42
-            'menu_type'               => AdminMenuItem::TYPE_MENU_SUB_ITEM,
43
-            'menu_group'              => AdminMenuGroup::MENU_SLUG_EXTRAS,
44
-            'menu_order'              => 30,
45
-            'show_on_menu'            => AdminMenuItem::DISPLAY_BLOG_AND_NETWORK,
46
-            'parent_slug'             => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
47
-            'menu_slug'               => EE_OTHER_SERVICES_PG_SLUG,
48
-            'menu_label'              => esc_html__('Extensions & Services', 'event_espresso'),
49
-            'capability'              => 'ee_read_ee',
50
-            'maintenance_mode_parent' => AdminMenuTopLevel::MENU_PARENT_MAINTENANCE,
51
-        ];
52
-    }
39
+	public function getMenuProperties(): array
40
+	{
41
+		return [
42
+			'menu_type'               => AdminMenuItem::TYPE_MENU_SUB_ITEM,
43
+			'menu_group'              => AdminMenuGroup::MENU_SLUG_EXTRAS,
44
+			'menu_order'              => 30,
45
+			'show_on_menu'            => AdminMenuItem::DISPLAY_BLOG_AND_NETWORK,
46
+			'parent_slug'             => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
47
+			'menu_slug'               => EE_OTHER_SERVICES_PG_SLUG,
48
+			'menu_label'              => esc_html__('Extensions & Services', 'event_espresso'),
49
+			'capability'              => 'ee_read_ee',
50
+			'maintenance_mode_parent' => AdminMenuTopLevel::MENU_PARENT_MAINTENANCE,
51
+		];
52
+	}
53 53
 }
Please login to merge, or discard this patch.
caffeinated/admin/hooks/Global_EE_Caf_Hooks.class.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -12,43 +12,43 @@
 block discarded – undo
12 12
  */
13 13
 class Global_EE_Caf_Hooks
14 14
 {
15
-    private const RSS_FEED_URL = 'https://eventespresso.com/api/feed/';
16
-
17
-
18
-    public function __construct()
19
-    {
20
-        $this->_do_hooks();
21
-    }
22
-
23
-
24
-    private function _do_hooks()
25
-    {
26
-        add_filter('FHEE_show_sponsors_meta_box', '__return_false');
27
-        add_filter('FHEE_show_ratings_request_meta_box', '__return_false');
28
-        add_filter(
29
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
30
-            [$this, 'forums_lazy_loading']
31
-        );
32
-        // commenting out for now because it's a duplicate of EE_Admin_Page::espresso_news_post_box()
33
-        // add_action(
34
-        //     'AHEE__EE_Admin_Page__espresso_news_post_box__after_content',
35
-        //     [$this, 'extra_news_box_content']
36
-        // );
37
-    }
38
-
39
-
40
-    public function extra_news_box_content()
41
-    {
42
-        echo '<h3 style="margin:0">' . esc_html__('From the Forums', 'event_espresso') . '</h3>';
43
-        echo '<div id="ee_forum_posts_content">';
44
-        EE_Admin_Page::cached_rss_display('ee_forum_posts_content', self::RSS_FEED_URL);
45
-        echo '</div>';
46
-    }
47
-
48
-
49
-    public function forums_lazy_loading($ids)
50
-    {
51
-        $ids[] = 'ee_forum_posts_content';
52
-        return $ids;
53
-    }
15
+	private const RSS_FEED_URL = 'https://eventespresso.com/api/feed/';
16
+
17
+
18
+	public function __construct()
19
+	{
20
+		$this->_do_hooks();
21
+	}
22
+
23
+
24
+	private function _do_hooks()
25
+	{
26
+		add_filter('FHEE_show_sponsors_meta_box', '__return_false');
27
+		add_filter('FHEE_show_ratings_request_meta_box', '__return_false');
28
+		add_filter(
29
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
30
+			[$this, 'forums_lazy_loading']
31
+		);
32
+		// commenting out for now because it's a duplicate of EE_Admin_Page::espresso_news_post_box()
33
+		// add_action(
34
+		//     'AHEE__EE_Admin_Page__espresso_news_post_box__after_content',
35
+		//     [$this, 'extra_news_box_content']
36
+		// );
37
+	}
38
+
39
+
40
+	public function extra_news_box_content()
41
+	{
42
+		echo '<h3 style="margin:0">' . esc_html__('From the Forums', 'event_espresso') . '</h3>';
43
+		echo '<div id="ee_forum_posts_content">';
44
+		EE_Admin_Page::cached_rss_display('ee_forum_posts_content', self::RSS_FEED_URL);
45
+		echo '</div>';
46
+	}
47
+
48
+
49
+	public function forums_lazy_loading($ids)
50
+	{
51
+		$ids[] = 'ee_forum_posts_content';
52
+		return $ids;
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
     public function extra_news_box_content()
41 41
     {
42
-        echo '<h3 style="margin:0">' . esc_html__('From the Forums', 'event_espresso') . '</h3>';
42
+        echo '<h3 style="margin:0">'.esc_html__('From the Forums', 'event_espresso').'</h3>';
43 43
         echo '<div id="ee_forum_posts_content">';
44 44
         EE_Admin_Page::cached_rss_display('ee_forum_posts_content', self::RSS_FEED_URL);
45 45
         echo '</div>';
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/Pricing_Admin_Page_Init.core.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -17,45 +17,45 @@
 block discarded – undo
17 17
  */
18 18
 class Pricing_Admin_Page_Init extends EE_Admin_Page_Init
19 19
 {
20
-    /**
21
-     * @Constructor
22
-     */
23
-    public function __construct()
24
-    {
25
-        if (! defined('PRICING_PG_SLUG')) {
26
-            define('PRICING_PG_SLUG', 'pricing');
27
-            define('PRICING_LABEL', esc_html__('Pricing', 'event_espresso'));
28
-            define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG)));
29
-            define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/');
30
-            define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG));
31
-            define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/');
32
-            define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/');
33
-            define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/');
34
-            define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/');
35
-        }
36
-        parent::__construct();
37
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/';
38
-    }
20
+	/**
21
+	 * @Constructor
22
+	 */
23
+	public function __construct()
24
+	{
25
+		if (! defined('PRICING_PG_SLUG')) {
26
+			define('PRICING_PG_SLUG', 'pricing');
27
+			define('PRICING_LABEL', esc_html__('Pricing', 'event_espresso'));
28
+			define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG)));
29
+			define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/');
30
+			define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG));
31
+			define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/');
32
+			define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/');
33
+			define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/');
34
+			define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/');
35
+		}
36
+		parent::__construct();
37
+		$this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/';
38
+	}
39 39
 
40 40
 
41
-    protected function _set_init_properties()
42
-    {
43
-        $this->label = PRICING_LABEL;
44
-    }
41
+	protected function _set_init_properties()
42
+	{
43
+		$this->label = PRICING_LABEL;
44
+	}
45 45
 
46 46
 
47
-    public function getMenuProperties(): array
48
-    {
49
-        return [
50
-            'menu_type'       => AdminMenuItem::TYPE_MENU_SUB_ITEM,
51
-            'menu_group'      => AdminMenuGroup::MENU_SLUG_MANAGEMENT,
52
-            'menu_order'      => 20,
53
-            'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
54
-            'parent_slug'     => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
55
-            'menu_slug'       => PRICING_PG_SLUG,
56
-            'menu_label'      => PRICING_LABEL,
57
-            'capability'      => 'ee_read_default_prices',
58
-            'admin_init_page' => $this,
59
-        ];
60
-    }
47
+	public function getMenuProperties(): array
48
+	{
49
+		return [
50
+			'menu_type'       => AdminMenuItem::TYPE_MENU_SUB_ITEM,
51
+			'menu_group'      => AdminMenuGroup::MENU_SLUG_MANAGEMENT,
52
+			'menu_order'      => 20,
53
+			'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
54
+			'parent_slug'     => AdminMenuTopLevel::MENU_PARENT_ACTIVE,
55
+			'menu_slug'       => PRICING_PG_SLUG,
56
+			'menu_label'      => PRICING_LABEL,
57
+			'capability'      => 'ee_read_default_prices',
58
+			'admin_init_page' => $this,
59
+		];
60
+	}
61 61
 }
Please login to merge, or discard this patch.
caffeinated/admin/new/license_keys/License_Keys_Admin_Page_Init.core.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -12,46 +12,46 @@
 block discarded – undo
12 12
  */
13 13
 class License_Keys_Admin_Page_Init extends EE_Admin_Page_Init
14 14
 {
15
-    public function __construct()
16
-    {
17
-        if (! defined('LICENSE_KEYS_PG_SLUG')) {
18
-            define('LICENSE_KEYS_PG_SLUG', 'espresso_license_keys');
19
-            define('LICENSE_KEYS_LABEL', esc_html__('License Keys', 'event_espresso'));
20
-            define('LICENSE_KEYS_ADMIN', EE_CORE_CAF_ADMIN . 'new/license_keys/');
21
-            define('LICENSE_KEYS_ADMIN_URL', admin_url('admin.php?page=' . LICENSE_KEYS_PG_SLUG));
22
-            define('LICENSE_KEYS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/license_keys/assets/');
23
-        }
24
-        parent::__construct();
25
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/license_keys/';
26
-    }
15
+	public function __construct()
16
+	{
17
+		if (! defined('LICENSE_KEYS_PG_SLUG')) {
18
+			define('LICENSE_KEYS_PG_SLUG', 'espresso_license_keys');
19
+			define('LICENSE_KEYS_LABEL', esc_html__('License Keys', 'event_espresso'));
20
+			define('LICENSE_KEYS_ADMIN', EE_CORE_CAF_ADMIN . 'new/license_keys/');
21
+			define('LICENSE_KEYS_ADMIN_URL', admin_url('admin.php?page=' . LICENSE_KEYS_PG_SLUG));
22
+			define('LICENSE_KEYS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/license_keys/assets/');
23
+		}
24
+		parent::__construct();
25
+		$this->_folder_path = EE_CORE_CAF_ADMIN . 'new/license_keys/';
26
+	}
27 27
 
28 28
 
29
-    protected function _set_init_properties()
30
-    {
31
-        $this->label = LICENSE_KEYS_LABEL;
32
-    }
29
+	protected function _set_init_properties()
30
+	{
31
+		$this->label = LICENSE_KEYS_LABEL;
32
+	}
33 33
 
34 34
 
35
-    public function getMenuProperties(): array
36
-    {
37
-        $feature = $this->loader->getShared(FeatureFlags::class);
38
-        $this->setAdminMenu(
39
-            new AdminMenuSubItem(
40
-                [
41
-                    'menu_type'       => AdminMenuItem::TYPE_MENU_SUB_ITEM,
42
-                    'menu_group'      => 'settings',
43
-                    'menu_order'      => 10,
44
-                    'show_on_menu'    => $feature->allowed('use_edd_plugin_licensing') && is_main_site()
45
-                        ? AdminMenuItem::DISPLAY_BLOG_ONLY
46
-                        : AdminMenuItem::DISPLAY_NONE,
47
-                    'parent_slug'     => 'espresso_events',
48
-                    'menu_slug'       => LICENSE_KEYS_PG_SLUG,
49
-                    'menu_label'      => LICENSE_KEYS_LABEL,
50
-                    'capability'      => 'manage_options',
51
-                    'admin_init_page' => $this,
52
-                ]
53
-            )
54
-        );
55
-        return [];
56
-    }
35
+	public function getMenuProperties(): array
36
+	{
37
+		$feature = $this->loader->getShared(FeatureFlags::class);
38
+		$this->setAdminMenu(
39
+			new AdminMenuSubItem(
40
+				[
41
+					'menu_type'       => AdminMenuItem::TYPE_MENU_SUB_ITEM,
42
+					'menu_group'      => 'settings',
43
+					'menu_order'      => 10,
44
+					'show_on_menu'    => $feature->allowed('use_edd_plugin_licensing') && is_main_site()
45
+						? AdminMenuItem::DISPLAY_BLOG_ONLY
46
+						: AdminMenuItem::DISPLAY_NONE,
47
+					'parent_slug'     => 'espresso_events',
48
+					'menu_slug'       => LICENSE_KEYS_PG_SLUG,
49
+					'menu_label'      => LICENSE_KEYS_LABEL,
50
+					'capability'      => 'manage_options',
51
+					'admin_init_page' => $this,
52
+				]
53
+			)
54
+		);
55
+		return [];
56
+	}
57 57
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
 {
15 15
     public function __construct()
16 16
     {
17
-        if (! defined('LICENSE_KEYS_PG_SLUG')) {
17
+        if ( ! defined('LICENSE_KEYS_PG_SLUG')) {
18 18
             define('LICENSE_KEYS_PG_SLUG', 'espresso_license_keys');
19 19
             define('LICENSE_KEYS_LABEL', esc_html__('License Keys', 'event_espresso'));
20
-            define('LICENSE_KEYS_ADMIN', EE_CORE_CAF_ADMIN . 'new/license_keys/');
21
-            define('LICENSE_KEYS_ADMIN_URL', admin_url('admin.php?page=' . LICENSE_KEYS_PG_SLUG));
22
-            define('LICENSE_KEYS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/license_keys/assets/');
20
+            define('LICENSE_KEYS_ADMIN', EE_CORE_CAF_ADMIN.'new/license_keys/');
21
+            define('LICENSE_KEYS_ADMIN_URL', admin_url('admin.php?page='.LICENSE_KEYS_PG_SLUG));
22
+            define('LICENSE_KEYS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL.'new/license_keys/assets/');
23 23
         }
24 24
         parent::__construct();
25
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/license_keys/';
25
+        $this->_folder_path = EE_CORE_CAF_ADMIN.'new/license_keys/';
26 26
     }
27 27
 
28 28
 
Please login to merge, or discard this patch.