Completed
Branch add-wp-version-to-pue-stats (0dc30c)
by
unknown
116:06 queued 107:39
created
admin/extend/registration_form/Extend_Registration_Form_Admin_Page.core.php 2 patches
Indentation   +1319 added lines, -1319 removed lines patch added patch discarded remove patch
@@ -14,1323 +14,1323 @@
 block discarded – undo
14 14
 class Extend_Registration_Form_Admin_Page extends Registration_Form_Admin_Page
15 15
 {
16 16
 
17
-    /**
18
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
19
-     */
20
-    public function __construct($routing = true)
21
-    {
22
-        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/');
23
-        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/');
24
-        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
25
-        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/');
26
-        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
27
-        parent::__construct($routing);
28
-    }
29
-
30
-
31
-    /**
32
-     * @return void
33
-     */
34
-    protected function _extend_page_config()
35
-    {
36
-        $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
37
-        $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID'])
38
-            ? $this->_req_data['QST_ID'] : 0;
39
-        $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID'])
40
-            ? $this->_req_data['QSG_ID'] : 0;
41
-
42
-        $new_page_routes = array(
43
-            'question_groups'    => array(
44
-                'func'       => '_question_groups_overview_list_table',
45
-                'capability' => 'ee_read_question_groups',
46
-            ),
47
-            'add_question'       => array(
48
-                'func'       => '_edit_question',
49
-                'capability' => 'ee_edit_questions',
50
-            ),
51
-            'insert_question'    => array(
52
-                'func'       => '_insert_or_update_question',
53
-                'args'       => array('new_question' => true),
54
-                'capability' => 'ee_edit_questions',
55
-                'noheader'   => true,
56
-            ),
57
-            'duplicate_question' => array(
58
-                'func'       => '_duplicate_question',
59
-                'capability' => 'ee_edit_questions',
60
-                'noheader'   => true,
61
-            ),
62
-            'trash_question'     => array(
63
-                'func'       => '_trash_question',
64
-                'capability' => 'ee_delete_question',
65
-                'obj_id'     => $qst_id,
66
-                'noheader'   => true,
67
-            ),
68
-
69
-            'restore_question' => array(
70
-                'func'       => '_trash_or_restore_questions',
71
-                'capability' => 'ee_delete_question',
72
-                'obj_id'     => $qst_id,
73
-                'args'       => array('trash' => false),
74
-                'noheader'   => true,
75
-            ),
76
-
77
-            'delete_question' => array(
78
-                'func'       => '_delete_question',
79
-                'capability' => 'ee_delete_question',
80
-                'obj_id'     => $qst_id,
81
-                'noheader'   => true,
82
-            ),
83
-
84
-            'trash_questions' => array(
85
-                'func'       => '_trash_or_restore_questions',
86
-                'capability' => 'ee_delete_questions',
87
-                'args'       => array('trash' => true),
88
-                'noheader'   => true,
89
-            ),
90
-
91
-            'restore_questions' => array(
92
-                'func'       => '_trash_or_restore_questions',
93
-                'capability' => 'ee_delete_questions',
94
-                'args'       => array('trash' => false),
95
-                'noheader'   => true,
96
-            ),
97
-
98
-            'delete_questions' => array(
99
-                'func'       => '_delete_questions',
100
-                'args'       => array(),
101
-                'capability' => 'ee_delete_questions',
102
-                'noheader'   => true,
103
-            ),
104
-
105
-            'add_question_group' => array(
106
-                'func'       => '_edit_question_group',
107
-                'capability' => 'ee_edit_question_groups',
108
-            ),
109
-
110
-            'edit_question_group' => array(
111
-                'func'       => '_edit_question_group',
112
-                'capability' => 'ee_edit_question_group',
113
-                'obj_id'     => $qsg_id,
114
-                'args'       => array('edit'),
115
-            ),
116
-
117
-            'delete_question_groups' => array(
118
-                'func'       => '_delete_question_groups',
119
-                'capability' => 'ee_delete_question_groups',
120
-                'noheader'   => true,
121
-            ),
122
-
123
-            'delete_question_group' => array(
124
-                'func'       => '_delete_question_groups',
125
-                'capability' => 'ee_delete_question_group',
126
-                'obj_id'     => $qsg_id,
127
-                'noheader'   => true,
128
-            ),
129
-
130
-            'trash_question_group' => array(
131
-                'func'       => '_trash_or_restore_question_groups',
132
-                'args'       => array('trash' => true),
133
-                'capability' => 'ee_delete_question_group',
134
-                'obj_id'     => $qsg_id,
135
-                'noheader'   => true,
136
-            ),
137
-
138
-            'restore_question_group' => array(
139
-                'func'       => '_trash_or_restore_question_groups',
140
-                'args'       => array('trash' => false),
141
-                'capability' => 'ee_delete_question_group',
142
-                'obj_id'     => $qsg_id,
143
-                'noheader'   => true,
144
-            ),
145
-
146
-            'insert_question_group' => array(
147
-                'func'       => '_insert_or_update_question_group',
148
-                'args'       => array('new_question_group' => true),
149
-                'capability' => 'ee_edit_question_groups',
150
-                'noheader'   => true,
151
-            ),
152
-
153
-            'update_question_group' => array(
154
-                'func'       => '_insert_or_update_question_group',
155
-                'args'       => array('new_question_group' => false),
156
-                'capability' => 'ee_edit_question_group',
157
-                'obj_id'     => $qsg_id,
158
-                'noheader'   => true,
159
-            ),
160
-
161
-            'trash_question_groups' => array(
162
-                'func'       => '_trash_or_restore_question_groups',
163
-                'args'       => array('trash' => true),
164
-                'capability' => 'ee_delete_question_groups',
165
-                'noheader'   => array('trash' => false),
166
-            ),
167
-
168
-            'restore_question_groups' => array(
169
-                'func'       => '_trash_or_restore_question_groups',
170
-                'args'       => array('trash' => false),
171
-                'capability' => 'ee_delete_question_groups',
172
-                'noheader'   => true,
173
-            ),
174
-
175
-
176
-            'espresso_update_question_group_order' => array(
177
-                'func'       => 'update_question_group_order',
178
-                'capability' => 'ee_edit_question_groups',
179
-                'noheader'   => true,
180
-            ),
181
-
182
-            'view_reg_form_settings' => array(
183
-                'func'       => '_reg_form_settings',
184
-                'capability' => 'manage_options',
185
-            ),
186
-
187
-            'update_reg_form_settings' => array(
188
-                'func'       => '_update_reg_form_settings',
189
-                'capability' => 'manage_options',
190
-                'noheader'   => true,
191
-            ),
192
-        );
193
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
194
-
195
-        $new_page_config = array(
196
-
197
-            'question_groups' => array(
198
-                'nav'           => array(
199
-                    'label' => esc_html__('Question Groups', 'event_espresso'),
200
-                    'order' => 20,
201
-                ),
202
-                'list_table'    => 'Registration_Form_Question_Groups_Admin_List_Table',
203
-                'help_tabs'     => array(
204
-                    'registration_form_question_groups_help_tab'                           => array(
205
-                        'title'    => esc_html__('Question Groups', 'event_espresso'),
206
-                        'filename' => 'registration_form_question_groups',
207
-                    ),
208
-                    'registration_form_question_groups_table_column_headings_help_tab'     => array(
209
-                        'title'    => esc_html__('Question Groups Table Column Headings', 'event_espresso'),
210
-                        'filename' => 'registration_form_question_groups_table_column_headings',
211
-                    ),
212
-                    'registration_form_question_groups_views_bulk_actions_search_help_tab' => array(
213
-                        'title'    => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'),
214
-                        'filename' => 'registration_form_question_groups_views_bulk_actions_search',
215
-                    ),
216
-                ),
217
-                'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
218
-                'metaboxes'     => $this->_default_espresso_metaboxes,
219
-                'require_nonce' => false,
220
-                'qtips'         => array(
221
-                    'EE_Registration_Form_Tips',
222
-                ),
223
-            ),
224
-
225
-            'add_question' => array(
226
-                'nav'           => array(
227
-                    'label'      => esc_html__('Add Question', 'event_espresso'),
228
-                    'order'      => 5,
229
-                    'persistent' => false,
230
-                ),
231
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
232
-                'help_tabs'     => array(
233
-                    'registration_form_add_question_help_tab' => array(
234
-                        'title'    => esc_html__('Add Question', 'event_espresso'),
235
-                        'filename' => 'registration_form_add_question',
236
-                    ),
237
-                ),
238
-                'help_tour'     => array('Registration_Form_Add_Question_Help_Tour'),
239
-                'require_nonce' => false,
240
-            ),
241
-
242
-            'add_question_group' => array(
243
-                'nav'           => array(
244
-                    'label'      => esc_html__('Add Question Group', 'event_espresso'),
245
-                    'order'      => 5,
246
-                    'persistent' => false,
247
-                ),
248
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
249
-                'help_tabs'     => array(
250
-                    'registration_form_add_question_group_help_tab' => array(
251
-                        'title'    => esc_html__('Add Question Group', 'event_espresso'),
252
-                        'filename' => 'registration_form_add_question_group',
253
-                    ),
254
-                ),
255
-                'help_tour'     => array('Registration_Form_Add_Question_Group_Help_Tour'),
256
-                'require_nonce' => false,
257
-            ),
258
-
259
-            'edit_question_group' => array(
260
-                'nav'           => array(
261
-                    'label'      => esc_html__('Edit Question Group', 'event_espresso'),
262
-                    'order'      => 5,
263
-                    'persistent' => false,
264
-                    'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(
265
-                        array('question_group_id' => $this->_req_data['question_group_id']),
266
-                        $this->_current_page_view_url
267
-                    ) : $this->_admin_base_url,
268
-                ),
269
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
270
-                'help_tabs'     => array(
271
-                    'registration_form_edit_question_group_help_tab' => array(
272
-                        'title'    => esc_html__('Edit Question Group', 'event_espresso'),
273
-                        'filename' => 'registration_form_edit_question_group',
274
-                    ),
275
-                ),
276
-                'help_tour'     => array('Registration_Form_Edit_Question_Group_Help_Tour'),
277
-                'require_nonce' => false,
278
-            ),
279
-
280
-            'view_reg_form_settings' => array(
281
-                'nav'           => array(
282
-                    'label' => esc_html__('Reg Form Settings', 'event_espresso'),
283
-                    'order' => 40,
284
-                ),
285
-                'labels'        => array(
286
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
287
-                ),
288
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
289
-                'help_tabs'     => array(
290
-                    'registration_form_reg_form_settings_help_tab' => array(
291
-                        'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
292
-                        'filename' => 'registration_form_reg_form_settings',
293
-                    ),
294
-                ),
295
-                'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
296
-                'require_nonce' => false,
297
-            ),
298
-
299
-        );
300
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
301
-
302
-        // change the list table we're going to use so it's the NEW list table!
303
-        $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
304
-
305
-
306
-        // additional labels
307
-        $new_labels = array(
308
-            'add_question'          => esc_html__('Add New Question', 'event_espresso'),
309
-            'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
310
-            'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
311
-            'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
312
-            'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
313
-        );
314
-        $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
315
-    }
316
-
317
-
318
-    /**
319
-     * @return void
320
-     */
321
-    protected function _ajax_hooks()
322
-    {
323
-        add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
324
-    }
325
-
326
-
327
-    /**
328
-     * @return void
329
-     */
330
-    public function load_scripts_styles_question_groups()
331
-    {
332
-        wp_enqueue_script('espresso_ajax_table_sorting');
333
-    }
334
-
335
-
336
-    /**
337
-     * @return void
338
-     */
339
-    public function load_scripts_styles_add_question_group()
340
-    {
341
-        $this->load_scripts_styles_forms();
342
-        $this->load_sortable_question_script();
343
-    }
344
-
345
-
346
-    /**
347
-     * @return void
348
-     */
349
-    public function load_scripts_styles_edit_question_group()
350
-    {
351
-        $this->load_scripts_styles_forms();
352
-        $this->load_sortable_question_script();
353
-    }
354
-
355
-
356
-    /**
357
-     * registers and enqueues script for questions
358
-     *
359
-     * @return void
360
-     */
361
-    public function load_sortable_question_script()
362
-    {
363
-        wp_register_script(
364
-            'ee-question-sortable',
365
-            REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
366
-            array('jquery-ui-sortable'),
367
-            EVENT_ESPRESSO_VERSION,
368
-            true
369
-        );
370
-        wp_enqueue_script('ee-question-sortable');
371
-    }
372
-
373
-
374
-    /**
375
-     * @return void
376
-     */
377
-    protected function _set_list_table_views_default()
378
-    {
379
-        $this->_views = array(
380
-            'all' => array(
381
-                'slug'        => 'all',
382
-                'label'       => esc_html__('View All Questions', 'event_espresso'),
383
-                'count'       => 0,
384
-                'bulk_action' => array(
385
-                    'trash_questions' => esc_html__('Trash', 'event_espresso'),
386
-                ),
387
-            ),
388
-        );
389
-
390
-        if (EE_Registry::instance()->CAP->current_user_can(
391
-            'ee_delete_questions',
392
-            'espresso_registration_form_trash_questions'
393
-        )
394
-        ) {
395
-            $this->_views['trash'] = array(
396
-                'slug'        => 'trash',
397
-                'label'       => esc_html__('Trash', 'event_espresso'),
398
-                'count'       => 0,
399
-                'bulk_action' => array(
400
-                    'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
401
-                    'restore_questions' => esc_html__('Restore', 'event_espresso'),
402
-                ),
403
-            );
404
-        }
405
-    }
406
-
407
-
408
-    /**
409
-     * @return void
410
-     */
411
-    protected function _set_list_table_views_question_groups()
412
-    {
413
-        $this->_views = array(
414
-            'all' => array(
415
-                'slug'        => 'all',
416
-                'label'       => esc_html__('All', 'event_espresso'),
417
-                'count'       => 0,
418
-                'bulk_action' => array(
419
-                    'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
420
-                ),
421
-            ),
422
-        );
423
-
424
-        if (EE_Registry::instance()->CAP->current_user_can(
425
-            'ee_delete_question_groups',
426
-            'espresso_registration_form_trash_question_groups'
427
-        )
428
-        ) {
429
-            $this->_views['trash'] = array(
430
-                'slug'        => 'trash',
431
-                'label'       => esc_html__('Trash', 'event_espresso'),
432
-                'count'       => 0,
433
-                'bulk_action' => array(
434
-                    'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
435
-                    'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
436
-                ),
437
-            );
438
-        }
439
-    }
440
-
441
-
442
-    /**
443
-     * @return void
444
-     * @throws EE_Error
445
-     * @throws InvalidArgumentException
446
-     * @throws InvalidDataTypeException
447
-     * @throws InvalidInterfaceException
448
-     */
449
-    protected function _questions_overview_list_table()
450
-    {
451
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
452
-            'add_question',
453
-            'add_question',
454
-            array(),
455
-            'add-new-h2'
456
-        );
457
-        parent::_questions_overview_list_table();
458
-    }
459
-
460
-
461
-    /**
462
-     * @return void
463
-     * @throws DomainException
464
-     * @throws EE_Error
465
-     * @throws InvalidArgumentException
466
-     * @throws InvalidDataTypeException
467
-     * @throws InvalidInterfaceException
468
-     */
469
-    protected function _question_groups_overview_list_table()
470
-    {
471
-        $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
472
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
473
-            'add_question_group',
474
-            'add_question_group',
475
-            array(),
476
-            'add-new-h2'
477
-        );
478
-        $this->display_admin_list_table_page_with_sidebar();
479
-    }
480
-
481
-
482
-    /**
483
-     * @return void
484
-     * @throws EE_Error
485
-     * @throws InvalidArgumentException
486
-     * @throws InvalidDataTypeException
487
-     * @throws InvalidInterfaceException
488
-     */
489
-    protected function _delete_question()
490
-    {
491
-        $success = $this->_delete_items($this->_question_model);
492
-        $this->_redirect_after_action(
493
-            $success,
494
-            $this->_question_model->item_name($success),
495
-            'deleted',
496
-            array('action' => 'default', 'status' => 'all')
497
-        );
498
-    }
499
-
500
-
501
-    /**
502
-     * @return void
503
-     * @throws EE_Error
504
-     * @throws InvalidArgumentException
505
-     * @throws InvalidDataTypeException
506
-     * @throws InvalidInterfaceException
507
-     */
508
-    protected function _delete_questions()
509
-    {
510
-        $success = $this->_delete_items($this->_question_model);
511
-        $this->_redirect_after_action(
512
-            $success,
513
-            $this->_question_model->item_name($success),
514
-            'deleted permanently',
515
-            array('action' => 'default', 'status' => 'trash')
516
-        );
517
-    }
518
-
519
-
520
-    /**
521
-     * Performs the deletion of a single or multiple questions or question groups.
522
-     *
523
-     * @param EEM_Soft_Delete_Base $model
524
-     * @return int number of items deleted permanently
525
-     * @throws EE_Error
526
-     * @throws InvalidArgumentException
527
-     * @throws InvalidDataTypeException
528
-     * @throws InvalidInterfaceException
529
-     */
530
-    private function _delete_items(EEM_Soft_Delete_Base $model)
531
-    {
532
-        $success = 0;
533
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
534
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
535
-            // if array has more than one element than success message should be plural
536
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
537
-            // cycle thru bulk action checkboxes
538
-            while (list($ID, $value) = each($this->_req_data['checkbox'])) {
539
-                if (! $this->_delete_item($ID, $model)) {
540
-                    $success = 0;
541
-                }
542
-            }
543
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
544
-            $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
545
-        } elseif (! empty($this->_req_data['QST_ID'])) {
546
-            $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
547
-        } else {
548
-            EE_Error::add_error(
549
-                sprintf(
550
-                    esc_html__(
551
-                        "No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
552
-                        "event_espresso"
553
-                    )
554
-                ),
555
-                __FILE__,
556
-                __FUNCTION__,
557
-                __LINE__
558
-            );
559
-        }
560
-        return $success;
561
-    }
562
-
563
-
564
-    /**
565
-     * Deletes the specified question (and its associated question options) or question group
566
-     *
567
-     * @param int                  $id
568
-     * @param EEM_Soft_Delete_Base $model
569
-     * @return boolean
570
-     * @throws EE_Error
571
-     * @throws InvalidArgumentException
572
-     * @throws InvalidDataTypeException
573
-     * @throws InvalidInterfaceException
574
-     */
575
-    protected function _delete_item($id, $model)
576
-    {
577
-        if ($model instanceof EEM_Question) {
578
-            EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
579
-        }
580
-        return $model->delete_permanently_by_ID(absint($id));
581
-    }
582
-
583
-
584
-    /******************************    QUESTION GROUPS    ******************************/
585
-
586
-
587
-    /**
588
-     * @param string $type
589
-     * @return void
590
-     * @throws DomainException
591
-     * @throws EE_Error
592
-     * @throws InvalidArgumentException
593
-     * @throws InvalidDataTypeException
594
-     * @throws InvalidInterfaceException
595
-     */
596
-    protected function _edit_question_group($type = 'add')
597
-    {
598
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
599
-        $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID'])
600
-            ? absint($this->_req_data['QSG_ID'])
601
-            : false;
602
-
603
-        switch ($this->_req_action) {
604
-            case 'add_question_group':
605
-                $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
606
-                break;
607
-            case 'edit_question_group':
608
-                $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
609
-                break;
610
-            default:
611
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
612
-        }
613
-        // add ID to title if editing
614
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
615
-        if ($ID) {
616
-            /** @var EE_Question_Group $questionGroup */
617
-            $questionGroup = $this->_question_group_model->get_one_by_ID($ID);
618
-            $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
619
-            $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
620
-        } else {
621
-            /** @var EE_Question_Group $questionGroup */
622
-            $questionGroup = EEM_Question_Group::instance()->create_default_object();
623
-            $questionGroup->set_order_to_latest();
624
-            $this->_set_add_edit_form_tags('insert_question_group');
625
-        }
626
-        $this->_template_args['values'] = $this->_yes_no_values;
627
-        $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
628
-        $this->_template_args['QSG_ID'] = $ID ? $ID : true;
629
-        $this->_template_args['question_group'] = $questionGroup;
630
-
631
-        $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
632
-        $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
633
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
634
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
635
-            $this->_template_args,
636
-            true
637
-        );
638
-
639
-        // the details template wrapper
640
-        $this->display_admin_page_with_sidebar();
641
-    }
642
-
643
-
644
-    /**
645
-     * @return void
646
-     * @throws EE_Error
647
-     * @throws InvalidArgumentException
648
-     * @throws InvalidDataTypeException
649
-     * @throws InvalidInterfaceException
650
-     */
651
-    protected function _delete_question_groups()
652
-    {
653
-        $success = $this->_delete_items($this->_question_group_model);
654
-        $this->_redirect_after_action(
655
-            $success,
656
-            $this->_question_group_model->item_name($success),
657
-            'deleted permanently',
658
-            array('action' => 'question_groups', 'status' => 'trash')
659
-        );
660
-    }
661
-
662
-
663
-    /**
664
-     * @param bool $new_question_group
665
-     * @throws EE_Error
666
-     * @throws InvalidArgumentException
667
-     * @throws InvalidDataTypeException
668
-     * @throws InvalidInterfaceException
669
-     */
670
-    protected function _insert_or_update_question_group($new_question_group = true)
671
-    {
672
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
673
-        $set_column_values = $this->_set_column_values_for($this->_question_group_model);
674
-        if ($new_question_group) {
675
-            // make sure identifier is unique
676
-            $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : '';
677
-            $identifier_exists = ! empty($identifier_value)
678
-                ? $this->_question_group_model->count([['QSG_identifier' => $set_column_values['QSG_identifier']]]) > 0
679
-                : false;
680
-            if ($identifier_exists) {
681
-                $set_column_values['QSG_identifier'] .= uniqid('id', true);
682
-            }
683
-            $QSG_ID = $this->_question_group_model->insert($set_column_values);
684
-            $success = $QSG_ID ? 1 : 0;
685
-            if ($success === 0) {
686
-                EE_Error::add_error(
687
-                    esc_html__('Something went wrong saving the question group.', 'event_espresso'),
688
-                    __FILE__,
689
-                    __FUNCTION__,
690
-                    __LINE__
691
-                );
692
-                $this->_redirect_after_action(
693
-                    false,
694
-                    '',
695
-                    '',
696
-                    array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
697
-                    true
698
-                );
699
-            }
700
-        } else {
701
-            $QSG_ID = absint($this->_req_data['QSG_ID']);
702
-            unset($set_column_values['QSG_ID']);
703
-            $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
704
-        }
705
-
706
-        $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(
707
-            EEM_Attendee::system_question_phone
708
-        );
709
-        // update the existing related questions
710
-        // BUT FIRST...  delete the phone question from the Question_Group_Question
711
-        // if it is being added to this question group (therefore removed from the existing group)
712
-        if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
713
-            // delete where QST ID = system phone question ID and Question Group ID is NOT this group
714
-            EEM_Question_Group_Question::instance()->delete(
715
-                array(
716
-                    array(
717
-                        'QST_ID' => $phone_question_id,
718
-                        'QSG_ID' => array('!=', $QSG_ID),
719
-                    ),
720
-                )
721
-            );
722
-        }
723
-        /** @type EE_Question_Group $question_group */
724
-        $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
725
-        $questions = $question_group->questions();
726
-        // make sure system phone question is added to list of questions for this group
727
-        if (! isset($questions[ $phone_question_id ])) {
728
-            $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
729
-        }
730
-
731
-        foreach ($questions as $question_ID => $question) {
732
-            // first we always check for order.
733
-            if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
734
-                // update question order
735
-                $question_group->update_question_order(
736
-                    $question_ID,
737
-                    $this->_req_data['question_orders'][ $question_ID ]
738
-                );
739
-            }
740
-
741
-            // then we always check if adding or removing.
742
-            if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
743
-                $question_group->add_question($question_ID);
744
-            } else {
745
-                // not found, remove it (but only if not a system question for the personal group
746
-                // with the exception of lname system question - we allow removal of it)
747
-                if (in_array(
748
-                    $question->system_ID(),
749
-                    EEM_Question::instance()->required_system_questions_in_system_question_group(
750
-                        $question_group->system_group()
751
-                    )
752
-                )) {
753
-                    continue;
754
-                } else {
755
-                    $question_group->remove_question($question_ID);
756
-                }
757
-            }
758
-        }
759
-        // save new related questions
760
-        if (isset($this->_req_data['questions'])) {
761
-            foreach ($this->_req_data['questions'] as $QST_ID) {
762
-                $question_group->add_question($QST_ID);
763
-                if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
764
-                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
765
-                }
766
-            }
767
-        }
768
-
769
-        if ($success !== false) {
770
-            $msg = $new_question_group
771
-                ? sprintf(
772
-                    esc_html__('The %s has been created', 'event_espresso'),
773
-                    $this->_question_group_model->item_name()
774
-                )
775
-                : sprintf(
776
-                    esc_html__(
777
-                        'The %s has been updated',
778
-                        'event_espresso'
779
-                    ),
780
-                    $this->_question_group_model->item_name()
781
-                );
782
-            EE_Error::add_success($msg);
783
-        }
784
-        $this->_redirect_after_action(
785
-            false,
786
-            '',
787
-            '',
788
-            array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
789
-            true
790
-        );
791
-    }
792
-
793
-
794
-    /**
795
-     * duplicates a question and all its question options and redirects to the new question.
796
-     *
797
-     * @return void
798
-     * @throws EE_Error
799
-     * @throws InvalidArgumentException
800
-     * @throws ReflectionException
801
-     * @throws InvalidDataTypeException
802
-     * @throws InvalidInterfaceException
803
-     */
804
-    public function _duplicate_question()
805
-    {
806
-        $question_ID = (int) $this->_req_data['QST_ID'];
807
-        $question = EEM_Question::instance()->get_one_by_ID($question_ID);
808
-        if ($question instanceof EE_Question) {
809
-            $new_question = $question->duplicate();
810
-            if ($new_question instanceof EE_Question) {
811
-                $this->_redirect_after_action(
812
-                    true,
813
-                    esc_html__('Question', 'event_espresso'),
814
-                    esc_html__('Duplicated', 'event_espresso'),
815
-                    array('action' => 'edit_question', 'QST_ID' => $new_question->ID()),
816
-                    true
817
-                );
818
-            } else {
819
-                global $wpdb;
820
-                EE_Error::add_error(
821
-                    sprintf(
822
-                        esc_html__(
823
-                            'Could not duplicate question with ID %1$d because: %2$s',
824
-                            'event_espresso'
825
-                        ),
826
-                        $question_ID,
827
-                        $wpdb->last_error
828
-                    ),
829
-                    __FILE__,
830
-                    __FUNCTION__,
831
-                    __LINE__
832
-                );
833
-                $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
834
-            }
835
-        } else {
836
-            EE_Error::add_error(
837
-                sprintf(
838
-                    esc_html__(
839
-                        'Could not duplicate question with ID %d because it didn\'t exist!',
840
-                        'event_espresso'
841
-                    ),
842
-                    $question_ID
843
-                ),
844
-                __FILE__,
845
-                __FUNCTION__,
846
-                __LINE__
847
-            );
848
-            $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
849
-        }
850
-    }
851
-
852
-
853
-    /**
854
-     * @param bool $trash
855
-     * @throws EE_Error
856
-     */
857
-    protected function _trash_or_restore_question_groups($trash = true)
858
-    {
859
-        $this->_trash_or_restore_items($this->_question_group_model, $trash);
860
-    }
861
-
862
-
863
-    /**
864
-     *_trash_question
865
-     *
866
-     * @return void
867
-     * @throws EE_Error
868
-     */
869
-    protected function _trash_question()
870
-    {
871
-        $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
872
-        $query_args = array('action' => 'default', 'status' => 'all');
873
-        $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
874
-    }
875
-
876
-
877
-    /**
878
-     * @param bool $trash
879
-     * @throws EE_Error
880
-     */
881
-    protected function _trash_or_restore_questions($trash = true)
882
-    {
883
-        $this->_trash_or_restore_items($this->_question_model, $trash);
884
-    }
885
-
886
-
887
-    /**
888
-     * Internally used to delete or restore items, using the request data. Meant to be
889
-     * flexible between question or question groups
890
-     *
891
-     * @param EEM_Soft_Delete_Base $model
892
-     * @param boolean              $trash whether to trash or restore
893
-     * @throws EE_Error
894
-     */
895
-    private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
896
-    {
897
-
898
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
899
-
900
-        $success = 1;
901
-        // Checkboxes
902
-        // echo "trash $trash";
903
-        // var_dump($this->_req_data['checkbox']);die;
904
-        if (isset($this->_req_data['checkbox'])) {
905
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
906
-                // if array has more than one element than success message should be plural
907
-                $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
908
-                // cycle thru bulk action checkboxes
909
-                while (list($ID, $value) = each($this->_req_data['checkbox'])) {
910
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
911
-                        $success = 0;
912
-                    }
913
-                }
914
-            } else {
915
-                // grab single id and delete
916
-                $ID = absint($this->_req_data['checkbox']);
917
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
918
-                    $success = 0;
919
-                }
920
-            }
921
-        } else {
922
-            // delete via trash link
923
-            // grab single id and delete
924
-            $ID = absint($this->_req_data[ $model->primary_key_name() ]);
925
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
926
-                $success = 0;
927
-            }
928
-        }
929
-
930
-
931
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
932
-        // echo "action :$action";
933
-        // $action = 'questions' ? 'default' : $action;
934
-        if ($trash) {
935
-            $action_desc = 'trashed';
936
-            $status = 'trash';
937
-        } else {
938
-            $action_desc = 'restored';
939
-            $status = 'all';
940
-        }
941
-        $this->_redirect_after_action(
942
-            $success,
943
-            $model->item_name($success),
944
-            $action_desc,
945
-            array('action' => $action, 'status' => $status)
946
-        );
947
-    }
948
-
949
-
950
-    /**
951
-     * @param            $per_page
952
-     * @param int        $current_page
953
-     * @param bool|false $count
954
-     * @return EE_Soft_Delete_Base_Class[]|int
955
-     * @throws EE_Error
956
-     * @throws InvalidArgumentException
957
-     * @throws InvalidDataTypeException
958
-     * @throws InvalidInterfaceException
959
-     */
960
-    public function get_trashed_questions($per_page, $current_page = 1, $count = false)
961
-    {
962
-        $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
963
-
964
-        if ($count) {
965
-            // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
966
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
967
-            $results = $this->_question_model->count_deleted($where);
968
-        } else {
969
-            // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
970
-            $results = $this->_question_model->get_all_deleted($query_params);
971
-        }
972
-        return $results;
973
-    }
974
-
975
-
976
-    /**
977
-     * @param            $per_page
978
-     * @param int        $current_page
979
-     * @param bool|false $count
980
-     * @return EE_Soft_Delete_Base_Class[]|int
981
-     * @throws EE_Error
982
-     * @throws InvalidArgumentException
983
-     * @throws InvalidDataTypeException
984
-     * @throws InvalidInterfaceException
985
-     */
986
-    public function get_question_groups($per_page, $current_page = 1, $count = false)
987
-    {
988
-        $questionGroupModel = EEM_Question_Group::instance();
989
-        $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
990
-        if ($count) {
991
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
992
-            $results = $questionGroupModel->count($where);
993
-        } else {
994
-            $results = $questionGroupModel->get_all($query_params);
995
-        }
996
-        return $results;
997
-    }
998
-
999
-
1000
-    /**
1001
-     * @param      $per_page
1002
-     * @param int  $current_page
1003
-     * @param bool $count
1004
-     * @return EE_Soft_Delete_Base_Class[]|int
1005
-     * @throws EE_Error
1006
-     * @throws InvalidArgumentException
1007
-     * @throws InvalidDataTypeException
1008
-     * @throws InvalidInterfaceException
1009
-     */
1010
-    public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
1011
-    {
1012
-        $questionGroupModel = EEM_Question_Group::instance();
1013
-        $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
1014
-        if ($count) {
1015
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
1016
-            $query_params['limit'] = null;
1017
-            $results = $questionGroupModel->count_deleted($where);
1018
-        } else {
1019
-            $results = $questionGroupModel->get_all_deleted($query_params);
1020
-        }
1021
-        return $results;
1022
-    }
1023
-
1024
-
1025
-    /**
1026
-     * method for performing updates to question order
1027
-     *
1028
-     * @return void results array
1029
-     * @throws EE_Error
1030
-     * @throws InvalidArgumentException
1031
-     * @throws InvalidDataTypeException
1032
-     * @throws InvalidInterfaceException
1033
-     */
1034
-    public function update_question_group_order()
1035
-    {
1036
-
1037
-        $success = esc_html__('Question group order was updated successfully.', 'event_espresso');
1038
-
1039
-        // grab our row IDs
1040
-        $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
1041
-            ? explode(',', rtrim($this->_req_data['row_ids'], ','))
1042
-            : array();
1043
-
1044
-        $perpage = ! empty($this->_req_data['perpage'])
1045
-            ? (int) $this->_req_data['perpage']
1046
-            : null;
1047
-        $curpage = ! empty($this->_req_data['curpage'])
1048
-            ? (int) $this->_req_data['curpage']
1049
-            : null;
1050
-
1051
-        if (! empty($row_ids)) {
1052
-            // figure out where we start the row_id count at for the current page.
1053
-            $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1054
-
1055
-            $row_count = count($row_ids);
1056
-            for ($i = 0; $i < $row_count; $i++) {
1057
-                // Update the questions when re-ordering
1058
-                $updated = EEM_Question_Group::instance()->update(
1059
-                    array('QSG_order' => $qsgcount),
1060
-                    array(array('QSG_ID' => $row_ids[ $i ]))
1061
-                );
1062
-                if ($updated === false) {
1063
-                    $success = false;
1064
-                }
1065
-                $qsgcount++;
1066
-            }
1067
-        } else {
1068
-            $success = false;
1069
-        }
1070
-
1071
-        $errors = ! $success
1072
-            ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
1073
-            : false;
1074
-
1075
-        echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
1076
-        die();
1077
-    }
1078
-
1079
-
1080
-
1081
-    /***************************************       REGISTRATION SETTINGS       ***************************************/
1082
-
1083
-
1084
-    /**
1085
-     * @throws DomainException
1086
-     * @throws EE_Error
1087
-     * @throws InvalidArgumentException
1088
-     * @throws InvalidDataTypeException
1089
-     * @throws InvalidInterfaceException
1090
-     */
1091
-    protected function _reg_form_settings()
1092
-    {
1093
-        $this->_template_args['values'] = $this->_yes_no_values;
1094
-        add_action(
1095
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1096
-            array($this, 'email_validation_settings_form'),
1097
-            2
1098
-        );
1099
-        $this->_template_args = (array) apply_filters(
1100
-            'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
1101
-            $this->_template_args
1102
-        );
1103
-        $this->_set_add_edit_form_tags('update_reg_form_settings');
1104
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1105
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1106
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1107
-            $this->_template_args,
1108
-            true
1109
-        );
1110
-        $this->display_admin_page_with_sidebar();
1111
-    }
1112
-
1113
-
1114
-    /**
1115
-     * @return void
1116
-     * @throws EE_Error
1117
-     * @throws InvalidArgumentException
1118
-     * @throws ReflectionException
1119
-     * @throws InvalidDataTypeException
1120
-     * @throws InvalidInterfaceException
1121
-     */
1122
-    protected function _update_reg_form_settings()
1123
-    {
1124
-        EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
1125
-            EE_Registry::instance()->CFG->registration
1126
-        );
1127
-        EE_Registry::instance()->CFG->registration = apply_filters(
1128
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
1129
-            EE_Registry::instance()->CFG->registration
1130
-        );
1131
-        $success = $this->_update_espresso_configuration(
1132
-            esc_html__('Registration Form Options', 'event_espresso'),
1133
-            EE_Registry::instance()->CFG,
1134
-            __FILE__,
1135
-            __FUNCTION__,
1136
-            __LINE__
1137
-        );
1138
-        $this->_redirect_after_action(
1139
-            $success,
1140
-            esc_html__('Registration Form Options', 'event_espresso'),
1141
-            'updated',
1142
-            array('action' => 'view_reg_form_settings')
1143
-        );
1144
-    }
1145
-
1146
-
1147
-    /**
1148
-     * @return void
1149
-     * @throws EE_Error
1150
-     * @throws InvalidArgumentException
1151
-     * @throws InvalidDataTypeException
1152
-     * @throws InvalidInterfaceException
1153
-     */
1154
-    public function email_validation_settings_form()
1155
-    {
1156
-        echo $this->_email_validation_settings_form()->get_html();
1157
-    }
1158
-
1159
-
1160
-    /**
1161
-     * _email_validation_settings_form
1162
-     *
1163
-     * @access protected
1164
-     * @return EE_Form_Section_Proper
1165
-     * @throws \EE_Error
1166
-     */
1167
-    protected function _email_validation_settings_form()
1168
-    {
1169
-        return new EE_Form_Section_Proper(
1170
-            array(
1171
-                'name'            => 'email_validation_settings',
1172
-                'html_id'         => 'email_validation_settings',
1173
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1174
-                'subsections'     => apply_filters(
1175
-                    'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
1176
-                    array(
1177
-                        'email_validation_hdr'   => new EE_Form_Section_HTML(
1178
-                            EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
1179
-                        ),
1180
-                        'email_validation_level' => new EE_Select_Input(
1181
-                            array(
1182
-                                'basic'      => esc_html__('Basic', 'event_espresso'),
1183
-                                'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
1184
-                                'i18n'       => esc_html__('International', 'event_espresso'),
1185
-                                'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
1186
-                            ),
1187
-                            array(
1188
-                                'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
1189
-                                                     . EEH_Template::get_help_tab_link('email_validation_info'),
1190
-                                'html_help_text'  => esc_html__(
1191
-                                    'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.',
1192
-                                    'event_espresso'
1193
-                                ),
1194
-                                'default'         => isset(
1195
-                                    EE_Registry::instance()->CFG->registration->email_validation_level
1196
-                                )
1197
-                                    ? EE_Registry::instance()->CFG->registration->email_validation_level
1198
-                                    : 'wp_default',
1199
-                                'required'        => false,
1200
-                            )
1201
-                        ),
1202
-                    )
1203
-                ),
1204
-            )
1205
-        );
1206
-    }
1207
-
1208
-
1209
-    /**
1210
-     * @param EE_Registration_Config $EE_Registration_Config
1211
-     * @return EE_Registration_Config
1212
-     * @throws EE_Error
1213
-     * @throws InvalidArgumentException
1214
-     * @throws ReflectionException
1215
-     * @throws InvalidDataTypeException
1216
-     * @throws InvalidInterfaceException
1217
-     */
1218
-    public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1219
-    {
1220
-        $prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1221
-        try {
1222
-            $email_validation_settings_form = $this->_email_validation_settings_form();
1223
-            // if not displaying a form, then check for form submission
1224
-            if ($email_validation_settings_form->was_submitted()) {
1225
-                // capture form data
1226
-                $email_validation_settings_form->receive_form_submission();
1227
-                // validate form data
1228
-                if ($email_validation_settings_form->is_valid()) {
1229
-                    // grab validated data from form
1230
-                    $valid_data = $email_validation_settings_form->valid_data();
1231
-                    if (isset($valid_data['email_validation_level'])) {
1232
-                        $email_validation_level = $valid_data['email_validation_level'];
1233
-                        // now if they want to use international email addresses
1234
-                        if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1235
-                            // in case we need to reset their email validation level,
1236
-                            // make sure that the previous value wasn't already set to one of the i18n options.
1237
-                            if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1238
-                                // if so, then reset it back to "basic" since that is the only other option that,
1239
-                                // despite offering poor validation, supports i18n email addresses
1240
-                                $prev_email_validation_level = 'basic';
1241
-                            }
1242
-                            // confirm our i18n email validation will work on the server
1243
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1244
-                                // or reset email validation level to previous value
1245
-                                $email_validation_level = $prev_email_validation_level;
1246
-                            }
1247
-                        }
1248
-                        $EE_Registration_Config->email_validation_level = $email_validation_level;
1249
-                    } else {
1250
-                        EE_Error::add_error(
1251
-                            esc_html__(
1252
-                                'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1253
-                                'event_espresso'
1254
-                            ),
1255
-                            __FILE__,
1256
-                            __FUNCTION__,
1257
-                            __LINE__
1258
-                        );
1259
-                    }
1260
-                } else {
1261
-                    if ($email_validation_settings_form->submission_error_message() !== '') {
1262
-                        EE_Error::add_error(
1263
-                            $email_validation_settings_form->submission_error_message(),
1264
-                            __FILE__,
1265
-                            __FUNCTION__,
1266
-                            __LINE__
1267
-                        );
1268
-                    }
1269
-                }
1270
-            }
1271
-        } catch (EE_Error $e) {
1272
-            $e->get_error();
1273
-        }
1274
-        return $EE_Registration_Config;
1275
-    }
1276
-
1277
-
1278
-    /**
1279
-     * confirms that the server's PHP version has the PCRE module enabled,
1280
-     * and that the PCRE version works with our i18n email validation
1281
-     *
1282
-     * @param EE_Registration_Config $EE_Registration_Config
1283
-     * @param string                 $email_validation_level
1284
-     * @return bool
1285
-     */
1286
-    private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1287
-    {
1288
-        // first check that PCRE is enabled
1289
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1290
-            EE_Error::add_error(
1291
-                sprintf(
1292
-                    esc_html__(
1293
-                        'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.',
1294
-                        'event_espresso'
1295
-                    ),
1296
-                    '<br />'
1297
-                ),
1298
-                __FILE__,
1299
-                __FUNCTION__,
1300
-                __LINE__
1301
-            );
1302
-            return false;
1303
-        } else {
1304
-            // PCRE support is enabled, but let's still
1305
-            // perform a test to see if the server will support it.
1306
-            // but first, save the updated validation level to the config,
1307
-            // so that the validation strategy picks it up.
1308
-            // this will get bumped back down if it doesn't work
1309
-            $EE_Registration_Config->email_validation_level = $email_validation_level;
1310
-            try {
1311
-                $email_validator = new EE_Email_Validation_Strategy();
1312
-                $i18n_email_address = apply_filters(
1313
-                    'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1314
-                    'jägerjü[email protected]'
1315
-                );
1316
-                $email_validator->validate($i18n_email_address);
1317
-            } catch (Exception $e) {
1318
-                EE_Error::add_error(
1319
-                    sprintf(
1320
-                        esc_html__(
1321
-                            'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s',
1322
-                            'event_espresso'
1323
-                        ),
1324
-                        '<br />',
1325
-                        '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>'
1326
-                    ),
1327
-                    __FILE__,
1328
-                    __FUNCTION__,
1329
-                    __LINE__
1330
-                );
1331
-                return false;
1332
-            }
1333
-        }
1334
-        return true;
1335
-    }
17
+	/**
18
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
19
+	 */
20
+	public function __construct($routing = true)
21
+	{
22
+		define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/');
23
+		define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/');
24
+		define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
25
+		define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/');
26
+		define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
27
+		parent::__construct($routing);
28
+	}
29
+
30
+
31
+	/**
32
+	 * @return void
33
+	 */
34
+	protected function _extend_page_config()
35
+	{
36
+		$this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
37
+		$qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID'])
38
+			? $this->_req_data['QST_ID'] : 0;
39
+		$qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID'])
40
+			? $this->_req_data['QSG_ID'] : 0;
41
+
42
+		$new_page_routes = array(
43
+			'question_groups'    => array(
44
+				'func'       => '_question_groups_overview_list_table',
45
+				'capability' => 'ee_read_question_groups',
46
+			),
47
+			'add_question'       => array(
48
+				'func'       => '_edit_question',
49
+				'capability' => 'ee_edit_questions',
50
+			),
51
+			'insert_question'    => array(
52
+				'func'       => '_insert_or_update_question',
53
+				'args'       => array('new_question' => true),
54
+				'capability' => 'ee_edit_questions',
55
+				'noheader'   => true,
56
+			),
57
+			'duplicate_question' => array(
58
+				'func'       => '_duplicate_question',
59
+				'capability' => 'ee_edit_questions',
60
+				'noheader'   => true,
61
+			),
62
+			'trash_question'     => array(
63
+				'func'       => '_trash_question',
64
+				'capability' => 'ee_delete_question',
65
+				'obj_id'     => $qst_id,
66
+				'noheader'   => true,
67
+			),
68
+
69
+			'restore_question' => array(
70
+				'func'       => '_trash_or_restore_questions',
71
+				'capability' => 'ee_delete_question',
72
+				'obj_id'     => $qst_id,
73
+				'args'       => array('trash' => false),
74
+				'noheader'   => true,
75
+			),
76
+
77
+			'delete_question' => array(
78
+				'func'       => '_delete_question',
79
+				'capability' => 'ee_delete_question',
80
+				'obj_id'     => $qst_id,
81
+				'noheader'   => true,
82
+			),
83
+
84
+			'trash_questions' => array(
85
+				'func'       => '_trash_or_restore_questions',
86
+				'capability' => 'ee_delete_questions',
87
+				'args'       => array('trash' => true),
88
+				'noheader'   => true,
89
+			),
90
+
91
+			'restore_questions' => array(
92
+				'func'       => '_trash_or_restore_questions',
93
+				'capability' => 'ee_delete_questions',
94
+				'args'       => array('trash' => false),
95
+				'noheader'   => true,
96
+			),
97
+
98
+			'delete_questions' => array(
99
+				'func'       => '_delete_questions',
100
+				'args'       => array(),
101
+				'capability' => 'ee_delete_questions',
102
+				'noheader'   => true,
103
+			),
104
+
105
+			'add_question_group' => array(
106
+				'func'       => '_edit_question_group',
107
+				'capability' => 'ee_edit_question_groups',
108
+			),
109
+
110
+			'edit_question_group' => array(
111
+				'func'       => '_edit_question_group',
112
+				'capability' => 'ee_edit_question_group',
113
+				'obj_id'     => $qsg_id,
114
+				'args'       => array('edit'),
115
+			),
116
+
117
+			'delete_question_groups' => array(
118
+				'func'       => '_delete_question_groups',
119
+				'capability' => 'ee_delete_question_groups',
120
+				'noheader'   => true,
121
+			),
122
+
123
+			'delete_question_group' => array(
124
+				'func'       => '_delete_question_groups',
125
+				'capability' => 'ee_delete_question_group',
126
+				'obj_id'     => $qsg_id,
127
+				'noheader'   => true,
128
+			),
129
+
130
+			'trash_question_group' => array(
131
+				'func'       => '_trash_or_restore_question_groups',
132
+				'args'       => array('trash' => true),
133
+				'capability' => 'ee_delete_question_group',
134
+				'obj_id'     => $qsg_id,
135
+				'noheader'   => true,
136
+			),
137
+
138
+			'restore_question_group' => array(
139
+				'func'       => '_trash_or_restore_question_groups',
140
+				'args'       => array('trash' => false),
141
+				'capability' => 'ee_delete_question_group',
142
+				'obj_id'     => $qsg_id,
143
+				'noheader'   => true,
144
+			),
145
+
146
+			'insert_question_group' => array(
147
+				'func'       => '_insert_or_update_question_group',
148
+				'args'       => array('new_question_group' => true),
149
+				'capability' => 'ee_edit_question_groups',
150
+				'noheader'   => true,
151
+			),
152
+
153
+			'update_question_group' => array(
154
+				'func'       => '_insert_or_update_question_group',
155
+				'args'       => array('new_question_group' => false),
156
+				'capability' => 'ee_edit_question_group',
157
+				'obj_id'     => $qsg_id,
158
+				'noheader'   => true,
159
+			),
160
+
161
+			'trash_question_groups' => array(
162
+				'func'       => '_trash_or_restore_question_groups',
163
+				'args'       => array('trash' => true),
164
+				'capability' => 'ee_delete_question_groups',
165
+				'noheader'   => array('trash' => false),
166
+			),
167
+
168
+			'restore_question_groups' => array(
169
+				'func'       => '_trash_or_restore_question_groups',
170
+				'args'       => array('trash' => false),
171
+				'capability' => 'ee_delete_question_groups',
172
+				'noheader'   => true,
173
+			),
174
+
175
+
176
+			'espresso_update_question_group_order' => array(
177
+				'func'       => 'update_question_group_order',
178
+				'capability' => 'ee_edit_question_groups',
179
+				'noheader'   => true,
180
+			),
181
+
182
+			'view_reg_form_settings' => array(
183
+				'func'       => '_reg_form_settings',
184
+				'capability' => 'manage_options',
185
+			),
186
+
187
+			'update_reg_form_settings' => array(
188
+				'func'       => '_update_reg_form_settings',
189
+				'capability' => 'manage_options',
190
+				'noheader'   => true,
191
+			),
192
+		);
193
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
194
+
195
+		$new_page_config = array(
196
+
197
+			'question_groups' => array(
198
+				'nav'           => array(
199
+					'label' => esc_html__('Question Groups', 'event_espresso'),
200
+					'order' => 20,
201
+				),
202
+				'list_table'    => 'Registration_Form_Question_Groups_Admin_List_Table',
203
+				'help_tabs'     => array(
204
+					'registration_form_question_groups_help_tab'                           => array(
205
+						'title'    => esc_html__('Question Groups', 'event_espresso'),
206
+						'filename' => 'registration_form_question_groups',
207
+					),
208
+					'registration_form_question_groups_table_column_headings_help_tab'     => array(
209
+						'title'    => esc_html__('Question Groups Table Column Headings', 'event_espresso'),
210
+						'filename' => 'registration_form_question_groups_table_column_headings',
211
+					),
212
+					'registration_form_question_groups_views_bulk_actions_search_help_tab' => array(
213
+						'title'    => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'),
214
+						'filename' => 'registration_form_question_groups_views_bulk_actions_search',
215
+					),
216
+				),
217
+				'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
218
+				'metaboxes'     => $this->_default_espresso_metaboxes,
219
+				'require_nonce' => false,
220
+				'qtips'         => array(
221
+					'EE_Registration_Form_Tips',
222
+				),
223
+			),
224
+
225
+			'add_question' => array(
226
+				'nav'           => array(
227
+					'label'      => esc_html__('Add Question', 'event_espresso'),
228
+					'order'      => 5,
229
+					'persistent' => false,
230
+				),
231
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
232
+				'help_tabs'     => array(
233
+					'registration_form_add_question_help_tab' => array(
234
+						'title'    => esc_html__('Add Question', 'event_espresso'),
235
+						'filename' => 'registration_form_add_question',
236
+					),
237
+				),
238
+				'help_tour'     => array('Registration_Form_Add_Question_Help_Tour'),
239
+				'require_nonce' => false,
240
+			),
241
+
242
+			'add_question_group' => array(
243
+				'nav'           => array(
244
+					'label'      => esc_html__('Add Question Group', 'event_espresso'),
245
+					'order'      => 5,
246
+					'persistent' => false,
247
+				),
248
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
249
+				'help_tabs'     => array(
250
+					'registration_form_add_question_group_help_tab' => array(
251
+						'title'    => esc_html__('Add Question Group', 'event_espresso'),
252
+						'filename' => 'registration_form_add_question_group',
253
+					),
254
+				),
255
+				'help_tour'     => array('Registration_Form_Add_Question_Group_Help_Tour'),
256
+				'require_nonce' => false,
257
+			),
258
+
259
+			'edit_question_group' => array(
260
+				'nav'           => array(
261
+					'label'      => esc_html__('Edit Question Group', 'event_espresso'),
262
+					'order'      => 5,
263
+					'persistent' => false,
264
+					'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(
265
+						array('question_group_id' => $this->_req_data['question_group_id']),
266
+						$this->_current_page_view_url
267
+					) : $this->_admin_base_url,
268
+				),
269
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
270
+				'help_tabs'     => array(
271
+					'registration_form_edit_question_group_help_tab' => array(
272
+						'title'    => esc_html__('Edit Question Group', 'event_espresso'),
273
+						'filename' => 'registration_form_edit_question_group',
274
+					),
275
+				),
276
+				'help_tour'     => array('Registration_Form_Edit_Question_Group_Help_Tour'),
277
+				'require_nonce' => false,
278
+			),
279
+
280
+			'view_reg_form_settings' => array(
281
+				'nav'           => array(
282
+					'label' => esc_html__('Reg Form Settings', 'event_espresso'),
283
+					'order' => 40,
284
+				),
285
+				'labels'        => array(
286
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
287
+				),
288
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
289
+				'help_tabs'     => array(
290
+					'registration_form_reg_form_settings_help_tab' => array(
291
+						'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
292
+						'filename' => 'registration_form_reg_form_settings',
293
+					),
294
+				),
295
+				'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
296
+				'require_nonce' => false,
297
+			),
298
+
299
+		);
300
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
301
+
302
+		// change the list table we're going to use so it's the NEW list table!
303
+		$this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
304
+
305
+
306
+		// additional labels
307
+		$new_labels = array(
308
+			'add_question'          => esc_html__('Add New Question', 'event_espresso'),
309
+			'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
310
+			'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
311
+			'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
312
+			'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
313
+		);
314
+		$this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
315
+	}
316
+
317
+
318
+	/**
319
+	 * @return void
320
+	 */
321
+	protected function _ajax_hooks()
322
+	{
323
+		add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
324
+	}
325
+
326
+
327
+	/**
328
+	 * @return void
329
+	 */
330
+	public function load_scripts_styles_question_groups()
331
+	{
332
+		wp_enqueue_script('espresso_ajax_table_sorting');
333
+	}
334
+
335
+
336
+	/**
337
+	 * @return void
338
+	 */
339
+	public function load_scripts_styles_add_question_group()
340
+	{
341
+		$this->load_scripts_styles_forms();
342
+		$this->load_sortable_question_script();
343
+	}
344
+
345
+
346
+	/**
347
+	 * @return void
348
+	 */
349
+	public function load_scripts_styles_edit_question_group()
350
+	{
351
+		$this->load_scripts_styles_forms();
352
+		$this->load_sortable_question_script();
353
+	}
354
+
355
+
356
+	/**
357
+	 * registers and enqueues script for questions
358
+	 *
359
+	 * @return void
360
+	 */
361
+	public function load_sortable_question_script()
362
+	{
363
+		wp_register_script(
364
+			'ee-question-sortable',
365
+			REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
366
+			array('jquery-ui-sortable'),
367
+			EVENT_ESPRESSO_VERSION,
368
+			true
369
+		);
370
+		wp_enqueue_script('ee-question-sortable');
371
+	}
372
+
373
+
374
+	/**
375
+	 * @return void
376
+	 */
377
+	protected function _set_list_table_views_default()
378
+	{
379
+		$this->_views = array(
380
+			'all' => array(
381
+				'slug'        => 'all',
382
+				'label'       => esc_html__('View All Questions', 'event_espresso'),
383
+				'count'       => 0,
384
+				'bulk_action' => array(
385
+					'trash_questions' => esc_html__('Trash', 'event_espresso'),
386
+				),
387
+			),
388
+		);
389
+
390
+		if (EE_Registry::instance()->CAP->current_user_can(
391
+			'ee_delete_questions',
392
+			'espresso_registration_form_trash_questions'
393
+		)
394
+		) {
395
+			$this->_views['trash'] = array(
396
+				'slug'        => 'trash',
397
+				'label'       => esc_html__('Trash', 'event_espresso'),
398
+				'count'       => 0,
399
+				'bulk_action' => array(
400
+					'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
401
+					'restore_questions' => esc_html__('Restore', 'event_espresso'),
402
+				),
403
+			);
404
+		}
405
+	}
406
+
407
+
408
+	/**
409
+	 * @return void
410
+	 */
411
+	protected function _set_list_table_views_question_groups()
412
+	{
413
+		$this->_views = array(
414
+			'all' => array(
415
+				'slug'        => 'all',
416
+				'label'       => esc_html__('All', 'event_espresso'),
417
+				'count'       => 0,
418
+				'bulk_action' => array(
419
+					'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
420
+				),
421
+			),
422
+		);
423
+
424
+		if (EE_Registry::instance()->CAP->current_user_can(
425
+			'ee_delete_question_groups',
426
+			'espresso_registration_form_trash_question_groups'
427
+		)
428
+		) {
429
+			$this->_views['trash'] = array(
430
+				'slug'        => 'trash',
431
+				'label'       => esc_html__('Trash', 'event_espresso'),
432
+				'count'       => 0,
433
+				'bulk_action' => array(
434
+					'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
435
+					'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
436
+				),
437
+			);
438
+		}
439
+	}
440
+
441
+
442
+	/**
443
+	 * @return void
444
+	 * @throws EE_Error
445
+	 * @throws InvalidArgumentException
446
+	 * @throws InvalidDataTypeException
447
+	 * @throws InvalidInterfaceException
448
+	 */
449
+	protected function _questions_overview_list_table()
450
+	{
451
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
452
+			'add_question',
453
+			'add_question',
454
+			array(),
455
+			'add-new-h2'
456
+		);
457
+		parent::_questions_overview_list_table();
458
+	}
459
+
460
+
461
+	/**
462
+	 * @return void
463
+	 * @throws DomainException
464
+	 * @throws EE_Error
465
+	 * @throws InvalidArgumentException
466
+	 * @throws InvalidDataTypeException
467
+	 * @throws InvalidInterfaceException
468
+	 */
469
+	protected function _question_groups_overview_list_table()
470
+	{
471
+		$this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
472
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
473
+			'add_question_group',
474
+			'add_question_group',
475
+			array(),
476
+			'add-new-h2'
477
+		);
478
+		$this->display_admin_list_table_page_with_sidebar();
479
+	}
480
+
481
+
482
+	/**
483
+	 * @return void
484
+	 * @throws EE_Error
485
+	 * @throws InvalidArgumentException
486
+	 * @throws InvalidDataTypeException
487
+	 * @throws InvalidInterfaceException
488
+	 */
489
+	protected function _delete_question()
490
+	{
491
+		$success = $this->_delete_items($this->_question_model);
492
+		$this->_redirect_after_action(
493
+			$success,
494
+			$this->_question_model->item_name($success),
495
+			'deleted',
496
+			array('action' => 'default', 'status' => 'all')
497
+		);
498
+	}
499
+
500
+
501
+	/**
502
+	 * @return void
503
+	 * @throws EE_Error
504
+	 * @throws InvalidArgumentException
505
+	 * @throws InvalidDataTypeException
506
+	 * @throws InvalidInterfaceException
507
+	 */
508
+	protected function _delete_questions()
509
+	{
510
+		$success = $this->_delete_items($this->_question_model);
511
+		$this->_redirect_after_action(
512
+			$success,
513
+			$this->_question_model->item_name($success),
514
+			'deleted permanently',
515
+			array('action' => 'default', 'status' => 'trash')
516
+		);
517
+	}
518
+
519
+
520
+	/**
521
+	 * Performs the deletion of a single or multiple questions or question groups.
522
+	 *
523
+	 * @param EEM_Soft_Delete_Base $model
524
+	 * @return int number of items deleted permanently
525
+	 * @throws EE_Error
526
+	 * @throws InvalidArgumentException
527
+	 * @throws InvalidDataTypeException
528
+	 * @throws InvalidInterfaceException
529
+	 */
530
+	private function _delete_items(EEM_Soft_Delete_Base $model)
531
+	{
532
+		$success = 0;
533
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
534
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
535
+			// if array has more than one element than success message should be plural
536
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
537
+			// cycle thru bulk action checkboxes
538
+			while (list($ID, $value) = each($this->_req_data['checkbox'])) {
539
+				if (! $this->_delete_item($ID, $model)) {
540
+					$success = 0;
541
+				}
542
+			}
543
+		} elseif (! empty($this->_req_data['QSG_ID'])) {
544
+			$success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
545
+		} elseif (! empty($this->_req_data['QST_ID'])) {
546
+			$success = $this->_delete_item($this->_req_data['QST_ID'], $model);
547
+		} else {
548
+			EE_Error::add_error(
549
+				sprintf(
550
+					esc_html__(
551
+						"No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
552
+						"event_espresso"
553
+					)
554
+				),
555
+				__FILE__,
556
+				__FUNCTION__,
557
+				__LINE__
558
+			);
559
+		}
560
+		return $success;
561
+	}
562
+
563
+
564
+	/**
565
+	 * Deletes the specified question (and its associated question options) or question group
566
+	 *
567
+	 * @param int                  $id
568
+	 * @param EEM_Soft_Delete_Base $model
569
+	 * @return boolean
570
+	 * @throws EE_Error
571
+	 * @throws InvalidArgumentException
572
+	 * @throws InvalidDataTypeException
573
+	 * @throws InvalidInterfaceException
574
+	 */
575
+	protected function _delete_item($id, $model)
576
+	{
577
+		if ($model instanceof EEM_Question) {
578
+			EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
579
+		}
580
+		return $model->delete_permanently_by_ID(absint($id));
581
+	}
582
+
583
+
584
+	/******************************    QUESTION GROUPS    ******************************/
585
+
586
+
587
+	/**
588
+	 * @param string $type
589
+	 * @return void
590
+	 * @throws DomainException
591
+	 * @throws EE_Error
592
+	 * @throws InvalidArgumentException
593
+	 * @throws InvalidDataTypeException
594
+	 * @throws InvalidInterfaceException
595
+	 */
596
+	protected function _edit_question_group($type = 'add')
597
+	{
598
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
599
+		$ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID'])
600
+			? absint($this->_req_data['QSG_ID'])
601
+			: false;
602
+
603
+		switch ($this->_req_action) {
604
+			case 'add_question_group':
605
+				$this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
606
+				break;
607
+			case 'edit_question_group':
608
+				$this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
609
+				break;
610
+			default:
611
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
612
+		}
613
+		// add ID to title if editing
614
+		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
615
+		if ($ID) {
616
+			/** @var EE_Question_Group $questionGroup */
617
+			$questionGroup = $this->_question_group_model->get_one_by_ID($ID);
618
+			$additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
619
+			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
620
+		} else {
621
+			/** @var EE_Question_Group $questionGroup */
622
+			$questionGroup = EEM_Question_Group::instance()->create_default_object();
623
+			$questionGroup->set_order_to_latest();
624
+			$this->_set_add_edit_form_tags('insert_question_group');
625
+		}
626
+		$this->_template_args['values'] = $this->_yes_no_values;
627
+		$this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
628
+		$this->_template_args['QSG_ID'] = $ID ? $ID : true;
629
+		$this->_template_args['question_group'] = $questionGroup;
630
+
631
+		$redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
632
+		$this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
633
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
634
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
635
+			$this->_template_args,
636
+			true
637
+		);
638
+
639
+		// the details template wrapper
640
+		$this->display_admin_page_with_sidebar();
641
+	}
642
+
643
+
644
+	/**
645
+	 * @return void
646
+	 * @throws EE_Error
647
+	 * @throws InvalidArgumentException
648
+	 * @throws InvalidDataTypeException
649
+	 * @throws InvalidInterfaceException
650
+	 */
651
+	protected function _delete_question_groups()
652
+	{
653
+		$success = $this->_delete_items($this->_question_group_model);
654
+		$this->_redirect_after_action(
655
+			$success,
656
+			$this->_question_group_model->item_name($success),
657
+			'deleted permanently',
658
+			array('action' => 'question_groups', 'status' => 'trash')
659
+		);
660
+	}
661
+
662
+
663
+	/**
664
+	 * @param bool $new_question_group
665
+	 * @throws EE_Error
666
+	 * @throws InvalidArgumentException
667
+	 * @throws InvalidDataTypeException
668
+	 * @throws InvalidInterfaceException
669
+	 */
670
+	protected function _insert_or_update_question_group($new_question_group = true)
671
+	{
672
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
673
+		$set_column_values = $this->_set_column_values_for($this->_question_group_model);
674
+		if ($new_question_group) {
675
+			// make sure identifier is unique
676
+			$identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : '';
677
+			$identifier_exists = ! empty($identifier_value)
678
+				? $this->_question_group_model->count([['QSG_identifier' => $set_column_values['QSG_identifier']]]) > 0
679
+				: false;
680
+			if ($identifier_exists) {
681
+				$set_column_values['QSG_identifier'] .= uniqid('id', true);
682
+			}
683
+			$QSG_ID = $this->_question_group_model->insert($set_column_values);
684
+			$success = $QSG_ID ? 1 : 0;
685
+			if ($success === 0) {
686
+				EE_Error::add_error(
687
+					esc_html__('Something went wrong saving the question group.', 'event_espresso'),
688
+					__FILE__,
689
+					__FUNCTION__,
690
+					__LINE__
691
+				);
692
+				$this->_redirect_after_action(
693
+					false,
694
+					'',
695
+					'',
696
+					array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
697
+					true
698
+				);
699
+			}
700
+		} else {
701
+			$QSG_ID = absint($this->_req_data['QSG_ID']);
702
+			unset($set_column_values['QSG_ID']);
703
+			$success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
704
+		}
705
+
706
+		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(
707
+			EEM_Attendee::system_question_phone
708
+		);
709
+		// update the existing related questions
710
+		// BUT FIRST...  delete the phone question from the Question_Group_Question
711
+		// if it is being added to this question group (therefore removed from the existing group)
712
+		if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
713
+			// delete where QST ID = system phone question ID and Question Group ID is NOT this group
714
+			EEM_Question_Group_Question::instance()->delete(
715
+				array(
716
+					array(
717
+						'QST_ID' => $phone_question_id,
718
+						'QSG_ID' => array('!=', $QSG_ID),
719
+					),
720
+				)
721
+			);
722
+		}
723
+		/** @type EE_Question_Group $question_group */
724
+		$question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
725
+		$questions = $question_group->questions();
726
+		// make sure system phone question is added to list of questions for this group
727
+		if (! isset($questions[ $phone_question_id ])) {
728
+			$questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
729
+		}
730
+
731
+		foreach ($questions as $question_ID => $question) {
732
+			// first we always check for order.
733
+			if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
734
+				// update question order
735
+				$question_group->update_question_order(
736
+					$question_ID,
737
+					$this->_req_data['question_orders'][ $question_ID ]
738
+				);
739
+			}
740
+
741
+			// then we always check if adding or removing.
742
+			if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
743
+				$question_group->add_question($question_ID);
744
+			} else {
745
+				// not found, remove it (but only if not a system question for the personal group
746
+				// with the exception of lname system question - we allow removal of it)
747
+				if (in_array(
748
+					$question->system_ID(),
749
+					EEM_Question::instance()->required_system_questions_in_system_question_group(
750
+						$question_group->system_group()
751
+					)
752
+				)) {
753
+					continue;
754
+				} else {
755
+					$question_group->remove_question($question_ID);
756
+				}
757
+			}
758
+		}
759
+		// save new related questions
760
+		if (isset($this->_req_data['questions'])) {
761
+			foreach ($this->_req_data['questions'] as $QST_ID) {
762
+				$question_group->add_question($QST_ID);
763
+				if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
764
+					$question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
765
+				}
766
+			}
767
+		}
768
+
769
+		if ($success !== false) {
770
+			$msg = $new_question_group
771
+				? sprintf(
772
+					esc_html__('The %s has been created', 'event_espresso'),
773
+					$this->_question_group_model->item_name()
774
+				)
775
+				: sprintf(
776
+					esc_html__(
777
+						'The %s has been updated',
778
+						'event_espresso'
779
+					),
780
+					$this->_question_group_model->item_name()
781
+				);
782
+			EE_Error::add_success($msg);
783
+		}
784
+		$this->_redirect_after_action(
785
+			false,
786
+			'',
787
+			'',
788
+			array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
789
+			true
790
+		);
791
+	}
792
+
793
+
794
+	/**
795
+	 * duplicates a question and all its question options and redirects to the new question.
796
+	 *
797
+	 * @return void
798
+	 * @throws EE_Error
799
+	 * @throws InvalidArgumentException
800
+	 * @throws ReflectionException
801
+	 * @throws InvalidDataTypeException
802
+	 * @throws InvalidInterfaceException
803
+	 */
804
+	public function _duplicate_question()
805
+	{
806
+		$question_ID = (int) $this->_req_data['QST_ID'];
807
+		$question = EEM_Question::instance()->get_one_by_ID($question_ID);
808
+		if ($question instanceof EE_Question) {
809
+			$new_question = $question->duplicate();
810
+			if ($new_question instanceof EE_Question) {
811
+				$this->_redirect_after_action(
812
+					true,
813
+					esc_html__('Question', 'event_espresso'),
814
+					esc_html__('Duplicated', 'event_espresso'),
815
+					array('action' => 'edit_question', 'QST_ID' => $new_question->ID()),
816
+					true
817
+				);
818
+			} else {
819
+				global $wpdb;
820
+				EE_Error::add_error(
821
+					sprintf(
822
+						esc_html__(
823
+							'Could not duplicate question with ID %1$d because: %2$s',
824
+							'event_espresso'
825
+						),
826
+						$question_ID,
827
+						$wpdb->last_error
828
+					),
829
+					__FILE__,
830
+					__FUNCTION__,
831
+					__LINE__
832
+				);
833
+				$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
834
+			}
835
+		} else {
836
+			EE_Error::add_error(
837
+				sprintf(
838
+					esc_html__(
839
+						'Could not duplicate question with ID %d because it didn\'t exist!',
840
+						'event_espresso'
841
+					),
842
+					$question_ID
843
+				),
844
+				__FILE__,
845
+				__FUNCTION__,
846
+				__LINE__
847
+			);
848
+			$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
849
+		}
850
+	}
851
+
852
+
853
+	/**
854
+	 * @param bool $trash
855
+	 * @throws EE_Error
856
+	 */
857
+	protected function _trash_or_restore_question_groups($trash = true)
858
+	{
859
+		$this->_trash_or_restore_items($this->_question_group_model, $trash);
860
+	}
861
+
862
+
863
+	/**
864
+	 *_trash_question
865
+	 *
866
+	 * @return void
867
+	 * @throws EE_Error
868
+	 */
869
+	protected function _trash_question()
870
+	{
871
+		$success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
872
+		$query_args = array('action' => 'default', 'status' => 'all');
873
+		$this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
874
+	}
875
+
876
+
877
+	/**
878
+	 * @param bool $trash
879
+	 * @throws EE_Error
880
+	 */
881
+	protected function _trash_or_restore_questions($trash = true)
882
+	{
883
+		$this->_trash_or_restore_items($this->_question_model, $trash);
884
+	}
885
+
886
+
887
+	/**
888
+	 * Internally used to delete or restore items, using the request data. Meant to be
889
+	 * flexible between question or question groups
890
+	 *
891
+	 * @param EEM_Soft_Delete_Base $model
892
+	 * @param boolean              $trash whether to trash or restore
893
+	 * @throws EE_Error
894
+	 */
895
+	private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
896
+	{
897
+
898
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
899
+
900
+		$success = 1;
901
+		// Checkboxes
902
+		// echo "trash $trash";
903
+		// var_dump($this->_req_data['checkbox']);die;
904
+		if (isset($this->_req_data['checkbox'])) {
905
+			if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
906
+				// if array has more than one element than success message should be plural
907
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
908
+				// cycle thru bulk action checkboxes
909
+				while (list($ID, $value) = each($this->_req_data['checkbox'])) {
910
+					if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
911
+						$success = 0;
912
+					}
913
+				}
914
+			} else {
915
+				// grab single id and delete
916
+				$ID = absint($this->_req_data['checkbox']);
917
+				if (! $model->delete_or_restore_by_ID($trash, $ID)) {
918
+					$success = 0;
919
+				}
920
+			}
921
+		} else {
922
+			// delete via trash link
923
+			// grab single id and delete
924
+			$ID = absint($this->_req_data[ $model->primary_key_name() ]);
925
+			if (! $model->delete_or_restore_by_ID($trash, $ID)) {
926
+				$success = 0;
927
+			}
928
+		}
929
+
930
+
931
+		$action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
932
+		// echo "action :$action";
933
+		// $action = 'questions' ? 'default' : $action;
934
+		if ($trash) {
935
+			$action_desc = 'trashed';
936
+			$status = 'trash';
937
+		} else {
938
+			$action_desc = 'restored';
939
+			$status = 'all';
940
+		}
941
+		$this->_redirect_after_action(
942
+			$success,
943
+			$model->item_name($success),
944
+			$action_desc,
945
+			array('action' => $action, 'status' => $status)
946
+		);
947
+	}
948
+
949
+
950
+	/**
951
+	 * @param            $per_page
952
+	 * @param int        $current_page
953
+	 * @param bool|false $count
954
+	 * @return EE_Soft_Delete_Base_Class[]|int
955
+	 * @throws EE_Error
956
+	 * @throws InvalidArgumentException
957
+	 * @throws InvalidDataTypeException
958
+	 * @throws InvalidInterfaceException
959
+	 */
960
+	public function get_trashed_questions($per_page, $current_page = 1, $count = false)
961
+	{
962
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
963
+
964
+		if ($count) {
965
+			// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
966
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
967
+			$results = $this->_question_model->count_deleted($where);
968
+		} else {
969
+			// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
970
+			$results = $this->_question_model->get_all_deleted($query_params);
971
+		}
972
+		return $results;
973
+	}
974
+
975
+
976
+	/**
977
+	 * @param            $per_page
978
+	 * @param int        $current_page
979
+	 * @param bool|false $count
980
+	 * @return EE_Soft_Delete_Base_Class[]|int
981
+	 * @throws EE_Error
982
+	 * @throws InvalidArgumentException
983
+	 * @throws InvalidDataTypeException
984
+	 * @throws InvalidInterfaceException
985
+	 */
986
+	public function get_question_groups($per_page, $current_page = 1, $count = false)
987
+	{
988
+		$questionGroupModel = EEM_Question_Group::instance();
989
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
990
+		if ($count) {
991
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
992
+			$results = $questionGroupModel->count($where);
993
+		} else {
994
+			$results = $questionGroupModel->get_all($query_params);
995
+		}
996
+		return $results;
997
+	}
998
+
999
+
1000
+	/**
1001
+	 * @param      $per_page
1002
+	 * @param int  $current_page
1003
+	 * @param bool $count
1004
+	 * @return EE_Soft_Delete_Base_Class[]|int
1005
+	 * @throws EE_Error
1006
+	 * @throws InvalidArgumentException
1007
+	 * @throws InvalidDataTypeException
1008
+	 * @throws InvalidInterfaceException
1009
+	 */
1010
+	public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
1011
+	{
1012
+		$questionGroupModel = EEM_Question_Group::instance();
1013
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
1014
+		if ($count) {
1015
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
1016
+			$query_params['limit'] = null;
1017
+			$results = $questionGroupModel->count_deleted($where);
1018
+		} else {
1019
+			$results = $questionGroupModel->get_all_deleted($query_params);
1020
+		}
1021
+		return $results;
1022
+	}
1023
+
1024
+
1025
+	/**
1026
+	 * method for performing updates to question order
1027
+	 *
1028
+	 * @return void results array
1029
+	 * @throws EE_Error
1030
+	 * @throws InvalidArgumentException
1031
+	 * @throws InvalidDataTypeException
1032
+	 * @throws InvalidInterfaceException
1033
+	 */
1034
+	public function update_question_group_order()
1035
+	{
1036
+
1037
+		$success = esc_html__('Question group order was updated successfully.', 'event_espresso');
1038
+
1039
+		// grab our row IDs
1040
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
1041
+			? explode(',', rtrim($this->_req_data['row_ids'], ','))
1042
+			: array();
1043
+
1044
+		$perpage = ! empty($this->_req_data['perpage'])
1045
+			? (int) $this->_req_data['perpage']
1046
+			: null;
1047
+		$curpage = ! empty($this->_req_data['curpage'])
1048
+			? (int) $this->_req_data['curpage']
1049
+			: null;
1050
+
1051
+		if (! empty($row_ids)) {
1052
+			// figure out where we start the row_id count at for the current page.
1053
+			$qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1054
+
1055
+			$row_count = count($row_ids);
1056
+			for ($i = 0; $i < $row_count; $i++) {
1057
+				// Update the questions when re-ordering
1058
+				$updated = EEM_Question_Group::instance()->update(
1059
+					array('QSG_order' => $qsgcount),
1060
+					array(array('QSG_ID' => $row_ids[ $i ]))
1061
+				);
1062
+				if ($updated === false) {
1063
+					$success = false;
1064
+				}
1065
+				$qsgcount++;
1066
+			}
1067
+		} else {
1068
+			$success = false;
1069
+		}
1070
+
1071
+		$errors = ! $success
1072
+			? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
1073
+			: false;
1074
+
1075
+		echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
1076
+		die();
1077
+	}
1078
+
1079
+
1080
+
1081
+	/***************************************       REGISTRATION SETTINGS       ***************************************/
1082
+
1083
+
1084
+	/**
1085
+	 * @throws DomainException
1086
+	 * @throws EE_Error
1087
+	 * @throws InvalidArgumentException
1088
+	 * @throws InvalidDataTypeException
1089
+	 * @throws InvalidInterfaceException
1090
+	 */
1091
+	protected function _reg_form_settings()
1092
+	{
1093
+		$this->_template_args['values'] = $this->_yes_no_values;
1094
+		add_action(
1095
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1096
+			array($this, 'email_validation_settings_form'),
1097
+			2
1098
+		);
1099
+		$this->_template_args = (array) apply_filters(
1100
+			'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
1101
+			$this->_template_args
1102
+		);
1103
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
1104
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1105
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1106
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1107
+			$this->_template_args,
1108
+			true
1109
+		);
1110
+		$this->display_admin_page_with_sidebar();
1111
+	}
1112
+
1113
+
1114
+	/**
1115
+	 * @return void
1116
+	 * @throws EE_Error
1117
+	 * @throws InvalidArgumentException
1118
+	 * @throws ReflectionException
1119
+	 * @throws InvalidDataTypeException
1120
+	 * @throws InvalidInterfaceException
1121
+	 */
1122
+	protected function _update_reg_form_settings()
1123
+	{
1124
+		EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
1125
+			EE_Registry::instance()->CFG->registration
1126
+		);
1127
+		EE_Registry::instance()->CFG->registration = apply_filters(
1128
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
1129
+			EE_Registry::instance()->CFG->registration
1130
+		);
1131
+		$success = $this->_update_espresso_configuration(
1132
+			esc_html__('Registration Form Options', 'event_espresso'),
1133
+			EE_Registry::instance()->CFG,
1134
+			__FILE__,
1135
+			__FUNCTION__,
1136
+			__LINE__
1137
+		);
1138
+		$this->_redirect_after_action(
1139
+			$success,
1140
+			esc_html__('Registration Form Options', 'event_espresso'),
1141
+			'updated',
1142
+			array('action' => 'view_reg_form_settings')
1143
+		);
1144
+	}
1145
+
1146
+
1147
+	/**
1148
+	 * @return void
1149
+	 * @throws EE_Error
1150
+	 * @throws InvalidArgumentException
1151
+	 * @throws InvalidDataTypeException
1152
+	 * @throws InvalidInterfaceException
1153
+	 */
1154
+	public function email_validation_settings_form()
1155
+	{
1156
+		echo $this->_email_validation_settings_form()->get_html();
1157
+	}
1158
+
1159
+
1160
+	/**
1161
+	 * _email_validation_settings_form
1162
+	 *
1163
+	 * @access protected
1164
+	 * @return EE_Form_Section_Proper
1165
+	 * @throws \EE_Error
1166
+	 */
1167
+	protected function _email_validation_settings_form()
1168
+	{
1169
+		return new EE_Form_Section_Proper(
1170
+			array(
1171
+				'name'            => 'email_validation_settings',
1172
+				'html_id'         => 'email_validation_settings',
1173
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1174
+				'subsections'     => apply_filters(
1175
+					'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
1176
+					array(
1177
+						'email_validation_hdr'   => new EE_Form_Section_HTML(
1178
+							EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
1179
+						),
1180
+						'email_validation_level' => new EE_Select_Input(
1181
+							array(
1182
+								'basic'      => esc_html__('Basic', 'event_espresso'),
1183
+								'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
1184
+								'i18n'       => esc_html__('International', 'event_espresso'),
1185
+								'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
1186
+							),
1187
+							array(
1188
+								'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
1189
+													 . EEH_Template::get_help_tab_link('email_validation_info'),
1190
+								'html_help_text'  => esc_html__(
1191
+									'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.',
1192
+									'event_espresso'
1193
+								),
1194
+								'default'         => isset(
1195
+									EE_Registry::instance()->CFG->registration->email_validation_level
1196
+								)
1197
+									? EE_Registry::instance()->CFG->registration->email_validation_level
1198
+									: 'wp_default',
1199
+								'required'        => false,
1200
+							)
1201
+						),
1202
+					)
1203
+				),
1204
+			)
1205
+		);
1206
+	}
1207
+
1208
+
1209
+	/**
1210
+	 * @param EE_Registration_Config $EE_Registration_Config
1211
+	 * @return EE_Registration_Config
1212
+	 * @throws EE_Error
1213
+	 * @throws InvalidArgumentException
1214
+	 * @throws ReflectionException
1215
+	 * @throws InvalidDataTypeException
1216
+	 * @throws InvalidInterfaceException
1217
+	 */
1218
+	public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1219
+	{
1220
+		$prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1221
+		try {
1222
+			$email_validation_settings_form = $this->_email_validation_settings_form();
1223
+			// if not displaying a form, then check for form submission
1224
+			if ($email_validation_settings_form->was_submitted()) {
1225
+				// capture form data
1226
+				$email_validation_settings_form->receive_form_submission();
1227
+				// validate form data
1228
+				if ($email_validation_settings_form->is_valid()) {
1229
+					// grab validated data from form
1230
+					$valid_data = $email_validation_settings_form->valid_data();
1231
+					if (isset($valid_data['email_validation_level'])) {
1232
+						$email_validation_level = $valid_data['email_validation_level'];
1233
+						// now if they want to use international email addresses
1234
+						if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1235
+							// in case we need to reset their email validation level,
1236
+							// make sure that the previous value wasn't already set to one of the i18n options.
1237
+							if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1238
+								// if so, then reset it back to "basic" since that is the only other option that,
1239
+								// despite offering poor validation, supports i18n email addresses
1240
+								$prev_email_validation_level = 'basic';
1241
+							}
1242
+							// confirm our i18n email validation will work on the server
1243
+							if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1244
+								// or reset email validation level to previous value
1245
+								$email_validation_level = $prev_email_validation_level;
1246
+							}
1247
+						}
1248
+						$EE_Registration_Config->email_validation_level = $email_validation_level;
1249
+					} else {
1250
+						EE_Error::add_error(
1251
+							esc_html__(
1252
+								'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1253
+								'event_espresso'
1254
+							),
1255
+							__FILE__,
1256
+							__FUNCTION__,
1257
+							__LINE__
1258
+						);
1259
+					}
1260
+				} else {
1261
+					if ($email_validation_settings_form->submission_error_message() !== '') {
1262
+						EE_Error::add_error(
1263
+							$email_validation_settings_form->submission_error_message(),
1264
+							__FILE__,
1265
+							__FUNCTION__,
1266
+							__LINE__
1267
+						);
1268
+					}
1269
+				}
1270
+			}
1271
+		} catch (EE_Error $e) {
1272
+			$e->get_error();
1273
+		}
1274
+		return $EE_Registration_Config;
1275
+	}
1276
+
1277
+
1278
+	/**
1279
+	 * confirms that the server's PHP version has the PCRE module enabled,
1280
+	 * and that the PCRE version works with our i18n email validation
1281
+	 *
1282
+	 * @param EE_Registration_Config $EE_Registration_Config
1283
+	 * @param string                 $email_validation_level
1284
+	 * @return bool
1285
+	 */
1286
+	private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1287
+	{
1288
+		// first check that PCRE is enabled
1289
+		if (! defined('PREG_BAD_UTF8_ERROR')) {
1290
+			EE_Error::add_error(
1291
+				sprintf(
1292
+					esc_html__(
1293
+						'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.',
1294
+						'event_espresso'
1295
+					),
1296
+					'<br />'
1297
+				),
1298
+				__FILE__,
1299
+				__FUNCTION__,
1300
+				__LINE__
1301
+			);
1302
+			return false;
1303
+		} else {
1304
+			// PCRE support is enabled, but let's still
1305
+			// perform a test to see if the server will support it.
1306
+			// but first, save the updated validation level to the config,
1307
+			// so that the validation strategy picks it up.
1308
+			// this will get bumped back down if it doesn't work
1309
+			$EE_Registration_Config->email_validation_level = $email_validation_level;
1310
+			try {
1311
+				$email_validator = new EE_Email_Validation_Strategy();
1312
+				$i18n_email_address = apply_filters(
1313
+					'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1314
+					'jägerjü[email protected]'
1315
+				);
1316
+				$email_validator->validate($i18n_email_address);
1317
+			} catch (Exception $e) {
1318
+				EE_Error::add_error(
1319
+					sprintf(
1320
+						esc_html__(
1321
+							'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s',
1322
+							'event_espresso'
1323
+						),
1324
+						'<br />',
1325
+						'<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>'
1326
+					),
1327
+					__FILE__,
1328
+					__FUNCTION__,
1329
+					__LINE__
1330
+				);
1331
+				return false;
1332
+			}
1333
+		}
1334
+		return true;
1335
+	}
1336 1336
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public function __construct($routing = true)
21 21
     {
22
-        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/');
23
-        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/');
24
-        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
25
-        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/');
26
-        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
22
+        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form/');
23
+        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets/');
24
+        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/');
25
+        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates/');
26
+        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/');
27 27
         parent::__construct($routing);
28 28
     }
29 29
 
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     {
363 363
         wp_register_script(
364 364
             'ee-question-sortable',
365
-            REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
365
+            REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js',
366 366
             array('jquery-ui-sortable'),
367 367
             EVENT_ESPRESSO_VERSION,
368 368
             true
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
      */
449 449
     protected function _questions_overview_list_table()
450 450
     {
451
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
451
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
452 452
             'add_question',
453 453
             'add_question',
454 454
             array(),
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
     protected function _question_groups_overview_list_table()
470 470
     {
471 471
         $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
472
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
472
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
473 473
             'add_question_group',
474 474
             'add_question_group',
475 475
             array(),
@@ -531,18 +531,18 @@  discard block
 block discarded – undo
531 531
     {
532 532
         $success = 0;
533 533
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
534
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
534
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
535 535
             // if array has more than one element than success message should be plural
536 536
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
537 537
             // cycle thru bulk action checkboxes
538 538
             while (list($ID, $value) = each($this->_req_data['checkbox'])) {
539
-                if (! $this->_delete_item($ID, $model)) {
539
+                if ( ! $this->_delete_item($ID, $model)) {
540 540
                     $success = 0;
541 541
                 }
542 542
             }
543
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
543
+        } elseif ( ! empty($this->_req_data['QSG_ID'])) {
544 544
             $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
545
-        } elseif (! empty($this->_req_data['QST_ID'])) {
545
+        } elseif ( ! empty($this->_req_data['QST_ID'])) {
546 546
             $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
547 547
         } else {
548 548
             EE_Error::add_error(
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
612 612
         }
613 613
         // add ID to title if editing
614
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
614
+        $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
615 615
         if ($ID) {
616 616
             /** @var EE_Question_Group $questionGroup */
617 617
             $questionGroup = $this->_question_group_model->get_one_by_ID($ID);
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
         $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
632 632
         $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
633 633
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
634
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
634
+            REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php',
635 635
             $this->_template_args,
636 636
             true
637 637
         );
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
         // update the existing related questions
710 710
         // BUT FIRST...  delete the phone question from the Question_Group_Question
711 711
         // if it is being added to this question group (therefore removed from the existing group)
712
-        if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
712
+        if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) {
713 713
             // delete where QST ID = system phone question ID and Question Group ID is NOT this group
714 714
             EEM_Question_Group_Question::instance()->delete(
715 715
                 array(
@@ -724,22 +724,22 @@  discard block
 block discarded – undo
724 724
         $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
725 725
         $questions = $question_group->questions();
726 726
         // make sure system phone question is added to list of questions for this group
727
-        if (! isset($questions[ $phone_question_id ])) {
728
-            $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
727
+        if ( ! isset($questions[$phone_question_id])) {
728
+            $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
729 729
         }
730 730
 
731 731
         foreach ($questions as $question_ID => $question) {
732 732
             // first we always check for order.
733
-            if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
733
+            if ( ! empty($this->_req_data['question_orders'][$question_ID])) {
734 734
                 // update question order
735 735
                 $question_group->update_question_order(
736 736
                     $question_ID,
737
-                    $this->_req_data['question_orders'][ $question_ID ]
737
+                    $this->_req_data['question_orders'][$question_ID]
738 738
                 );
739 739
             }
740 740
 
741 741
             // then we always check if adding or removing.
742
-            if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
742
+            if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) {
743 743
                 $question_group->add_question($question_ID);
744 744
             } else {
745 745
                 // not found, remove it (but only if not a system question for the personal group
@@ -760,8 +760,8 @@  discard block
 block discarded – undo
760 760
         if (isset($this->_req_data['questions'])) {
761 761
             foreach ($this->_req_data['questions'] as $QST_ID) {
762 762
                 $question_group->add_question($QST_ID);
763
-                if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
764
-                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
763
+                if (isset($this->_req_data['question_orders'][$QST_ID])) {
764
+                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]);
765 765
                 }
766 766
             }
767 767
         }
@@ -902,33 +902,33 @@  discard block
 block discarded – undo
902 902
         // echo "trash $trash";
903 903
         // var_dump($this->_req_data['checkbox']);die;
904 904
         if (isset($this->_req_data['checkbox'])) {
905
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
905
+            if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
906 906
                 // if array has more than one element than success message should be plural
907 907
                 $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
908 908
                 // cycle thru bulk action checkboxes
909 909
                 while (list($ID, $value) = each($this->_req_data['checkbox'])) {
910
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
910
+                    if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) {
911 911
                         $success = 0;
912 912
                     }
913 913
                 }
914 914
             } else {
915 915
                 // grab single id and delete
916 916
                 $ID = absint($this->_req_data['checkbox']);
917
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
917
+                if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
918 918
                     $success = 0;
919 919
                 }
920 920
             }
921 921
         } else {
922 922
             // delete via trash link
923 923
             // grab single id and delete
924
-            $ID = absint($this->_req_data[ $model->primary_key_name() ]);
925
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
924
+            $ID = absint($this->_req_data[$model->primary_key_name()]);
925
+            if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
926 926
                 $success = 0;
927 927
             }
928 928
         }
929 929
 
930 930
 
931
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
931
+        $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; // strtolower( $model->item_name(2) );
932 932
         // echo "action :$action";
933 933
         // $action = 'questions' ? 'default' : $action;
934 934
         if ($trash) {
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
             ? (int) $this->_req_data['curpage']
1049 1049
             : null;
1050 1050
 
1051
-        if (! empty($row_ids)) {
1051
+        if ( ! empty($row_ids)) {
1052 1052
             // figure out where we start the row_id count at for the current page.
1053 1053
             $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1054 1054
 
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
                 // Update the questions when re-ordering
1058 1058
                 $updated = EEM_Question_Group::instance()->update(
1059 1059
                     array('QSG_order' => $qsgcount),
1060
-                    array(array('QSG_ID' => $row_ids[ $i ]))
1060
+                    array(array('QSG_ID' => $row_ids[$i]))
1061 1061
                 );
1062 1062
                 if ($updated === false) {
1063 1063
                     $success = false;
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
         $this->_set_add_edit_form_tags('update_reg_form_settings');
1104 1104
         $this->_set_publish_post_box_vars(null, false, false, null, false);
1105 1105
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1106
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1106
+            REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php',
1107 1107
             $this->_template_args,
1108 1108
             true
1109 1109
         );
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
                                 $prev_email_validation_level = 'basic';
1241 1241
                             }
1242 1242
                             // confirm our i18n email validation will work on the server
1243
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1243
+                            if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1244 1244
                                 // or reset email validation level to previous value
1245 1245
                                 $email_validation_level = $prev_email_validation_level;
1246 1246
                             }
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
     private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1287 1287
     {
1288 1288
         // first check that PCRE is enabled
1289
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1289
+        if ( ! defined('PREG_BAD_UTF8_ERROR')) {
1290 1290
             EE_Error::add_error(
1291 1291
                 sprintf(
1292 1292
                     esc_html__(
Please login to merge, or discard this patch.
core/bootstrap_espresso.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -6,22 +6,22 @@  discard block
 block discarded – undo
6 6
  */
7 7
 function espresso_load_error_handling()
8 8
 {
9
-    static $error_handling_loaded = false;
10
-    if ($error_handling_loaded) {
11
-        return;
12
-    }
13
-    // load debugging tools
14
-    if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
15
-        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
16
-        \EEH_Debug_Tools::instance();
17
-    }
18
-    // load error handling
19
-    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
20
-        require_once EE_CORE . 'EE_Error.core.php';
21
-    } else {
22
-        wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
23
-    }
24
-    $error_handling_loaded = true;
9
+	static $error_handling_loaded = false;
10
+	if ($error_handling_loaded) {
11
+		return;
12
+	}
13
+	// load debugging tools
14
+	if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
15
+		require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
16
+		\EEH_Debug_Tools::instance();
17
+	}
18
+	// load error handling
19
+	if (is_readable(EE_CORE . 'EE_Error.core.php')) {
20
+		require_once EE_CORE . 'EE_Error.core.php';
21
+	} else {
22
+		wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
23
+	}
24
+	$error_handling_loaded = true;
25 25
 }
26 26
 
27 27
 
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function espresso_load_required($classname, $full_path_to_file)
37 37
 {
38
-    if (is_readable($full_path_to_file)) {
39
-        require_once $full_path_to_file;
40
-    } else {
41
-        throw new \EE_Error(
42
-            sprintf(
43
-                esc_html__(
44
-                    'The %s class file could not be located or is not readable due to file permissions.',
45
-                    'event_espresso'
46
-                ),
47
-                $classname
48
-            )
49
-        );
50
-    }
38
+	if (is_readable($full_path_to_file)) {
39
+		require_once $full_path_to_file;
40
+	} else {
41
+		throw new \EE_Error(
42
+			sprintf(
43
+				esc_html__(
44
+					'The %s class file could not be located or is not readable due to file permissions.',
45
+					'event_espresso'
46
+				),
47
+				$classname
48
+			)
49
+		);
50
+	}
51 51
 }
52 52
 
53 53
 
@@ -66,52 +66,52 @@  discard block
 block discarded – undo
66 66
  */
67 67
 function bootstrap_espresso()
68 68
 {
69
-    require_once __DIR__ . '/espresso_definitions.php';
70
-    try {
71
-        espresso_load_error_handling();
72
-        // include WordPress shims for functions introduced in later versions of WordPress
73
-        espresso_load_required(
74
-            '',
75
-            EE_CORE . 'wordpress-shims.php'
76
-        );
77
-        espresso_load_required(
78
-            '',
79
-            EE_CORE . 'third-party-compatibility.php'
80
-        );
81
-        espresso_load_required(
82
-            'EEH_Base',
83
-            EE_CORE . 'helpers/EEH_Base.helper.php'
84
-        );
85
-        espresso_load_required(
86
-            'EEH_File',
87
-            EE_CORE . 'interfaces/EEHI_File.interface.php'
88
-        );
89
-        espresso_load_required(
90
-            'EEH_File',
91
-            EE_CORE . 'helpers/EEH_File.helper.php'
92
-        );
93
-        espresso_load_required(
94
-            'EEH_Array',
95
-            EE_CORE . 'helpers/EEH_Array.helper.php'
96
-        );
97
-        espresso_load_required(
98
-            'EE_Base',
99
-            EE_CORE . 'EE_Base.core.php'
100
-        );
101
-        // instantiate and configure PSR4 autoloader
102
-        espresso_load_required(
103
-            'Psr4Autoloader',
104
-            EE_CORE . 'Psr4Autoloader.php'
105
-        );
106
-        espresso_load_required(
107
-            'EE_Psr4AutoloaderInit',
108
-            EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
109
-        );
110
-        $AutoloaderInit = new EE_Psr4AutoloaderInit();
111
-        $AutoloaderInit->initializeAutoloader();
112
-        new EventEspresso\core\services\bootstrap\BootstrapCore();
113
-    } catch (Exception $e) {
114
-        require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php';
115
-        new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
116
-    }
69
+	require_once __DIR__ . '/espresso_definitions.php';
70
+	try {
71
+		espresso_load_error_handling();
72
+		// include WordPress shims for functions introduced in later versions of WordPress
73
+		espresso_load_required(
74
+			'',
75
+			EE_CORE . 'wordpress-shims.php'
76
+		);
77
+		espresso_load_required(
78
+			'',
79
+			EE_CORE . 'third-party-compatibility.php'
80
+		);
81
+		espresso_load_required(
82
+			'EEH_Base',
83
+			EE_CORE . 'helpers/EEH_Base.helper.php'
84
+		);
85
+		espresso_load_required(
86
+			'EEH_File',
87
+			EE_CORE . 'interfaces/EEHI_File.interface.php'
88
+		);
89
+		espresso_load_required(
90
+			'EEH_File',
91
+			EE_CORE . 'helpers/EEH_File.helper.php'
92
+		);
93
+		espresso_load_required(
94
+			'EEH_Array',
95
+			EE_CORE . 'helpers/EEH_Array.helper.php'
96
+		);
97
+		espresso_load_required(
98
+			'EE_Base',
99
+			EE_CORE . 'EE_Base.core.php'
100
+		);
101
+		// instantiate and configure PSR4 autoloader
102
+		espresso_load_required(
103
+			'Psr4Autoloader',
104
+			EE_CORE . 'Psr4Autoloader.php'
105
+		);
106
+		espresso_load_required(
107
+			'EE_Psr4AutoloaderInit',
108
+			EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
109
+		);
110
+		$AutoloaderInit = new EE_Psr4AutoloaderInit();
111
+		$AutoloaderInit->initializeAutoloader();
112
+		new EventEspresso\core\services\bootstrap\BootstrapCore();
113
+	} catch (Exception $e) {
114
+		require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php';
115
+		new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
116
+	}
117 117
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
         return;
12 12
     }
13 13
     // load debugging tools
14
-    if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
15
-        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
14
+    if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
15
+        require_once EE_HELPERS.'EEH_Debug_Tools.helper.php';
16 16
         \EEH_Debug_Tools::instance();
17 17
     }
18 18
     // load error handling
19
-    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
20
-        require_once EE_CORE . 'EE_Error.core.php';
19
+    if (is_readable(EE_CORE.'EE_Error.core.php')) {
20
+        require_once EE_CORE.'EE_Error.core.php';
21 21
     } else {
22 22
         wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
23 23
     }
@@ -66,52 +66,52 @@  discard block
 block discarded – undo
66 66
  */
67 67
 function bootstrap_espresso()
68 68
 {
69
-    require_once __DIR__ . '/espresso_definitions.php';
69
+    require_once __DIR__.'/espresso_definitions.php';
70 70
     try {
71 71
         espresso_load_error_handling();
72 72
         // include WordPress shims for functions introduced in later versions of WordPress
73 73
         espresso_load_required(
74 74
             '',
75
-            EE_CORE . 'wordpress-shims.php'
75
+            EE_CORE.'wordpress-shims.php'
76 76
         );
77 77
         espresso_load_required(
78 78
             '',
79
-            EE_CORE . 'third-party-compatibility.php'
79
+            EE_CORE.'third-party-compatibility.php'
80 80
         );
81 81
         espresso_load_required(
82 82
             'EEH_Base',
83
-            EE_CORE . 'helpers/EEH_Base.helper.php'
83
+            EE_CORE.'helpers/EEH_Base.helper.php'
84 84
         );
85 85
         espresso_load_required(
86 86
             'EEH_File',
87
-            EE_CORE . 'interfaces/EEHI_File.interface.php'
87
+            EE_CORE.'interfaces/EEHI_File.interface.php'
88 88
         );
89 89
         espresso_load_required(
90 90
             'EEH_File',
91
-            EE_CORE . 'helpers/EEH_File.helper.php'
91
+            EE_CORE.'helpers/EEH_File.helper.php'
92 92
         );
93 93
         espresso_load_required(
94 94
             'EEH_Array',
95
-            EE_CORE . 'helpers/EEH_Array.helper.php'
95
+            EE_CORE.'helpers/EEH_Array.helper.php'
96 96
         );
97 97
         espresso_load_required(
98 98
             'EE_Base',
99
-            EE_CORE . 'EE_Base.core.php'
99
+            EE_CORE.'EE_Base.core.php'
100 100
         );
101 101
         // instantiate and configure PSR4 autoloader
102 102
         espresso_load_required(
103 103
             'Psr4Autoloader',
104
-            EE_CORE . 'Psr4Autoloader.php'
104
+            EE_CORE.'Psr4Autoloader.php'
105 105
         );
106 106
         espresso_load_required(
107 107
             'EE_Psr4AutoloaderInit',
108
-            EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
108
+            EE_CORE.'EE_Psr4AutoloaderInit.core.php'
109 109
         );
110 110
         $AutoloaderInit = new EE_Psr4AutoloaderInit();
111 111
         $AutoloaderInit->initializeAutoloader();
112 112
         new EventEspresso\core\services\bootstrap\BootstrapCore();
113 113
     } catch (Exception $e) {
114
-        require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php';
114
+        require_once EE_CORE.'exceptions/ExceptionStackTraceDisplay.php';
115 115
         new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
116 116
     }
117 117
 }
Please login to merge, or discard this patch.
core/services/locators/FqcnLocator.php 2 patches
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -18,156 +18,156 @@
 block discarded – undo
18 18
 class FqcnLocator extends Locator
19 19
 {
20 20
 
21
-    /**
22
-     * @var array $FQCNs
23
-     */
24
-    protected $FQCNs = array();
25
-
26
-    /**
27
-     * @var array $namespaces
28
-     */
29
-    protected $namespaces = array();
30
-
31
-
32
-    /**
33
-     * @access protected
34
-     * @param string $namespace
35
-     * @param string $namespace_base_dir
36
-     * @throws InvalidDataTypeException
37
-     */
38
-    protected function setNamespace($namespace, $namespace_base_dir)
39
-    {
40
-        if (! is_string($namespace)) {
41
-            throw new InvalidDataTypeException('$namespace', $namespace, 'string');
42
-        }
43
-        if (! is_string($namespace_base_dir)) {
44
-            throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
45
-        }
46
-        $this->namespaces[ $namespace ] = $namespace_base_dir;
47
-    }
48
-
49
-
50
-    /**
51
-     * @access public
52
-     * @return array
53
-     */
54
-    public function getFQCNs()
55
-    {
56
-        return $this->FQCNs;
57
-    }
58
-
59
-
60
-    /**
61
-     * @access public
62
-     * @return int
63
-     */
64
-    public function count()
65
-    {
66
-        return count($this->FQCNs);
67
-    }
68
-
69
-
70
-    /**
71
-     * given a valid namespace, will find all files that match the provided mask
72
-     *
73
-     * @access public
74
-     * @param string|array $namespaces
75
-     * @return array
76
-     * @throws InvalidClassException
77
-     * @throws InvalidDataTypeException
78
-     */
79
-    public function locate($namespaces)
80
-    {
81
-        if (! (is_string($namespaces) || is_array($namespaces))) {
82
-            throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
83
-        }
84
-        foreach ((array) $namespaces as $namespace) {
85
-            foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
86
-                $this->FQCNs[ $key ] = $file;
87
-            }
88
-        }
89
-        return $this->FQCNs;
90
-    }
91
-
92
-
93
-    /**
94
-     * given a partial namespace, will find all files in that folder
95
-     * ** PLZ NOTE **
96
-     * This assumes that all files within the specified folder should be loaded
97
-     *
98
-     * @access protected
99
-     * @param string $partial_namespace
100
-     * @return array
101
-     * @throws InvalidClassException
102
-     * @throws InvalidDataTypeException
103
-     */
104
-    protected function findFQCNsByNamespace($partial_namespace)
105
-    {
106
-        $iterator = new FilesystemIterator(
107
-            $this->getDirectoryFromPartialNamespace($partial_namespace)
108
-        );
109
-        $iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO);
110
-        $iterator->setFlags(FilesystemIterator::UNIX_PATHS);
111
-        if (iterator_count($iterator) === 0) {
112
-            return array();
113
-        }
114
-        foreach ($iterator as $file) {
115
-            if ($file->isFile() && $file->getExtension() === 'php') {
116
-                $file = $file->getPath() . '/' . $file->getBasename('.php');
117
-                foreach ($this->namespaces as $namespace => $base_dir) {
118
-                    $namespace .= Psr4Autoloader::NS;
119
-                    if (strpos($file, $base_dir) === 0) {
120
-                        $this->FQCNs[] = Psr4Autoloader::NS . str_replace(
121
-                            array($base_dir, '/'),
122
-                            array($namespace, Psr4Autoloader::NS),
123
-                            $file
124
-                        );
125
-                    }
126
-                }
127
-            }
128
-        }
129
-        return $this->FQCNs;
130
-    }
131
-
132
-
133
-    /**
134
-     * getDirectoryFromPartialNamespace
135
-     *
136
-     * @access protected
137
-     * @param  string $partial_namespace almost fully qualified class name ?
138
-     * @return string
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidClassException
141
-     */
142
-    protected function getDirectoryFromPartialNamespace($partial_namespace)
143
-    {
144
-        if (empty($partial_namespace)) {
145
-            throw new InvalidClassException($partial_namespace);
146
-        }
147
-        // load our PSR-4 Autoloader so we can get the list of registered namespaces from it
148
-        $psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader();
149
-        // breakup the incoming namespace into segments so we can loop thru them
150
-        $namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS));
151
-        // we're only interested in the Vendor and secondary base, so pull those from the array
152
-        $vendor_base = array_slice($namespace_segments, 0, 2);
153
-        $namespace = $prefix = null;
154
-        while (! empty($vendor_base)) {
155
-            $namespace = implode(Psr4Autoloader::NS, $vendor_base);
156
-            // check if there's a base directory registered for that namespace
157
-            $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
158
-            if (! empty($prefix) && ! empty($prefix[0])) {
159
-                // found one!
160
-                break;
161
-            }
162
-            // remove base and try vendor only portion of namespace
163
-            array_pop($vendor_base);
164
-        }
165
-        // nope? then the incoming namespace is invalid
166
-        if (empty($prefix) || empty($prefix[0])) {
167
-            throw new InvalidClassException($partial_namespace);
168
-        }
169
-        $this->setNamespace($namespace, $prefix[0]);
170
-        // but if it's good, add that base directory to the rest of the path, and return it
171
-        return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
172
-    }
21
+	/**
22
+	 * @var array $FQCNs
23
+	 */
24
+	protected $FQCNs = array();
25
+
26
+	/**
27
+	 * @var array $namespaces
28
+	 */
29
+	protected $namespaces = array();
30
+
31
+
32
+	/**
33
+	 * @access protected
34
+	 * @param string $namespace
35
+	 * @param string $namespace_base_dir
36
+	 * @throws InvalidDataTypeException
37
+	 */
38
+	protected function setNamespace($namespace, $namespace_base_dir)
39
+	{
40
+		if (! is_string($namespace)) {
41
+			throw new InvalidDataTypeException('$namespace', $namespace, 'string');
42
+		}
43
+		if (! is_string($namespace_base_dir)) {
44
+			throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
45
+		}
46
+		$this->namespaces[ $namespace ] = $namespace_base_dir;
47
+	}
48
+
49
+
50
+	/**
51
+	 * @access public
52
+	 * @return array
53
+	 */
54
+	public function getFQCNs()
55
+	{
56
+		return $this->FQCNs;
57
+	}
58
+
59
+
60
+	/**
61
+	 * @access public
62
+	 * @return int
63
+	 */
64
+	public function count()
65
+	{
66
+		return count($this->FQCNs);
67
+	}
68
+
69
+
70
+	/**
71
+	 * given a valid namespace, will find all files that match the provided mask
72
+	 *
73
+	 * @access public
74
+	 * @param string|array $namespaces
75
+	 * @return array
76
+	 * @throws InvalidClassException
77
+	 * @throws InvalidDataTypeException
78
+	 */
79
+	public function locate($namespaces)
80
+	{
81
+		if (! (is_string($namespaces) || is_array($namespaces))) {
82
+			throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
83
+		}
84
+		foreach ((array) $namespaces as $namespace) {
85
+			foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
86
+				$this->FQCNs[ $key ] = $file;
87
+			}
88
+		}
89
+		return $this->FQCNs;
90
+	}
91
+
92
+
93
+	/**
94
+	 * given a partial namespace, will find all files in that folder
95
+	 * ** PLZ NOTE **
96
+	 * This assumes that all files within the specified folder should be loaded
97
+	 *
98
+	 * @access protected
99
+	 * @param string $partial_namespace
100
+	 * @return array
101
+	 * @throws InvalidClassException
102
+	 * @throws InvalidDataTypeException
103
+	 */
104
+	protected function findFQCNsByNamespace($partial_namespace)
105
+	{
106
+		$iterator = new FilesystemIterator(
107
+			$this->getDirectoryFromPartialNamespace($partial_namespace)
108
+		);
109
+		$iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO);
110
+		$iterator->setFlags(FilesystemIterator::UNIX_PATHS);
111
+		if (iterator_count($iterator) === 0) {
112
+			return array();
113
+		}
114
+		foreach ($iterator as $file) {
115
+			if ($file->isFile() && $file->getExtension() === 'php') {
116
+				$file = $file->getPath() . '/' . $file->getBasename('.php');
117
+				foreach ($this->namespaces as $namespace => $base_dir) {
118
+					$namespace .= Psr4Autoloader::NS;
119
+					if (strpos($file, $base_dir) === 0) {
120
+						$this->FQCNs[] = Psr4Autoloader::NS . str_replace(
121
+							array($base_dir, '/'),
122
+							array($namespace, Psr4Autoloader::NS),
123
+							$file
124
+						);
125
+					}
126
+				}
127
+			}
128
+		}
129
+		return $this->FQCNs;
130
+	}
131
+
132
+
133
+	/**
134
+	 * getDirectoryFromPartialNamespace
135
+	 *
136
+	 * @access protected
137
+	 * @param  string $partial_namespace almost fully qualified class name ?
138
+	 * @return string
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidClassException
141
+	 */
142
+	protected function getDirectoryFromPartialNamespace($partial_namespace)
143
+	{
144
+		if (empty($partial_namespace)) {
145
+			throw new InvalidClassException($partial_namespace);
146
+		}
147
+		// load our PSR-4 Autoloader so we can get the list of registered namespaces from it
148
+		$psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader();
149
+		// breakup the incoming namespace into segments so we can loop thru them
150
+		$namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS));
151
+		// we're only interested in the Vendor and secondary base, so pull those from the array
152
+		$vendor_base = array_slice($namespace_segments, 0, 2);
153
+		$namespace = $prefix = null;
154
+		while (! empty($vendor_base)) {
155
+			$namespace = implode(Psr4Autoloader::NS, $vendor_base);
156
+			// check if there's a base directory registered for that namespace
157
+			$prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
158
+			if (! empty($prefix) && ! empty($prefix[0])) {
159
+				// found one!
160
+				break;
161
+			}
162
+			// remove base and try vendor only portion of namespace
163
+			array_pop($vendor_base);
164
+		}
165
+		// nope? then the incoming namespace is invalid
166
+		if (empty($prefix) || empty($prefix[0])) {
167
+			throw new InvalidClassException($partial_namespace);
168
+		}
169
+		$this->setNamespace($namespace, $prefix[0]);
170
+		// but if it's good, add that base directory to the rest of the path, and return it
171
+		return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
172
+	}
173 173
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
      */
38 38
     protected function setNamespace($namespace, $namespace_base_dir)
39 39
     {
40
-        if (! is_string($namespace)) {
40
+        if ( ! is_string($namespace)) {
41 41
             throw new InvalidDataTypeException('$namespace', $namespace, 'string');
42 42
         }
43
-        if (! is_string($namespace_base_dir)) {
43
+        if ( ! is_string($namespace_base_dir)) {
44 44
             throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
45 45
         }
46
-        $this->namespaces[ $namespace ] = $namespace_base_dir;
46
+        $this->namespaces[$namespace] = $namespace_base_dir;
47 47
     }
48 48
 
49 49
 
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function locate($namespaces)
80 80
     {
81
-        if (! (is_string($namespaces) || is_array($namespaces))) {
81
+        if ( ! (is_string($namespaces) || is_array($namespaces))) {
82 82
             throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
83 83
         }
84 84
         foreach ((array) $namespaces as $namespace) {
85 85
             foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
86
-                $this->FQCNs[ $key ] = $file;
86
+                $this->FQCNs[$key] = $file;
87 87
             }
88 88
         }
89 89
         return $this->FQCNs;
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
         }
114 114
         foreach ($iterator as $file) {
115 115
             if ($file->isFile() && $file->getExtension() === 'php') {
116
-                $file = $file->getPath() . '/' . $file->getBasename('.php');
116
+                $file = $file->getPath().'/'.$file->getBasename('.php');
117 117
                 foreach ($this->namespaces as $namespace => $base_dir) {
118 118
                     $namespace .= Psr4Autoloader::NS;
119 119
                     if (strpos($file, $base_dir) === 0) {
120
-                        $this->FQCNs[] = Psr4Autoloader::NS . str_replace(
120
+                        $this->FQCNs[] = Psr4Autoloader::NS.str_replace(
121 121
                             array($base_dir, '/'),
122 122
                             array($namespace, Psr4Autoloader::NS),
123 123
                             $file
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
         // we're only interested in the Vendor and secondary base, so pull those from the array
152 152
         $vendor_base = array_slice($namespace_segments, 0, 2);
153 153
         $namespace = $prefix = null;
154
-        while (! empty($vendor_base)) {
154
+        while ( ! empty($vendor_base)) {
155 155
             $namespace = implode(Psr4Autoloader::NS, $vendor_base);
156 156
             // check if there's a base directory registered for that namespace
157
-            $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
158
-            if (! empty($prefix) && ! empty($prefix[0])) {
157
+            $prefix = $psr4_loader->prefixes($namespace.Psr4Autoloader::NS);
158
+            if ( ! empty($prefix) && ! empty($prefix[0])) {
159 159
                 // found one!
160 160
                 break;
161 161
             }
@@ -168,6 +168,6 @@  discard block
 block discarded – undo
168 168
         }
169 169
         $this->setNamespace($namespace, $prefix[0]);
170 170
         // but if it's good, add that base directory to the rest of the path, and return it
171
-        return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
171
+        return $prefix[0].implode('/', array_diff($namespace_segments, $vendor_base)).'/';
172 172
     }
173 173
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapRequestResponseObjects.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -25,80 +25,80 @@
 block discarded – undo
25 25
 class BootstrapRequestResponseObjects
26 26
 {
27 27
 
28
-    /**
29
-     * @type LegacyRequestInterface $legacy_request
30
-     */
31
-    protected $legacy_request;
28
+	/**
29
+	 * @type LegacyRequestInterface $legacy_request
30
+	 */
31
+	protected $legacy_request;
32 32
 
33
-    /**
34
-     * @type LoaderInterface $loader
35
-     */
36
-    protected $loader;
33
+	/**
34
+	 * @type LoaderInterface $loader
35
+	 */
36
+	protected $loader;
37 37
 
38
-    /**
39
-     * @var RequestInterface $request
40
-     */
41
-    protected $request;
38
+	/**
39
+	 * @var RequestInterface $request
40
+	 */
41
+	protected $request;
42 42
 
43
-    /**
44
-     * @var ResponseInterface $response
45
-     */
46
-    protected $response;
43
+	/**
44
+	 * @var ResponseInterface $response
45
+	 */
46
+	protected $response;
47 47
 
48 48
 
49
-    /**
50
-     * BootstrapRequestResponseObjects constructor.
51
-     *
52
-     * @param LoaderInterface $loader
53
-     */
54
-    public function __construct(LoaderInterface $loader)
55
-    {
56
-        $this->loader = $loader;
57
-    }
49
+	/**
50
+	 * BootstrapRequestResponseObjects constructor.
51
+	 *
52
+	 * @param LoaderInterface $loader
53
+	 */
54
+	public function __construct(LoaderInterface $loader)
55
+	{
56
+		$this->loader = $loader;
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * @return void
62
-     */
63
-    public function buildRequestResponse()
64
-    {
65
-        // load our Request and Response objects
66
-        $this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES);
67
-        $this->response = new Response();
68
-    }
60
+	/**
61
+	 * @return void
62
+	 */
63
+	public function buildRequestResponse()
64
+	{
65
+		// load our Request and Response objects
66
+		$this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES);
67
+		$this->response = new Response();
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @return void
73
-     * @throws InvalidArgumentException
74
-     */
75
-    public function shareRequestResponse()
76
-    {
77
-        $this->loader->share('EventEspresso\core\services\request\Request', $this->request);
78
-        $this->loader->share('EventEspresso\core\services\request\Response', $this->response);
79
-        EE_Dependency_Map::instance()->setRequest($this->request);
80
-        EE_Dependency_Map::instance()->setResponse($this->response);
81
-    }
71
+	/**
72
+	 * @return void
73
+	 * @throws InvalidArgumentException
74
+	 */
75
+	public function shareRequestResponse()
76
+	{
77
+		$this->loader->share('EventEspresso\core\services\request\Request', $this->request);
78
+		$this->loader->share('EventEspresso\core\services\request\Response', $this->response);
79
+		EE_Dependency_Map::instance()->setRequest($this->request);
80
+		EE_Dependency_Map::instance()->setResponse($this->response);
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     * @return void
86
-     * @throws InvalidArgumentException
87
-     * @throws EE_Error
88
-     */
89
-    public function setupLegacyRequest()
90
-    {
91
-        espresso_load_required(
92
-            'EE_Request',
93
-            EE_CORE . 'request_stack/EE_Request.core.php'
94
-        );
95
-        $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96
-        $this->legacy_request->setRequest($this->request);
97
-        $this->legacy_request->admin = $this->request->isAdmin();
98
-        $this->legacy_request->ajax = $this->request->isAjax();
99
-        $this->legacy_request->front_ajax = $this->request->isFrontAjax();
100
-        EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
101
-        $this->loader->share('EE_Request', $this->legacy_request);
102
-        $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
103
-    }
84
+	/**
85
+	 * @return void
86
+	 * @throws InvalidArgumentException
87
+	 * @throws EE_Error
88
+	 */
89
+	public function setupLegacyRequest()
90
+	{
91
+		espresso_load_required(
92
+			'EE_Request',
93
+			EE_CORE . 'request_stack/EE_Request.core.php'
94
+		);
95
+		$this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96
+		$this->legacy_request->setRequest($this->request);
97
+		$this->legacy_request->admin = $this->request->isAdmin();
98
+		$this->legacy_request->ajax = $this->request->isAjax();
99
+		$this->legacy_request->front_ajax = $this->request->isFrontAjax();
100
+		EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
101
+		$this->loader->share('EE_Request', $this->legacy_request);
102
+		$this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
103
+	}
104 104
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
     {
91 91
         espresso_load_required(
92 92
             'EE_Request',
93
-            EE_CORE . 'request_stack/EE_Request.core.php'
93
+            EE_CORE.'request_stack/EE_Request.core.php'
94 94
         );
95 95
         $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96 96
         $this->legacy_request->setRequest($this->request);
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapCore.php 2 patches
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -47,225 +47,225 @@
 block discarded – undo
47 47
 class BootstrapCore
48 48
 {
49 49
 
50
-    /**
51
-     * @type LoaderInterface $loader
52
-     */
53
-    private $loader;
50
+	/**
51
+	 * @type LoaderInterface $loader
52
+	 */
53
+	private $loader;
54 54
 
55
-    /**
56
-     * @var RequestInterface $request
57
-     */
58
-    protected $request;
55
+	/**
56
+	 * @var RequestInterface $request
57
+	 */
58
+	protected $request;
59 59
 
60
-    /**
61
-     * @var ResponseInterface $response
62
-     */
63
-    protected $response;
60
+	/**
61
+	 * @var ResponseInterface $response
62
+	 */
63
+	protected $response;
64 64
 
65
-    /**
66
-     * @var RequestStackBuilder $request_stack_builder
67
-     */
68
-    protected $request_stack_builder;
65
+	/**
66
+	 * @var RequestStackBuilder $request_stack_builder
67
+	 */
68
+	protected $request_stack_builder;
69 69
 
70
-    /**
71
-     * @var RequestStack $request_stack
72
-     */
73
-    protected $request_stack;
70
+	/**
71
+	 * @var RequestStack $request_stack
72
+	 */
73
+	protected $request_stack;
74 74
 
75 75
 
76
-    /**
77
-     * BootstrapCore constructor.
78
-     */
79
-    public function __construct()
80
-    {
81
-        do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
82
-        // construct request stack and run middleware apps as soon as all WP plugins are loaded
83
-        add_action('plugins_loaded', array($this, 'initialize'), 0);
84
-    }
76
+	/**
77
+	 * BootstrapCore constructor.
78
+	 */
79
+	public function __construct()
80
+	{
81
+		do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
82
+		// construct request stack and run middleware apps as soon as all WP plugins are loaded
83
+		add_action('plugins_loaded', array($this, 'initialize'), 0);
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * @throws DomainException
89
-     * @throws EE_Error
90
-     * @throws Exception
91
-     * @throws InvalidArgumentException
92
-     * @throws InvalidClassException
93
-     * @throws InvalidDataTypeException
94
-     * @throws InvalidFilePathException
95
-     * @throws InvalidInterfaceException
96
-     * @throws InvalidRequestStackMiddlewareException
97
-     * @throws OutOfBoundsException
98
-     * @throws ReflectionException
99
-     */
100
-    public function initialize()
101
-    {
102
-        $this->bootstrapDependencyInjectionContainer();
103
-        $this->bootstrapDomain();
104
-        $bootstrap_request = $this->bootstrapRequestResponseObjects();
105
-        add_action(
106
-            'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
107
-            array($bootstrap_request, 'setupLegacyRequest')
108
-        );
109
-        $this->runRequestStack();
110
-    }
87
+	/**
88
+	 * @throws DomainException
89
+	 * @throws EE_Error
90
+	 * @throws Exception
91
+	 * @throws InvalidArgumentException
92
+	 * @throws InvalidClassException
93
+	 * @throws InvalidDataTypeException
94
+	 * @throws InvalidFilePathException
95
+	 * @throws InvalidInterfaceException
96
+	 * @throws InvalidRequestStackMiddlewareException
97
+	 * @throws OutOfBoundsException
98
+	 * @throws ReflectionException
99
+	 */
100
+	public function initialize()
101
+	{
102
+		$this->bootstrapDependencyInjectionContainer();
103
+		$this->bootstrapDomain();
104
+		$bootstrap_request = $this->bootstrapRequestResponseObjects();
105
+		add_action(
106
+			'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
107
+			array($bootstrap_request, 'setupLegacyRequest')
108
+		);
109
+		$this->runRequestStack();
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * @throws ReflectionException
115
-     * @throws EE_Error
116
-     * @throws InvalidArgumentException
117
-     * @throws InvalidDataTypeException
118
-     * @throws InvalidInterfaceException
119
-     * @throws OutOfBoundsException
120
-     */
121
-    private function bootstrapDependencyInjectionContainer()
122
-    {
123
-        $bootstrap_di = new BootstrapDependencyInjectionContainer();
124
-        $bootstrap_di->buildLegacyDependencyInjectionContainer();
125
-        $bootstrap_di->buildLoader();
126
-        $registry = $bootstrap_di->getRegistry();
127
-        $dependency_map = $bootstrap_di->getDependencyMap();
128
-        $dependency_map->initialize();
129
-        $registry->initialize();
130
-        $this->loader = $bootstrap_di->getLoader();
131
-    }
113
+	/**
114
+	 * @throws ReflectionException
115
+	 * @throws EE_Error
116
+	 * @throws InvalidArgumentException
117
+	 * @throws InvalidDataTypeException
118
+	 * @throws InvalidInterfaceException
119
+	 * @throws OutOfBoundsException
120
+	 */
121
+	private function bootstrapDependencyInjectionContainer()
122
+	{
123
+		$bootstrap_di = new BootstrapDependencyInjectionContainer();
124
+		$bootstrap_di->buildLegacyDependencyInjectionContainer();
125
+		$bootstrap_di->buildLoader();
126
+		$registry = $bootstrap_di->getRegistry();
127
+		$dependency_map = $bootstrap_di->getDependencyMap();
128
+		$dependency_map->initialize();
129
+		$registry->initialize();
130
+		$this->loader = $bootstrap_di->getLoader();
131
+	}
132 132
 
133 133
 
134
-    /**
135
-     * configures the Domain object for core
136
-     *
137
-     * @return void
138
-     * @throws DomainException
139
-     * @throws InvalidArgumentException
140
-     * @throws InvalidDataTypeException
141
-     * @throws InvalidClassException
142
-     * @throws InvalidFilePathException
143
-     * @throws InvalidInterfaceException
144
-     */
145
-    private function bootstrapDomain()
146
-    {
147
-        DomainFactory::getEventEspressoCoreDomain();
148
-    }
134
+	/**
135
+	 * configures the Domain object for core
136
+	 *
137
+	 * @return void
138
+	 * @throws DomainException
139
+	 * @throws InvalidArgumentException
140
+	 * @throws InvalidDataTypeException
141
+	 * @throws InvalidClassException
142
+	 * @throws InvalidFilePathException
143
+	 * @throws InvalidInterfaceException
144
+	 */
145
+	private function bootstrapDomain()
146
+	{
147
+		DomainFactory::getEventEspressoCoreDomain();
148
+	}
149 149
 
150 150
 
151
-    /**
152
-     * sets up the request and response objects
153
-     *
154
-     * @return BootstrapRequestResponseObjects
155
-     * @throws InvalidArgumentException
156
-     */
157
-    private function bootstrapRequestResponseObjects()
158
-    {
159
-        /** @var BootstrapRequestResponseObjects $bootstrap_request */
160
-        $bootstrap_request = $this->loader->getShared(
161
-            'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
162
-            array($this->loader)
163
-        );
164
-        $bootstrap_request->buildRequestResponse();
165
-        $bootstrap_request->shareRequestResponse();
166
-        $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request');
167
-        $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
168
-        return $bootstrap_request;
169
-    }
151
+	/**
152
+	 * sets up the request and response objects
153
+	 *
154
+	 * @return BootstrapRequestResponseObjects
155
+	 * @throws InvalidArgumentException
156
+	 */
157
+	private function bootstrapRequestResponseObjects()
158
+	{
159
+		/** @var BootstrapRequestResponseObjects $bootstrap_request */
160
+		$bootstrap_request = $this->loader->getShared(
161
+			'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
162
+			array($this->loader)
163
+		);
164
+		$bootstrap_request->buildRequestResponse();
165
+		$bootstrap_request->shareRequestResponse();
166
+		$this->request = $this->loader->getShared('EventEspresso\core\services\request\Request');
167
+		$this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
168
+		return $bootstrap_request;
169
+	}
170 170
 
171 171
 
172
-    /**
173
-     * run_request_stack
174
-     * construct request stack and run middleware apps
175
-     *
176
-     * @throws EE_Error
177
-     * @throws Exception
178
-     */
179
-    public function runRequestStack()
180
-    {
181
-        $this->loadAutoloader();
182
-        $this->setAutoloadersForRequiredFiles();
183
-        $this->request_stack_builder = $this->buildRequestStack();
184
-        $this->request_stack = $this->request_stack_builder->resolve(
185
-            new RequestStackCoreApp()
186
-        );
187
-        $this->request_stack->handleRequest($this->request, $this->response);
188
-        $this->request_stack->handleResponse();
189
-    }
172
+	/**
173
+	 * run_request_stack
174
+	 * construct request stack and run middleware apps
175
+	 *
176
+	 * @throws EE_Error
177
+	 * @throws Exception
178
+	 */
179
+	public function runRequestStack()
180
+	{
181
+		$this->loadAutoloader();
182
+		$this->setAutoloadersForRequiredFiles();
183
+		$this->request_stack_builder = $this->buildRequestStack();
184
+		$this->request_stack = $this->request_stack_builder->resolve(
185
+			new RequestStackCoreApp()
186
+		);
187
+		$this->request_stack->handleRequest($this->request, $this->response);
188
+		$this->request_stack->handleResponse();
189
+	}
190 190
 
191 191
 
192
-    /**
193
-     * load_autoloader
194
-     *
195
-     * @throws EE_Error
196
-     */
197
-    protected function loadAutoloader()
198
-    {
199
-        // load interfaces
200
-        espresso_load_required(
201
-            'EEH_Autoloader',
202
-            EE_CORE . 'helpers/EEH_Autoloader.helper.php'
203
-        );
204
-        EEH_Autoloader::instance();
205
-    }
192
+	/**
193
+	 * load_autoloader
194
+	 *
195
+	 * @throws EE_Error
196
+	 */
197
+	protected function loadAutoloader()
198
+	{
199
+		// load interfaces
200
+		espresso_load_required(
201
+			'EEH_Autoloader',
202
+			EE_CORE . 'helpers/EEH_Autoloader.helper.php'
203
+		);
204
+		EEH_Autoloader::instance();
205
+	}
206 206
 
207 207
 
208
-    /**
209
-     * load_required_files
210
-     *
211
-     * @throws EE_Error
212
-     */
213
-    protected function setAutoloadersForRequiredFiles()
214
-    {
215
-        // load interfaces
216
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
217
-        // load helpers
218
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219
-        // register legacy request stack classes just in case
220
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
221
-        // register legacy middleware classes just in case
222
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
223
-    }
208
+	/**
209
+	 * load_required_files
210
+	 *
211
+	 * @throws EE_Error
212
+	 */
213
+	protected function setAutoloadersForRequiredFiles()
214
+	{
215
+		// load interfaces
216
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
217
+		// load helpers
218
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219
+		// register legacy request stack classes just in case
220
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
221
+		// register legacy middleware classes just in case
222
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
223
+	}
224 224
 
225 225
 
226
-    /**
227
-     * build_request_stack
228
-     *
229
-     * @return RequestStackBuilder
230
-     */
231
-    public function buildRequestStack()
232
-    {
233
-        $request_stack_builder = new RequestStackBuilder($this->loader);
234
-        /**
235
-         * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
236
-         * so items at the beginning of the final middleware stack will run last.
237
-         * First parameter is the middleware classname, second is an array of arguments
238
-         */
239
-        $stack_apps = apply_filters(
240
-            'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
241
-            array(
242
-                // first in last out
243
-                'EventEspresso\core\services\request\middleware\BotDetector'                 => array(),
244
-                'EventEspresso\core\services\request\middleware\DetectFileEditorRequest'     => array(),
245
-                'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(),
246
-                'EventEspresso\core\services\request\middleware\RecommendedVersions'         => array(),
247
-                // last in first out
248
-                'EventEspresso\core\services\request\middleware\DetectLogin'                 => array(),
249
-            )
250
-        );
251
-        // legacy filter for backwards compatibility
252
-        $stack_apps = apply_filters(
253
-            'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
254
-            $stack_apps
255
-        );
256
-        // load middleware onto stack : FILO (First In Last Out)
257
-        // items at the beginning of the $stack_apps array will run last
258
-        foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
259
-            $request_stack_builder->push(array($stack_app, $stack_app_args));
260
-        }
261
-        // finally, we'll add this on its own because we need it to always be part of the stack
262
-        // and we also need it to always run first because the rest of the system relies on it
263
-        $request_stack_builder->push(
264
-            array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array())
265
-        );
266
-        return apply_filters(
267
-            'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
268
-            $request_stack_builder
269
-        );
270
-    }
226
+	/**
227
+	 * build_request_stack
228
+	 *
229
+	 * @return RequestStackBuilder
230
+	 */
231
+	public function buildRequestStack()
232
+	{
233
+		$request_stack_builder = new RequestStackBuilder($this->loader);
234
+		/**
235
+		 * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
236
+		 * so items at the beginning of the final middleware stack will run last.
237
+		 * First parameter is the middleware classname, second is an array of arguments
238
+		 */
239
+		$stack_apps = apply_filters(
240
+			'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
241
+			array(
242
+				// first in last out
243
+				'EventEspresso\core\services\request\middleware\BotDetector'                 => array(),
244
+				'EventEspresso\core\services\request\middleware\DetectFileEditorRequest'     => array(),
245
+				'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(),
246
+				'EventEspresso\core\services\request\middleware\RecommendedVersions'         => array(),
247
+				// last in first out
248
+				'EventEspresso\core\services\request\middleware\DetectLogin'                 => array(),
249
+			)
250
+		);
251
+		// legacy filter for backwards compatibility
252
+		$stack_apps = apply_filters(
253
+			'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
254
+			$stack_apps
255
+		);
256
+		// load middleware onto stack : FILO (First In Last Out)
257
+		// items at the beginning of the $stack_apps array will run last
258
+		foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
259
+			$request_stack_builder->push(array($stack_app, $stack_app_args));
260
+		}
261
+		// finally, we'll add this on its own because we need it to always be part of the stack
262
+		// and we also need it to always run first because the rest of the system relies on it
263
+		$request_stack_builder->push(
264
+			array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array())
265
+		);
266
+		return apply_filters(
267
+			'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
268
+			$request_stack_builder
269
+		);
270
+	}
271 271
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         // load interfaces
200 200
         espresso_load_required(
201 201
             'EEH_Autoloader',
202
-            EE_CORE . 'helpers/EEH_Autoloader.helper.php'
202
+            EE_CORE.'helpers/EEH_Autoloader.helper.php'
203 203
         );
204 204
         EEH_Autoloader::instance();
205 205
     }
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
     protected function setAutoloadersForRequiredFiles()
214 214
     {
215 215
         // load interfaces
216
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
216
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces', true);
217 217
         // load helpers
218 218
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219 219
         // register legacy request stack classes just in case
220
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
220
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack/');
221 221
         // register legacy middleware classes just in case
222
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
222
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware/');
223 223
     }
224 224
 
225 225
 
Please login to merge, or discard this patch.
core/services/container/OpenCoffeeShop.php 2 patches
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -20,192 +20,192 @@
 block discarded – undo
20 20
 class OpenCoffeeShop
21 21
 {
22 22
 
23
-    /**
24
-     * @var CoffeeShop $CoffeeShop
25
-     */
26
-    private $CoffeeShop;
23
+	/**
24
+	 * @var CoffeeShop $CoffeeShop
25
+	 */
26
+	private $CoffeeShop;
27 27
 
28 28
 
29
-    /**
30
-     * OpenCoffeeShop constructor
31
-     *
32
-     * @throws InvalidInterfaceException
33
-     */
34
-    public function __construct()
35
-    {
36
-        // instantiate the DI container
37
-        $this->CoffeeShop = new CoffeeShop();
38
-    }
29
+	/**
30
+	 * OpenCoffeeShop constructor
31
+	 *
32
+	 * @throws InvalidInterfaceException
33
+	 */
34
+	public function __construct()
35
+	{
36
+		// instantiate the DI container
37
+		$this->CoffeeShop = new CoffeeShop();
38
+	}
39 39
 
40 40
 
41
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
42
-    /**
43
-     * @return CoffeeShop
44
-     */
45
-    public function CoffeeShop()
46
-    {
47
-        return $this->CoffeeShop;
48
-    }
41
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
42
+	/**
43
+	 * @return CoffeeShop
44
+	 */
45
+	public function CoffeeShop()
46
+	{
47
+		return $this->CoffeeShop;
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * configure coffee makers which control the different kinds of brews
53
-     * ( shared services, new factory objects, etc )
54
-     *
55
-     * @throws InvalidEntityException
56
-     */
57
-    public function setupCoffeeMakers()
58
-    {
59
-        // create a dependency injector class for resolving class constructor arguments
60
-        $DependencyInjector = new DependencyInjector(
61
-            $this->CoffeeShop,
62
-            new \EEH_Array()
63
-        );
64
-        // and some coffeemakers, one for creating new instances
65
-        $this->CoffeeShop->addCoffeeMaker(
66
-            new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector),
67
-            CoffeeMaker::BREW_NEW
68
-        );
69
-        // one for shared services
70
-        $this->CoffeeShop->addCoffeeMaker(
71
-            new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector),
72
-            CoffeeMaker::BREW_SHARED
73
-        );
74
-        // and one for classes that only get loaded
75
-        $this->CoffeeShop->addCoffeeMaker(
76
-            new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector),
77
-            CoffeeMaker::BREW_LOAD_ONLY
78
-        );
79
-    }
51
+	/**
52
+	 * configure coffee makers which control the different kinds of brews
53
+	 * ( shared services, new factory objects, etc )
54
+	 *
55
+	 * @throws InvalidEntityException
56
+	 */
57
+	public function setupCoffeeMakers()
58
+	{
59
+		// create a dependency injector class for resolving class constructor arguments
60
+		$DependencyInjector = new DependencyInjector(
61
+			$this->CoffeeShop,
62
+			new \EEH_Array()
63
+		);
64
+		// and some coffeemakers, one for creating new instances
65
+		$this->CoffeeShop->addCoffeeMaker(
66
+			new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector),
67
+			CoffeeMaker::BREW_NEW
68
+		);
69
+		// one for shared services
70
+		$this->CoffeeShop->addCoffeeMaker(
71
+			new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector),
72
+			CoffeeMaker::BREW_SHARED
73
+		);
74
+		// and one for classes that only get loaded
75
+		$this->CoffeeShop->addCoffeeMaker(
76
+			new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector),
77
+			CoffeeMaker::BREW_LOAD_ONLY
78
+		);
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * Recipes define how to load legacy classes
84
-     *
85
-     * @throws InvalidIdentifierException
86
-     */
87
-    public function addRecipes()
88
-    {
89
-        // add default recipe, which should handle loading for most PSR-4 compatible classes
90
-        // as long as they are not type hinting for interfaces
91
-        $this->CoffeeShop->addRecipe(
92
-            new Recipe(
93
-                Recipe::DEFAULT_ID
94
-            )
95
-        );
96
-        // PSR-4 compatible class with aliases
97
-        $this->CoffeeShop->addRecipe(
98
-            new Recipe(
99
-                'CommandHandlerManager',
100
-                'EventEspresso\core\services\commands\CommandHandlerManager',
101
-                array(
102
-                    'CommandHandlerManagerInterface',
103
-                    'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
104
-                ),
105
-                array(),
106
-                CoffeeMaker::BREW_SHARED
107
-            )
108
-        );
109
-        // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager
110
-        $this->CoffeeShop->addRecipe(
111
-            new Recipe(
112
-                'CommandBus',
113
-                'EventEspresso\core\services\commands\CommandBus',
114
-                array(
115
-                    'CommandBusInterface',
116
-                    'EventEspresso\core\services\commands\CommandBusInterface',
117
-                ),
118
-                array(),
119
-                CoffeeMaker::BREW_SHARED
120
-            )
121
-        );
122
-        // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath
123
-        // add a wildcard recipe for loading legacy core interfaces
124
-        $this->CoffeeShop->addRecipe(
125
-            new Recipe(
126
-                'EEI_*',
127
-                '',
128
-                array(),
129
-                array(),
130
-                CoffeeMaker::BREW_LOAD_ONLY,
131
-                array(
132
-                    EE_INTERFACES . '*.php',
133
-                    EE_INTERFACES . '*.interfaces.php',
134
-                )
135
-            )
136
-        );
137
-        // add a wildcard recipe for loading models
138
-        $this->CoffeeShop->addRecipe(
139
-            new Recipe(
140
-                'EEM_*',
141
-                '',
142
-                array(),
143
-                array(),
144
-                CoffeeMaker::BREW_SHARED,
145
-                EE_MODELS . '*.model.php'
146
-            )
147
-        );
148
-        // add a wildcard recipe for loading core classes
149
-        $this->CoffeeShop->addRecipe(
150
-            new Recipe(
151
-                'EE_*',
152
-                '',
153
-                array(),
154
-                array(),
155
-                CoffeeMaker::BREW_SHARED,
156
-                array(
157
-                    EE_CORE . '*.core.php',
158
-                    EE_ADMIN . '*.core.php',
159
-                    EE_CPTS . '*.core.php',
160
-                    EE_CORE . 'data_migration_scripts/*.core.php',
161
-                )
162
-            )
163
-        );
164
-        // load admin page parent class
165
-        $this->CoffeeShop->addRecipe(
166
-            new Recipe(
167
-                'EE_Admin_Page*',
168
-                '',
169
-                array(),
170
-                array(),
171
-                CoffeeMaker::BREW_LOAD_ONLY,
172
-                array(EE_ADMIN . '*.core.php')
173
-            )
174
-        );
175
-        // add a wildcard recipe for loading core classes
176
-        // $this->CoffeeShop->addRecipe(
177
-        //     new Recipe(
178
-        //         '*_Admin_Page',
179
-        //         '',
180
-        //         array(),
181
-        //         array(),
182
-        //         CoffeeMaker::BREW_SHARED,
183
-        //         array(
184
-        //             EE_ADMIN_PAGES . 'transactions/*.core.php',
185
-        //         )
186
-        //     )
187
-        // );
188
-    }
82
+	/**
83
+	 * Recipes define how to load legacy classes
84
+	 *
85
+	 * @throws InvalidIdentifierException
86
+	 */
87
+	public function addRecipes()
88
+	{
89
+		// add default recipe, which should handle loading for most PSR-4 compatible classes
90
+		// as long as they are not type hinting for interfaces
91
+		$this->CoffeeShop->addRecipe(
92
+			new Recipe(
93
+				Recipe::DEFAULT_ID
94
+			)
95
+		);
96
+		// PSR-4 compatible class with aliases
97
+		$this->CoffeeShop->addRecipe(
98
+			new Recipe(
99
+				'CommandHandlerManager',
100
+				'EventEspresso\core\services\commands\CommandHandlerManager',
101
+				array(
102
+					'CommandHandlerManagerInterface',
103
+					'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
104
+				),
105
+				array(),
106
+				CoffeeMaker::BREW_SHARED
107
+			)
108
+		);
109
+		// PSR-4 compatible class with aliases, which dependency on CommandHandlerManager
110
+		$this->CoffeeShop->addRecipe(
111
+			new Recipe(
112
+				'CommandBus',
113
+				'EventEspresso\core\services\commands\CommandBus',
114
+				array(
115
+					'CommandBusInterface',
116
+					'EventEspresso\core\services\commands\CommandBusInterface',
117
+				),
118
+				array(),
119
+				CoffeeMaker::BREW_SHARED
120
+			)
121
+		);
122
+		// LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath
123
+		// add a wildcard recipe for loading legacy core interfaces
124
+		$this->CoffeeShop->addRecipe(
125
+			new Recipe(
126
+				'EEI_*',
127
+				'',
128
+				array(),
129
+				array(),
130
+				CoffeeMaker::BREW_LOAD_ONLY,
131
+				array(
132
+					EE_INTERFACES . '*.php',
133
+					EE_INTERFACES . '*.interfaces.php',
134
+				)
135
+			)
136
+		);
137
+		// add a wildcard recipe for loading models
138
+		$this->CoffeeShop->addRecipe(
139
+			new Recipe(
140
+				'EEM_*',
141
+				'',
142
+				array(),
143
+				array(),
144
+				CoffeeMaker::BREW_SHARED,
145
+				EE_MODELS . '*.model.php'
146
+			)
147
+		);
148
+		// add a wildcard recipe for loading core classes
149
+		$this->CoffeeShop->addRecipe(
150
+			new Recipe(
151
+				'EE_*',
152
+				'',
153
+				array(),
154
+				array(),
155
+				CoffeeMaker::BREW_SHARED,
156
+				array(
157
+					EE_CORE . '*.core.php',
158
+					EE_ADMIN . '*.core.php',
159
+					EE_CPTS . '*.core.php',
160
+					EE_CORE . 'data_migration_scripts/*.core.php',
161
+				)
162
+			)
163
+		);
164
+		// load admin page parent class
165
+		$this->CoffeeShop->addRecipe(
166
+			new Recipe(
167
+				'EE_Admin_Page*',
168
+				'',
169
+				array(),
170
+				array(),
171
+				CoffeeMaker::BREW_LOAD_ONLY,
172
+				array(EE_ADMIN . '*.core.php')
173
+			)
174
+		);
175
+		// add a wildcard recipe for loading core classes
176
+		// $this->CoffeeShop->addRecipe(
177
+		//     new Recipe(
178
+		//         '*_Admin_Page',
179
+		//         '',
180
+		//         array(),
181
+		//         array(),
182
+		//         CoffeeMaker::BREW_SHARED,
183
+		//         array(
184
+		//             EE_ADMIN_PAGES . 'transactions/*.core.php',
185
+		//         )
186
+		//     )
187
+		// );
188
+	}
189 189
 
190 190
 
191
-    /**
192
-     * bootstrap EE and the request stack
193
-     *
194
-     * @throws ServiceNotFoundException
195
-     * @throws InvalidClassException
196
-     * @throws InvalidDataTypeException
197
-     * @throws InvalidIdentifierException
198
-     * @throws exceptions\ServiceExistsException
199
-     * @throws OutOfBoundsException
200
-     * @throws exceptions\InstantiationException
201
-     */
202
-    public function firstBrew()
203
-    {
204
-        $this->CoffeeShop->brew(
205
-            'EventEspresso\core\services\request\Request',
206
-            array($_GET, $_POST, $_COOKIE, $_SERVER)
207
-        );
208
-        $this->CoffeeShop->brew('EventEspresso\core\services\request\Response');
209
-        $this->CoffeeShop->brew('EE_Bootstrap');
210
-    }
191
+	/**
192
+	 * bootstrap EE and the request stack
193
+	 *
194
+	 * @throws ServiceNotFoundException
195
+	 * @throws InvalidClassException
196
+	 * @throws InvalidDataTypeException
197
+	 * @throws InvalidIdentifierException
198
+	 * @throws exceptions\ServiceExistsException
199
+	 * @throws OutOfBoundsException
200
+	 * @throws exceptions\InstantiationException
201
+	 */
202
+	public function firstBrew()
203
+	{
204
+		$this->CoffeeShop->brew(
205
+			'EventEspresso\core\services\request\Request',
206
+			array($_GET, $_POST, $_COOKIE, $_SERVER)
207
+		);
208
+		$this->CoffeeShop->brew('EventEspresso\core\services\request\Response');
209
+		$this->CoffeeShop->brew('EE_Bootstrap');
210
+	}
211 211
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
                 array(),
130 130
                 CoffeeMaker::BREW_LOAD_ONLY,
131 131
                 array(
132
-                    EE_INTERFACES . '*.php',
133
-                    EE_INTERFACES . '*.interfaces.php',
132
+                    EE_INTERFACES.'*.php',
133
+                    EE_INTERFACES.'*.interfaces.php',
134 134
                 )
135 135
             )
136 136
         );
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                 array(),
143 143
                 array(),
144 144
                 CoffeeMaker::BREW_SHARED,
145
-                EE_MODELS . '*.model.php'
145
+                EE_MODELS.'*.model.php'
146 146
             )
147 147
         );
148 148
         // add a wildcard recipe for loading core classes
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
                 array(),
155 155
                 CoffeeMaker::BREW_SHARED,
156 156
                 array(
157
-                    EE_CORE . '*.core.php',
158
-                    EE_ADMIN . '*.core.php',
159
-                    EE_CPTS . '*.core.php',
160
-                    EE_CORE . 'data_migration_scripts/*.core.php',
157
+                    EE_CORE.'*.core.php',
158
+                    EE_ADMIN.'*.core.php',
159
+                    EE_CPTS.'*.core.php',
160
+                    EE_CORE.'data_migration_scripts/*.core.php',
161 161
                 )
162 162
             )
163 163
         );
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
                 array(),
170 170
                 array(),
171 171
                 CoffeeMaker::BREW_LOAD_ONLY,
172
-                array(EE_ADMIN . '*.core.php')
172
+                array(EE_ADMIN.'*.core.php')
173 173
             )
174 174
         );
175 175
         // add a wildcard recipe for loading core classes
Please login to merge, or discard this patch.
core/services/licensing/LicenseService.php 2 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -15,94 +15,94 @@
 block discarded – undo
15 15
  */
16 16
 class LicenseService
17 17
 {
18
-    /**
19
-     * @var Config
20
-     */
21
-    private $config;
22
-
23
-
24
-    /**
25
-     * @var Stats
26
-     */
27
-    private $stats_collection;
28
-
29
-    public function __construct(Stats $stats_collection, Config $config)
30
-    {
31
-        $this->config = $config;
32
-        $this->stats_collection = $stats_collection;
33
-        $this->loadPueClient();
34
-    }
35
-
36
-    private function loadPueClient()
37
-    {
38
-        // PUE Auto Upgrades stuff
39
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
40
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
41
-
42
-            // $options needs to be an array with the included keys as listed.
43
-            $options = array(
44
-                // 'optionName' => '', //(optional) - used as the reference for saving update information in the
45
-                // clients options table.  Will be automatically set if left blank.
46
-                'apikey'                => $this->config->siteLicenseKey(),
47
-                // (required), you will need to obtain the apikey that the client gets from your site and
48
-                // then saves in their sites options table (see 'getting an api-key' below)
49
-                'lang_domain'           => $this->config->i18nDomain(),
50
-                // (optional) - put here whatever reference you are using for the localization of your plugin (if it's
51
-                // localized).  That way strings in this file will be included in the translation for your plugin.
52
-                'checkPeriod'           => $this->config->checkPeriod(),
53
-                // (optional) - use this parameter to indicate how often you want the client's install to ping your
54
-                // server for update checks.  The integer indicates hours.  If you don't include this parameter it will
55
-                // default to 12 hours.
56
-                'option_key'            => $this->config->optionKey(),
57
-                // this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
58
-                // updating your information message whenever this option_key is modified.
59
-                'options_page_slug'     => $this->config->optionsPageSlug(),
60
-                'plugin_basename'       => EE_PLUGIN_BASENAME,
61
-                'use_wp_update'         => true,
62
-                // if TRUE then you want FREE versions of the plugin to be updated from WP
63
-                'extra_stats'           => $this->stats_collection->statsCallback(),
64
-                'turn_on_notices_saved' => true,
65
-            );
66
-            // initiate the class and start the plugin update engine!
67
-            new PluginUpdateEngineChecker(
68
-                $this->config->hostServerUrl(),
69
-                $this->config->pluginSlug(),
70
-                $options
71
-            );
72
-        }
73
-    }
74
-
75
-
76
-    /**
77
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
78
-     *
79
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
80
-     *                          identify plugins. Defaults to core update
81
-     * @return boolean           True if update available, false if not.
82
-     */
83
-    public static function isUpdateAvailable($basename = '')
84
-    {
85
-        $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
86
-
87
-        $update = false;
88
-
89
-        // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
90
-        $folder = '/' . dirname($basename);
91
-
92
-        $plugins = get_plugins($folder);
93
-        $current = get_site_transient('update_plugins');
94
-
95
-        foreach ((array) $plugins as $plugin_file => $plugin_data) {
96
-            if (isset($current->response['plugin_file'])) {
97
-                $update = true;
98
-            }
99
-        }
100
-
101
-        // it's possible that there is an update but an invalid site-license-key is in use
102
-        if (get_site_option('pue_json_error_' . $basename)) {
103
-            $update = true;
104
-        }
105
-
106
-        return $update;
107
-    }
18
+	/**
19
+	 * @var Config
20
+	 */
21
+	private $config;
22
+
23
+
24
+	/**
25
+	 * @var Stats
26
+	 */
27
+	private $stats_collection;
28
+
29
+	public function __construct(Stats $stats_collection, Config $config)
30
+	{
31
+		$this->config = $config;
32
+		$this->stats_collection = $stats_collection;
33
+		$this->loadPueClient();
34
+	}
35
+
36
+	private function loadPueClient()
37
+	{
38
+		// PUE Auto Upgrades stuff
39
+		if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
40
+			require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
41
+
42
+			// $options needs to be an array with the included keys as listed.
43
+			$options = array(
44
+				// 'optionName' => '', //(optional) - used as the reference for saving update information in the
45
+				// clients options table.  Will be automatically set if left blank.
46
+				'apikey'                => $this->config->siteLicenseKey(),
47
+				// (required), you will need to obtain the apikey that the client gets from your site and
48
+				// then saves in their sites options table (see 'getting an api-key' below)
49
+				'lang_domain'           => $this->config->i18nDomain(),
50
+				// (optional) - put here whatever reference you are using for the localization of your plugin (if it's
51
+				// localized).  That way strings in this file will be included in the translation for your plugin.
52
+				'checkPeriod'           => $this->config->checkPeriod(),
53
+				// (optional) - use this parameter to indicate how often you want the client's install to ping your
54
+				// server for update checks.  The integer indicates hours.  If you don't include this parameter it will
55
+				// default to 12 hours.
56
+				'option_key'            => $this->config->optionKey(),
57
+				// this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
58
+				// updating your information message whenever this option_key is modified.
59
+				'options_page_slug'     => $this->config->optionsPageSlug(),
60
+				'plugin_basename'       => EE_PLUGIN_BASENAME,
61
+				'use_wp_update'         => true,
62
+				// if TRUE then you want FREE versions of the plugin to be updated from WP
63
+				'extra_stats'           => $this->stats_collection->statsCallback(),
64
+				'turn_on_notices_saved' => true,
65
+			);
66
+			// initiate the class and start the plugin update engine!
67
+			new PluginUpdateEngineChecker(
68
+				$this->config->hostServerUrl(),
69
+				$this->config->pluginSlug(),
70
+				$options
71
+			);
72
+		}
73
+	}
74
+
75
+
76
+	/**
77
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
78
+	 *
79
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
80
+	 *                          identify plugins. Defaults to core update
81
+	 * @return boolean           True if update available, false if not.
82
+	 */
83
+	public static function isUpdateAvailable($basename = '')
84
+	{
85
+		$basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
86
+
87
+		$update = false;
88
+
89
+		// should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
90
+		$folder = '/' . dirname($basename);
91
+
92
+		$plugins = get_plugins($folder);
93
+		$current = get_site_transient('update_plugins');
94
+
95
+		foreach ((array) $plugins as $plugin_file => $plugin_data) {
96
+			if (isset($current->response['plugin_file'])) {
97
+				$update = true;
98
+			}
99
+		}
100
+
101
+		// it's possible that there is an update but an invalid site-license-key is in use
102
+		if (get_site_option('pue_json_error_' . $basename)) {
103
+			$update = true;
104
+		}
105
+
106
+		return $update;
107
+	}
108 108
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
     private function loadPueClient()
37 37
     {
38 38
         // PUE Auto Upgrades stuff
39
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
40
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
39
+        if (is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) { // include the file
40
+            require_once(EE_THIRD_PARTY.'pue/pue-client.php');
41 41
 
42 42
             // $options needs to be an array with the included keys as listed.
43 43
             $options = array(
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $update = false;
88 88
 
89 89
         // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
90
-        $folder = '/' . dirname($basename);
90
+        $folder = '/'.dirname($basename);
91 91
 
92 92
         $plugins = get_plugins($folder);
93 93
         $current = get_site_transient('update_plugins');
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         }
100 100
 
101 101
         // it's possible that there is an update but an invalid site-license-key is in use
102
-        if (get_site_option('pue_json_error_' . $basename)) {
102
+        if (get_site_option('pue_json_error_'.$basename)) {
103 103
             $update = true;
104 104
         }
105 105
 
Please login to merge, or discard this patch.
core/services/notifications/PersistentAdminNoticeManager.php 2 patches
Indentation   +381 added lines, -381 removed lines patch added patch discarded remove patch
@@ -31,385 +31,385 @@
 block discarded – undo
31 31
 class PersistentAdminNoticeManager
32 32
 {
33 33
 
34
-    const WP_OPTION_KEY = 'ee_pers_admin_notices';
35
-
36
-    /**
37
-     * @var Collection|PersistentAdminNotice[] $notice_collection
38
-     */
39
-    private $notice_collection;
40
-
41
-    /**
42
-     * if AJAX is not enabled, then the return URL will be used for redirecting back to the admin page where the
43
-     * persistent admin notice was displayed, and ultimately dismissed from.
44
-     *
45
-     * @var string $return_url
46
-     */
47
-    private $return_url;
48
-
49
-    /**
50
-     * @var CapabilitiesChecker $capabilities_checker
51
-     */
52
-    private $capabilities_checker;
53
-
54
-    /**
55
-     * @var RequestInterface $request
56
-     */
57
-    private $request;
58
-
59
-
60
-    /**
61
-     * PersistentAdminNoticeManager constructor
62
-     *
63
-     * @param string              $return_url where to  redirect to after dismissing notices
64
-     * @param CapabilitiesChecker $capabilities_checker
65
-     * @param RequestInterface          $request
66
-     * @throws InvalidDataTypeException
67
-     */
68
-    public function __construct($return_url = '', CapabilitiesChecker $capabilities_checker, RequestInterface $request)
69
-    {
70
-        $this->setReturnUrl($return_url);
71
-        $this->capabilities_checker = $capabilities_checker;
72
-        $this->request = $request;
73
-        // setup up notices at priority 9 because `EE_Admin::display_admin_notices()` runs at priority 10,
74
-        // and we want to retrieve and generate any nag notices at the last possible moment
75
-        add_action('admin_notices', array($this, 'displayNotices'), 9);
76
-        add_action('network_admin_notices', array($this, 'displayNotices'), 9);
77
-        add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismissNotice'));
78
-        add_action('shutdown', array($this, 'registerAndSaveNotices'), 998);
79
-    }
80
-
81
-
82
-    /**
83
-     * @param string $return_url
84
-     * @throws InvalidDataTypeException
85
-     */
86
-    public function setReturnUrl($return_url)
87
-    {
88
-        if (! is_string($return_url)) {
89
-            throw new InvalidDataTypeException('$return_url', $return_url, 'string');
90
-        }
91
-        $this->return_url = $return_url;
92
-    }
93
-
94
-
95
-    /**
96
-     * @return Collection
97
-     * @throws InvalidEntityException
98
-     * @throws InvalidInterfaceException
99
-     * @throws InvalidDataTypeException
100
-     * @throws DomainException
101
-     * @throws DuplicateCollectionIdentifierException
102
-     */
103
-    protected function getPersistentAdminNoticeCollection()
104
-    {
105
-        if (! $this->notice_collection instanceof Collection) {
106
-            $this->notice_collection = new Collection(
107
-                'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
108
-            );
109
-            $this->retrieveStoredNotices();
110
-            $this->registerNotices();
111
-        }
112
-        return $this->notice_collection;
113
-    }
114
-
115
-
116
-    /**
117
-     * generates PersistentAdminNotice objects for all non-dismissed notices saved to the db
118
-     *
119
-     * @return void
120
-     * @throws InvalidEntityException
121
-     * @throws DomainException
122
-     * @throws InvalidDataTypeException
123
-     * @throws DuplicateCollectionIdentifierException
124
-     */
125
-    protected function retrieveStoredNotices()
126
-    {
127
-        $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array());
128
-        if (! empty($persistent_admin_notices)) {
129
-            foreach ($persistent_admin_notices as $name => $details) {
130
-                if (is_array($details)) {
131
-                    if (! isset(
132
-                        $details['message'],
133
-                        $details['capability'],
134
-                        $details['cap_context'],
135
-                        $details['dismissed']
136
-                    )) {
137
-                        throw new DomainException(
138
-                            sprintf(
139
-                                esc_html__(
140
-                                    'The "%1$s" PersistentAdminNotice could not be retrieved from the database.',
141
-                                    'event_espresso'
142
-                                ),
143
-                                $name
144
-                            )
145
-                        );
146
-                    }
147
-                    // new format for nag notices
148
-                    $this->notice_collection->add(
149
-                        new PersistentAdminNotice(
150
-                            $name,
151
-                            $details['message'],
152
-                            false,
153
-                            $details['capability'],
154
-                            $details['cap_context'],
155
-                            $details['dismissed']
156
-                        ),
157
-                        sanitize_key($name)
158
-                    );
159
-                } else {
160
-                    try {
161
-                        // old nag notices, that we want to convert to the new format
162
-                        $this->notice_collection->add(
163
-                            new PersistentAdminNotice(
164
-                                $name,
165
-                                (string) $details,
166
-                                false,
167
-                                '',
168
-                                '',
169
-                                empty($details)
170
-                            ),
171
-                            sanitize_key($name)
172
-                        );
173
-                    } catch (Exception $e) {
174
-                        EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
175
-                    }
176
-                }
177
-                // each notice will self register when the action hook in registerNotices is triggered
178
-            }
179
-        }
180
-    }
181
-
182
-
183
-    /**
184
-     * exposes the Persistent Admin Notice Collection via an action
185
-     * so that PersistentAdminNotice objects can be added and/or removed
186
-     * without compromising the actual collection like a filter would
187
-     */
188
-    protected function registerNotices()
189
-    {
190
-        do_action(
191
-            'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
192
-            $this->notice_collection
193
-        );
194
-    }
195
-
196
-
197
-    /**
198
-     * @throws DomainException
199
-     * @throws InvalidClassException
200
-     * @throws InvalidDataTypeException
201
-     * @throws InvalidInterfaceException
202
-     * @throws InvalidEntityException
203
-     * @throws DuplicateCollectionIdentifierException
204
-     */
205
-    public function displayNotices()
206
-    {
207
-        $this->notice_collection = $this->getPersistentAdminNoticeCollection();
208
-        if ($this->notice_collection->hasObjects()) {
209
-            $enqueue_assets = false;
210
-            // and display notices
211
-            foreach ($this->notice_collection as $persistent_admin_notice) {
212
-                /** @var PersistentAdminNotice $persistent_admin_notice */
213
-                // don't display notices that have already been dismissed
214
-                if ($persistent_admin_notice->getDismissed()) {
215
-                    continue;
216
-                }
217
-                try {
218
-                    $this->capabilities_checker->processCapCheck(
219
-                        $persistent_admin_notice->getCapCheck()
220
-                    );
221
-                } catch (InsufficientPermissionsException $e) {
222
-                    // user does not have required cap, so skip to next notice
223
-                    // and just eat the exception - nom nom nom nom
224
-                    continue;
225
-                }
226
-                if ($persistent_admin_notice->getMessage() === '') {
227
-                    continue;
228
-                }
229
-                $this->displayPersistentAdminNotice($persistent_admin_notice);
230
-                $enqueue_assets = true;
231
-            }
232
-            if ($enqueue_assets) {
233
-                $this->enqueueAssets();
234
-            }
235
-        }
236
-    }
237
-
238
-
239
-    /**
240
-     * does what it's named
241
-     *
242
-     * @return void
243
-     */
244
-    public function enqueueAssets()
245
-    {
246
-        wp_register_script(
247
-            'espresso_core',
248
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
249
-            array('jquery'),
250
-            EVENT_ESPRESSO_VERSION,
251
-            true
252
-        );
253
-        wp_register_script(
254
-            'ee_error_js',
255
-            EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
256
-            array('espresso_core'),
257
-            EVENT_ESPRESSO_VERSION,
258
-            true
259
-        );
260
-        wp_localize_script(
261
-            'ee_error_js',
262
-            'ee_dismiss',
263
-            array(
264
-                'return_url'    => urlencode($this->return_url),
265
-                'ajax_url'      => WP_AJAX_URL,
266
-                'unknown_error' => esc_html__(
267
-                    'An unknown error has occurred on the server while attempting to dismiss this notice.',
268
-                    'event_espresso'
269
-                ),
270
-            )
271
-        );
272
-        wp_enqueue_script('ee_error_js');
273
-    }
274
-
275
-
276
-    /**
277
-     * displayPersistentAdminNoticeHtml
278
-     *
279
-     * @param  PersistentAdminNotice $persistent_admin_notice
280
-     */
281
-    protected function displayPersistentAdminNotice(PersistentAdminNotice $persistent_admin_notice)
282
-    {
283
-        // used in template
284
-        $persistent_admin_notice_name = $persistent_admin_notice->getName();
285
-        $persistent_admin_notice_message = $persistent_admin_notice->getMessage();
286
-        require EE_TEMPLATES . '/notifications/persistent_admin_notice.template.php';
287
-    }
288
-
289
-
290
-    /**
291
-     * dismissNotice
292
-     *
293
-     * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
294
-     * @param bool   $purge    if true, then delete it from the db
295
-     * @param bool   $return   forget all of this AJAX or redirect nonsense, and just return
296
-     * @return void
297
-     * @throws InvalidEntityException
298
-     * @throws InvalidInterfaceException
299
-     * @throws InvalidDataTypeException
300
-     * @throws DomainException
301
-     * @throws InvalidArgumentException
302
-     * @throws InvalidArgumentException
303
-     * @throws InvalidArgumentException
304
-     * @throws InvalidArgumentException
305
-     * @throws DuplicateCollectionIdentifierException
306
-     */
307
-    public function dismissNotice($pan_name = '', $purge = false, $return = false)
308
-    {
309
-        $pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name);
310
-        $this->notice_collection = $this->getPersistentAdminNoticeCollection();
311
-        if (! empty($pan_name) && $this->notice_collection->has($pan_name)) {
312
-            /** @var PersistentAdminNotice $persistent_admin_notice */
313
-            $persistent_admin_notice = $this->notice_collection->get($pan_name);
314
-            $persistent_admin_notice->setDismissed(true);
315
-            $persistent_admin_notice->setPurge($purge);
316
-            $this->saveNotices();
317
-        }
318
-        if ($return) {
319
-            return;
320
-        }
321
-        if ($this->request->isAjax()) {
322
-            // grab any notices and concatenate into string
323
-            echo wp_json_encode(
324
-                array(
325
-                    'errors' => implode('<br />', EE_Error::get_notices(false)),
326
-                )
327
-            );
328
-            exit();
329
-        }
330
-        // save errors to a transient to be displayed on next request (after redirect)
331
-        EE_Error::get_notices(false, true);
332
-        wp_safe_redirect(
333
-            urldecode(
334
-                $this->request->getRequestParam('return_url', '')
335
-            )
336
-        );
337
-    }
338
-
339
-
340
-    /**
341
-     * saveNotices
342
-     *
343
-     * @throws DomainException
344
-     * @throws InvalidDataTypeException
345
-     * @throws InvalidInterfaceException
346
-     * @throws InvalidEntityException
347
-     * @throws DuplicateCollectionIdentifierException
348
-     */
349
-    public function saveNotices()
350
-    {
351
-        $this->notice_collection = $this->getPersistentAdminNoticeCollection();
352
-        if ($this->notice_collection->hasObjects()) {
353
-            $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array());
354
-            // maybe initialize persistent_admin_notices
355
-            if (empty($persistent_admin_notices)) {
356
-                add_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array(), '', 'no');
357
-            }
358
-            foreach ($this->notice_collection as $persistent_admin_notice) {
359
-                // are we deleting this notice ?
360
-                if ($persistent_admin_notice->getPurge()) {
361
-                    unset($persistent_admin_notices[ $persistent_admin_notice->getName() ]);
362
-                } else {
363
-                    /** @var PersistentAdminNotice $persistent_admin_notice */
364
-                    $persistent_admin_notices[ $persistent_admin_notice->getName() ] = array(
365
-                        'message'     => $persistent_admin_notice->getMessage(),
366
-                        'capability'  => $persistent_admin_notice->getCapability(),
367
-                        'cap_context' => $persistent_admin_notice->getCapContext(),
368
-                        'dismissed'   => $persistent_admin_notice->getDismissed(),
369
-                    );
370
-                }
371
-            }
372
-            update_option(PersistentAdminNoticeManager::WP_OPTION_KEY, $persistent_admin_notices);
373
-        }
374
-    }
375
-
376
-
377
-    /**
378
-     * @throws DomainException
379
-     * @throws InvalidDataTypeException
380
-     * @throws InvalidEntityException
381
-     * @throws InvalidInterfaceException
382
-     * @throws DuplicateCollectionIdentifierException
383
-     */
384
-    public function registerAndSaveNotices()
385
-    {
386
-        $this->getPersistentAdminNoticeCollection();
387
-        $this->registerNotices();
388
-        $this->saveNotices();
389
-        add_filter(
390
-            'PersistentAdminNoticeManager__registerAndSaveNotices__complete',
391
-            '__return_true'
392
-        );
393
-    }
394
-
395
-
396
-    /**
397
-     * @throws DomainException
398
-     * @throws InvalidDataTypeException
399
-     * @throws InvalidEntityException
400
-     * @throws InvalidInterfaceException
401
-     * @throws InvalidArgumentException
402
-     * @throws DuplicateCollectionIdentifierException
403
-     */
404
-    public static function loadRegisterAndSaveNotices()
405
-    {
406
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
407
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
408
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
409
-        );
410
-        // if shutdown has already run, then call registerAndSaveNotices() manually
411
-        if (did_action('shutdown')) {
412
-            $persistent_admin_notice_manager->registerAndSaveNotices();
413
-        }
414
-    }
34
+	const WP_OPTION_KEY = 'ee_pers_admin_notices';
35
+
36
+	/**
37
+	 * @var Collection|PersistentAdminNotice[] $notice_collection
38
+	 */
39
+	private $notice_collection;
40
+
41
+	/**
42
+	 * if AJAX is not enabled, then the return URL will be used for redirecting back to the admin page where the
43
+	 * persistent admin notice was displayed, and ultimately dismissed from.
44
+	 *
45
+	 * @var string $return_url
46
+	 */
47
+	private $return_url;
48
+
49
+	/**
50
+	 * @var CapabilitiesChecker $capabilities_checker
51
+	 */
52
+	private $capabilities_checker;
53
+
54
+	/**
55
+	 * @var RequestInterface $request
56
+	 */
57
+	private $request;
58
+
59
+
60
+	/**
61
+	 * PersistentAdminNoticeManager constructor
62
+	 *
63
+	 * @param string              $return_url where to  redirect to after dismissing notices
64
+	 * @param CapabilitiesChecker $capabilities_checker
65
+	 * @param RequestInterface          $request
66
+	 * @throws InvalidDataTypeException
67
+	 */
68
+	public function __construct($return_url = '', CapabilitiesChecker $capabilities_checker, RequestInterface $request)
69
+	{
70
+		$this->setReturnUrl($return_url);
71
+		$this->capabilities_checker = $capabilities_checker;
72
+		$this->request = $request;
73
+		// setup up notices at priority 9 because `EE_Admin::display_admin_notices()` runs at priority 10,
74
+		// and we want to retrieve and generate any nag notices at the last possible moment
75
+		add_action('admin_notices', array($this, 'displayNotices'), 9);
76
+		add_action('network_admin_notices', array($this, 'displayNotices'), 9);
77
+		add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismissNotice'));
78
+		add_action('shutdown', array($this, 'registerAndSaveNotices'), 998);
79
+	}
80
+
81
+
82
+	/**
83
+	 * @param string $return_url
84
+	 * @throws InvalidDataTypeException
85
+	 */
86
+	public function setReturnUrl($return_url)
87
+	{
88
+		if (! is_string($return_url)) {
89
+			throw new InvalidDataTypeException('$return_url', $return_url, 'string');
90
+		}
91
+		$this->return_url = $return_url;
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return Collection
97
+	 * @throws InvalidEntityException
98
+	 * @throws InvalidInterfaceException
99
+	 * @throws InvalidDataTypeException
100
+	 * @throws DomainException
101
+	 * @throws DuplicateCollectionIdentifierException
102
+	 */
103
+	protected function getPersistentAdminNoticeCollection()
104
+	{
105
+		if (! $this->notice_collection instanceof Collection) {
106
+			$this->notice_collection = new Collection(
107
+				'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
108
+			);
109
+			$this->retrieveStoredNotices();
110
+			$this->registerNotices();
111
+		}
112
+		return $this->notice_collection;
113
+	}
114
+
115
+
116
+	/**
117
+	 * generates PersistentAdminNotice objects for all non-dismissed notices saved to the db
118
+	 *
119
+	 * @return void
120
+	 * @throws InvalidEntityException
121
+	 * @throws DomainException
122
+	 * @throws InvalidDataTypeException
123
+	 * @throws DuplicateCollectionIdentifierException
124
+	 */
125
+	protected function retrieveStoredNotices()
126
+	{
127
+		$persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array());
128
+		if (! empty($persistent_admin_notices)) {
129
+			foreach ($persistent_admin_notices as $name => $details) {
130
+				if (is_array($details)) {
131
+					if (! isset(
132
+						$details['message'],
133
+						$details['capability'],
134
+						$details['cap_context'],
135
+						$details['dismissed']
136
+					)) {
137
+						throw new DomainException(
138
+							sprintf(
139
+								esc_html__(
140
+									'The "%1$s" PersistentAdminNotice could not be retrieved from the database.',
141
+									'event_espresso'
142
+								),
143
+								$name
144
+							)
145
+						);
146
+					}
147
+					// new format for nag notices
148
+					$this->notice_collection->add(
149
+						new PersistentAdminNotice(
150
+							$name,
151
+							$details['message'],
152
+							false,
153
+							$details['capability'],
154
+							$details['cap_context'],
155
+							$details['dismissed']
156
+						),
157
+						sanitize_key($name)
158
+					);
159
+				} else {
160
+					try {
161
+						// old nag notices, that we want to convert to the new format
162
+						$this->notice_collection->add(
163
+							new PersistentAdminNotice(
164
+								$name,
165
+								(string) $details,
166
+								false,
167
+								'',
168
+								'',
169
+								empty($details)
170
+							),
171
+							sanitize_key($name)
172
+						);
173
+					} catch (Exception $e) {
174
+						EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
175
+					}
176
+				}
177
+				// each notice will self register when the action hook in registerNotices is triggered
178
+			}
179
+		}
180
+	}
181
+
182
+
183
+	/**
184
+	 * exposes the Persistent Admin Notice Collection via an action
185
+	 * so that PersistentAdminNotice objects can be added and/or removed
186
+	 * without compromising the actual collection like a filter would
187
+	 */
188
+	protected function registerNotices()
189
+	{
190
+		do_action(
191
+			'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
192
+			$this->notice_collection
193
+		);
194
+	}
195
+
196
+
197
+	/**
198
+	 * @throws DomainException
199
+	 * @throws InvalidClassException
200
+	 * @throws InvalidDataTypeException
201
+	 * @throws InvalidInterfaceException
202
+	 * @throws InvalidEntityException
203
+	 * @throws DuplicateCollectionIdentifierException
204
+	 */
205
+	public function displayNotices()
206
+	{
207
+		$this->notice_collection = $this->getPersistentAdminNoticeCollection();
208
+		if ($this->notice_collection->hasObjects()) {
209
+			$enqueue_assets = false;
210
+			// and display notices
211
+			foreach ($this->notice_collection as $persistent_admin_notice) {
212
+				/** @var PersistentAdminNotice $persistent_admin_notice */
213
+				// don't display notices that have already been dismissed
214
+				if ($persistent_admin_notice->getDismissed()) {
215
+					continue;
216
+				}
217
+				try {
218
+					$this->capabilities_checker->processCapCheck(
219
+						$persistent_admin_notice->getCapCheck()
220
+					);
221
+				} catch (InsufficientPermissionsException $e) {
222
+					// user does not have required cap, so skip to next notice
223
+					// and just eat the exception - nom nom nom nom
224
+					continue;
225
+				}
226
+				if ($persistent_admin_notice->getMessage() === '') {
227
+					continue;
228
+				}
229
+				$this->displayPersistentAdminNotice($persistent_admin_notice);
230
+				$enqueue_assets = true;
231
+			}
232
+			if ($enqueue_assets) {
233
+				$this->enqueueAssets();
234
+			}
235
+		}
236
+	}
237
+
238
+
239
+	/**
240
+	 * does what it's named
241
+	 *
242
+	 * @return void
243
+	 */
244
+	public function enqueueAssets()
245
+	{
246
+		wp_register_script(
247
+			'espresso_core',
248
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
249
+			array('jquery'),
250
+			EVENT_ESPRESSO_VERSION,
251
+			true
252
+		);
253
+		wp_register_script(
254
+			'ee_error_js',
255
+			EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
256
+			array('espresso_core'),
257
+			EVENT_ESPRESSO_VERSION,
258
+			true
259
+		);
260
+		wp_localize_script(
261
+			'ee_error_js',
262
+			'ee_dismiss',
263
+			array(
264
+				'return_url'    => urlencode($this->return_url),
265
+				'ajax_url'      => WP_AJAX_URL,
266
+				'unknown_error' => esc_html__(
267
+					'An unknown error has occurred on the server while attempting to dismiss this notice.',
268
+					'event_espresso'
269
+				),
270
+			)
271
+		);
272
+		wp_enqueue_script('ee_error_js');
273
+	}
274
+
275
+
276
+	/**
277
+	 * displayPersistentAdminNoticeHtml
278
+	 *
279
+	 * @param  PersistentAdminNotice $persistent_admin_notice
280
+	 */
281
+	protected function displayPersistentAdminNotice(PersistentAdminNotice $persistent_admin_notice)
282
+	{
283
+		// used in template
284
+		$persistent_admin_notice_name = $persistent_admin_notice->getName();
285
+		$persistent_admin_notice_message = $persistent_admin_notice->getMessage();
286
+		require EE_TEMPLATES . '/notifications/persistent_admin_notice.template.php';
287
+	}
288
+
289
+
290
+	/**
291
+	 * dismissNotice
292
+	 *
293
+	 * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
294
+	 * @param bool   $purge    if true, then delete it from the db
295
+	 * @param bool   $return   forget all of this AJAX or redirect nonsense, and just return
296
+	 * @return void
297
+	 * @throws InvalidEntityException
298
+	 * @throws InvalidInterfaceException
299
+	 * @throws InvalidDataTypeException
300
+	 * @throws DomainException
301
+	 * @throws InvalidArgumentException
302
+	 * @throws InvalidArgumentException
303
+	 * @throws InvalidArgumentException
304
+	 * @throws InvalidArgumentException
305
+	 * @throws DuplicateCollectionIdentifierException
306
+	 */
307
+	public function dismissNotice($pan_name = '', $purge = false, $return = false)
308
+	{
309
+		$pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name);
310
+		$this->notice_collection = $this->getPersistentAdminNoticeCollection();
311
+		if (! empty($pan_name) && $this->notice_collection->has($pan_name)) {
312
+			/** @var PersistentAdminNotice $persistent_admin_notice */
313
+			$persistent_admin_notice = $this->notice_collection->get($pan_name);
314
+			$persistent_admin_notice->setDismissed(true);
315
+			$persistent_admin_notice->setPurge($purge);
316
+			$this->saveNotices();
317
+		}
318
+		if ($return) {
319
+			return;
320
+		}
321
+		if ($this->request->isAjax()) {
322
+			// grab any notices and concatenate into string
323
+			echo wp_json_encode(
324
+				array(
325
+					'errors' => implode('<br />', EE_Error::get_notices(false)),
326
+				)
327
+			);
328
+			exit();
329
+		}
330
+		// save errors to a transient to be displayed on next request (after redirect)
331
+		EE_Error::get_notices(false, true);
332
+		wp_safe_redirect(
333
+			urldecode(
334
+				$this->request->getRequestParam('return_url', '')
335
+			)
336
+		);
337
+	}
338
+
339
+
340
+	/**
341
+	 * saveNotices
342
+	 *
343
+	 * @throws DomainException
344
+	 * @throws InvalidDataTypeException
345
+	 * @throws InvalidInterfaceException
346
+	 * @throws InvalidEntityException
347
+	 * @throws DuplicateCollectionIdentifierException
348
+	 */
349
+	public function saveNotices()
350
+	{
351
+		$this->notice_collection = $this->getPersistentAdminNoticeCollection();
352
+		if ($this->notice_collection->hasObjects()) {
353
+			$persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array());
354
+			// maybe initialize persistent_admin_notices
355
+			if (empty($persistent_admin_notices)) {
356
+				add_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array(), '', 'no');
357
+			}
358
+			foreach ($this->notice_collection as $persistent_admin_notice) {
359
+				// are we deleting this notice ?
360
+				if ($persistent_admin_notice->getPurge()) {
361
+					unset($persistent_admin_notices[ $persistent_admin_notice->getName() ]);
362
+				} else {
363
+					/** @var PersistentAdminNotice $persistent_admin_notice */
364
+					$persistent_admin_notices[ $persistent_admin_notice->getName() ] = array(
365
+						'message'     => $persistent_admin_notice->getMessage(),
366
+						'capability'  => $persistent_admin_notice->getCapability(),
367
+						'cap_context' => $persistent_admin_notice->getCapContext(),
368
+						'dismissed'   => $persistent_admin_notice->getDismissed(),
369
+					);
370
+				}
371
+			}
372
+			update_option(PersistentAdminNoticeManager::WP_OPTION_KEY, $persistent_admin_notices);
373
+		}
374
+	}
375
+
376
+
377
+	/**
378
+	 * @throws DomainException
379
+	 * @throws InvalidDataTypeException
380
+	 * @throws InvalidEntityException
381
+	 * @throws InvalidInterfaceException
382
+	 * @throws DuplicateCollectionIdentifierException
383
+	 */
384
+	public function registerAndSaveNotices()
385
+	{
386
+		$this->getPersistentAdminNoticeCollection();
387
+		$this->registerNotices();
388
+		$this->saveNotices();
389
+		add_filter(
390
+			'PersistentAdminNoticeManager__registerAndSaveNotices__complete',
391
+			'__return_true'
392
+		);
393
+	}
394
+
395
+
396
+	/**
397
+	 * @throws DomainException
398
+	 * @throws InvalidDataTypeException
399
+	 * @throws InvalidEntityException
400
+	 * @throws InvalidInterfaceException
401
+	 * @throws InvalidArgumentException
402
+	 * @throws DuplicateCollectionIdentifierException
403
+	 */
404
+	public static function loadRegisterAndSaveNotices()
405
+	{
406
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
407
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
408
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
409
+		);
410
+		// if shutdown has already run, then call registerAndSaveNotices() manually
411
+		if (did_action('shutdown')) {
412
+			$persistent_admin_notice_manager->registerAndSaveNotices();
413
+		}
414
+	}
415 415
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function setReturnUrl($return_url)
87 87
     {
88
-        if (! is_string($return_url)) {
88
+        if ( ! is_string($return_url)) {
89 89
             throw new InvalidDataTypeException('$return_url', $return_url, 'string');
90 90
         }
91 91
         $this->return_url = $return_url;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     protected function getPersistentAdminNoticeCollection()
104 104
     {
105
-        if (! $this->notice_collection instanceof Collection) {
105
+        if ( ! $this->notice_collection instanceof Collection) {
106 106
             $this->notice_collection = new Collection(
107 107
                 'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
108 108
             );
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
     protected function retrieveStoredNotices()
126 126
     {
127 127
         $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, array());
128
-        if (! empty($persistent_admin_notices)) {
128
+        if ( ! empty($persistent_admin_notices)) {
129 129
             foreach ($persistent_admin_notices as $name => $details) {
130 130
                 if (is_array($details)) {
131
-                    if (! isset(
131
+                    if ( ! isset(
132 132
                         $details['message'],
133 133
                         $details['capability'],
134 134
                         $details['cap_context'],
@@ -245,14 +245,14 @@  discard block
 block discarded – undo
245 245
     {
246 246
         wp_register_script(
247 247
             'espresso_core',
248
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
248
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
249 249
             array('jquery'),
250 250
             EVENT_ESPRESSO_VERSION,
251 251
             true
252 252
         );
253 253
         wp_register_script(
254 254
             'ee_error_js',
255
-            EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
255
+            EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js',
256 256
             array('espresso_core'),
257 257
             EVENT_ESPRESSO_VERSION,
258 258
             true
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         // used in template
284 284
         $persistent_admin_notice_name = $persistent_admin_notice->getName();
285 285
         $persistent_admin_notice_message = $persistent_admin_notice->getMessage();
286
-        require EE_TEMPLATES . '/notifications/persistent_admin_notice.template.php';
286
+        require EE_TEMPLATES.'/notifications/persistent_admin_notice.template.php';
287 287
     }
288 288
 
289 289
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     {
309 309
         $pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name);
310 310
         $this->notice_collection = $this->getPersistentAdminNoticeCollection();
311
-        if (! empty($pan_name) && $this->notice_collection->has($pan_name)) {
311
+        if ( ! empty($pan_name) && $this->notice_collection->has($pan_name)) {
312 312
             /** @var PersistentAdminNotice $persistent_admin_notice */
313 313
             $persistent_admin_notice = $this->notice_collection->get($pan_name);
314 314
             $persistent_admin_notice->setDismissed(true);
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
             foreach ($this->notice_collection as $persistent_admin_notice) {
359 359
                 // are we deleting this notice ?
360 360
                 if ($persistent_admin_notice->getPurge()) {
361
-                    unset($persistent_admin_notices[ $persistent_admin_notice->getName() ]);
361
+                    unset($persistent_admin_notices[$persistent_admin_notice->getName()]);
362 362
                 } else {
363 363
                     /** @var PersistentAdminNotice $persistent_admin_notice */
364
-                    $persistent_admin_notices[ $persistent_admin_notice->getName() ] = array(
364
+                    $persistent_admin_notices[$persistent_admin_notice->getName()] = array(
365 365
                         'message'     => $persistent_admin_notice->getMessage(),
366 366
                         'capability'  => $persistent_admin_notice->getCapability(),
367 367
                         'cap_context' => $persistent_admin_notice->getCapContext(),
Please login to merge, or discard this patch.
display_strategies/number_bubbles/NumberBubblesProgressStepsDisplay.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -16,29 +16,29 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * used for setting up css and js required for the display strategy
21
-     *
22
-     * @return void
23
-     */
24
-    public function enqueueStylesAndScripts()
25
-    {
26
-        // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
27
-        wp_enqueue_style(
28
-            'ee_progress_steps_display_number_bubbles',
29
-            plugin_dir_url(__FILE__) . 'number_bubbles.css'
30
-        );
31
-    }
19
+	/**
20
+	 * used for setting up css and js required for the display strategy
21
+	 *
22
+	 * @return void
23
+	 */
24
+	public function enqueueStylesAndScripts()
25
+	{
26
+		// core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
27
+		wp_enqueue_style(
28
+			'ee_progress_steps_display_number_bubbles',
29
+			plugin_dir_url(__FILE__) . 'number_bubbles.css'
30
+		);
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * loads and returns a full server path to the template used for the display strategy
36
-     *
37
-     * @return string
38
-     */
39
-    public function getTemplate()
40
-    {
41
-        // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
42
-        return __DIR__ . '/number_bubbles.template.php';
43
-    }
34
+	/**
35
+	 * loads and returns a full server path to the template used for the display strategy
36
+	 *
37
+	 * @return string
38
+	 */
39
+	public function getTemplate()
40
+	{
41
+		// return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
42
+		return __DIR__ . '/number_bubbles.template.php';
43
+	}
44 44
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
27 27
         wp_enqueue_style(
28 28
             'ee_progress_steps_display_number_bubbles',
29
-            plugin_dir_url(__FILE__) . 'number_bubbles.css'
29
+            plugin_dir_url(__FILE__).'number_bubbles.css'
30 30
         );
31 31
     }
32 32
 
@@ -39,6 +39,6 @@  discard block
 block discarded – undo
39 39
     public function getTemplate()
40 40
     {
41 41
         // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
42
-        return __DIR__ . '/number_bubbles.template.php';
42
+        return __DIR__.'/number_bubbles.template.php';
43 43
     }
44 44
 }
Please login to merge, or discard this patch.