Completed
Branch fix-unit-tests (9a2fb0)
by
unknown
06:58 queued 05:09
created
admin/extend/registration_form/Extend_Registration_Form_Admin_Page.core.php 2 patches
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.
Indentation   +1442 added lines, -1442 removed lines patch added patch discarded remove patch
@@ -14,1446 +14,1446 @@
 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
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
218
-                // 'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
219
-                'metaboxes'     => $this->_default_espresso_metaboxes,
220
-                'require_nonce' => false,
221
-                'qtips'         => array(
222
-                    'EE_Registration_Form_Tips',
223
-                ),
224
-            ),
225
-
226
-            'add_question' => array(
227
-                'nav'           => array(
228
-                    'label'      => esc_html__('Add Question', 'event_espresso'),
229
-                    'order'      => 5,
230
-                    'persistent' => false,
231
-                ),
232
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
233
-                'help_tabs'     => array(
234
-                    'registration_form_add_question_help_tab' => array(
235
-                        'title'    => esc_html__('Add Question', 'event_espresso'),
236
-                        'filename' => 'registration_form_add_question',
237
-                    ),
238
-                ),
239
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
240
-                // 'help_tour'     => array('Registration_Form_Add_Question_Help_Tour'),
241
-                'require_nonce' => false,
242
-            ),
243
-
244
-            'add_question_group' => array(
245
-                'nav'           => array(
246
-                    'label'      => esc_html__('Add Question Group', 'event_espresso'),
247
-                    'order'      => 5,
248
-                    'persistent' => false,
249
-                ),
250
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
251
-                'help_tabs'     => array(
252
-                    'registration_form_add_question_group_help_tab' => array(
253
-                        'title'    => esc_html__('Add Question Group', 'event_espresso'),
254
-                        'filename' => 'registration_form_add_question_group',
255
-                    ),
256
-                ),
257
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
258
-                // 'help_tour'     => array('Registration_Form_Add_Question_Group_Help_Tour'),
259
-                'require_nonce' => false,
260
-            ),
261
-
262
-            'edit_question_group' => array(
263
-                'nav'           => array(
264
-                    'label'      => esc_html__('Edit Question Group', 'event_espresso'),
265
-                    'order'      => 5,
266
-                    'persistent' => false,
267
-                    'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(
268
-                        array('question_group_id' => $this->_req_data['question_group_id']),
269
-                        $this->_current_page_view_url
270
-                    ) : $this->_admin_base_url,
271
-                ),
272
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
273
-                'help_tabs'     => array(
274
-                    'registration_form_edit_question_group_help_tab' => array(
275
-                        'title'    => esc_html__('Edit Question Group', 'event_espresso'),
276
-                        'filename' => 'registration_form_edit_question_group',
277
-                    ),
278
-                ),
279
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
280
-                // 'help_tour'     => array('Registration_Form_Edit_Question_Group_Help_Tour'),
281
-                'require_nonce' => false,
282
-            ),
283
-
284
-            'view_reg_form_settings' => array(
285
-                'nav'           => array(
286
-                    'label' => esc_html__('Reg Form Settings', 'event_espresso'),
287
-                    'order' => 40,
288
-                ),
289
-                'labels'        => array(
290
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
291
-                ),
292
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
293
-                'help_tabs'     => array(
294
-                    'registration_form_reg_form_settings_help_tab' => array(
295
-                        'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
296
-                        'filename' => 'registration_form_reg_form_settings',
297
-                    ),
298
-                ),
299
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
300
-                // 'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
301
-                'require_nonce' => false,
302
-            ),
303
-
304
-        );
305
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
306
-
307
-        // change the list table we're going to use so it's the NEW list table!
308
-        $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
309
-
310
-
311
-        // additional labels
312
-        $new_labels = array(
313
-            'add_question'          => esc_html__('Add New Question', 'event_espresso'),
314
-            'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
315
-            'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
316
-            'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
317
-            'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
318
-        );
319
-        $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
320
-    }
321
-
322
-
323
-    /**
324
-     * @return void
325
-     */
326
-    protected function _ajax_hooks()
327
-    {
328
-        add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
329
-    }
330
-
331
-
332
-    /**
333
-     * @return void
334
-     */
335
-    public function load_scripts_styles_question_groups()
336
-    {
337
-        wp_enqueue_script('espresso_ajax_table_sorting');
338
-    }
339
-
340
-
341
-    /**
342
-     * @return void
343
-     */
344
-    public function load_scripts_styles_add_question_group()
345
-    {
346
-        $this->load_scripts_styles_forms();
347
-        $this->load_sortable_question_script();
348
-    }
349
-
350
-
351
-    /**
352
-     * @return void
353
-     */
354
-    public function load_scripts_styles_edit_question_group()
355
-    {
356
-        $this->load_scripts_styles_forms();
357
-        $this->load_sortable_question_script();
358
-    }
359
-
360
-
361
-    /**
362
-     * registers and enqueues script for questions
363
-     *
364
-     * @return void
365
-     */
366
-    public function load_sortable_question_script()
367
-    {
368
-        wp_register_script(
369
-            'ee-question-sortable',
370
-            REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
371
-            array('jquery-ui-sortable'),
372
-            EVENT_ESPRESSO_VERSION,
373
-            true
374
-        );
375
-        wp_enqueue_script('ee-question-sortable');
376
-    }
377
-
378
-
379
-    /**
380
-     * @return void
381
-     */
382
-    protected function _set_list_table_views_default()
383
-    {
384
-        $this->_views = array(
385
-            'all' => array(
386
-                'slug'        => 'all',
387
-                'label'       => esc_html__('View All Questions', 'event_espresso'),
388
-                'count'       => 0,
389
-                'bulk_action' => array(
390
-                    'trash_questions' => esc_html__('Trash', 'event_espresso'),
391
-                ),
392
-            ),
393
-        );
394
-
395
-        if (
396
-            EE_Registry::instance()->CAP->current_user_can(
397
-                'ee_delete_questions',
398
-                'espresso_registration_form_trash_questions'
399
-            )
400
-        ) {
401
-            $this->_views['trash'] = array(
402
-                'slug'        => 'trash',
403
-                'label'       => esc_html__('Trash', 'event_espresso'),
404
-                'count'       => 0,
405
-                'bulk_action' => array(
406
-                    'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
407
-                    'restore_questions' => esc_html__('Restore', 'event_espresso'),
408
-                ),
409
-            );
410
-        }
411
-    }
412
-
413
-
414
-    /**
415
-     * @return void
416
-     */
417
-    protected function _set_list_table_views_question_groups()
418
-    {
419
-        $this->_views = array(
420
-            'all' => array(
421
-                'slug'        => 'all',
422
-                'label'       => esc_html__('All', 'event_espresso'),
423
-                'count'       => 0,
424
-                'bulk_action' => array(
425
-                    'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
426
-                ),
427
-            ),
428
-        );
429
-
430
-        if (
431
-            EE_Registry::instance()->CAP->current_user_can(
432
-                'ee_delete_question_groups',
433
-                'espresso_registration_form_trash_question_groups'
434
-            )
435
-        ) {
436
-            $this->_views['trash'] = array(
437
-                'slug'        => 'trash',
438
-                'label'       => esc_html__('Trash', 'event_espresso'),
439
-                'count'       => 0,
440
-                'bulk_action' => array(
441
-                    'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
442
-                    'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
443
-                ),
444
-            );
445
-        }
446
-    }
447
-
448
-
449
-    /**
450
-     * @return void
451
-     * @throws EE_Error
452
-     * @throws InvalidArgumentException
453
-     * @throws InvalidDataTypeException
454
-     * @throws InvalidInterfaceException
455
-     */
456
-    protected function _questions_overview_list_table()
457
-    {
458
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
459
-            'add_question',
460
-            'add_question',
461
-            array(),
462
-            'add-new-h2'
463
-        );
464
-        parent::_questions_overview_list_table();
465
-    }
466
-
467
-
468
-    /**
469
-     * @return void
470
-     * @throws DomainException
471
-     * @throws EE_Error
472
-     * @throws InvalidArgumentException
473
-     * @throws InvalidDataTypeException
474
-     * @throws InvalidInterfaceException
475
-     */
476
-    protected function _question_groups_overview_list_table()
477
-    {
478
-        $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
479
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
480
-            'add_question_group',
481
-            'add_question_group',
482
-            array(),
483
-            'add-new-h2'
484
-        );
485
-        $this->display_admin_list_table_page_with_sidebar();
486
-    }
487
-
488
-
489
-    /**
490
-     * @return void
491
-     * @throws EE_Error
492
-     * @throws InvalidArgumentException
493
-     * @throws InvalidDataTypeException
494
-     * @throws InvalidInterfaceException
495
-     */
496
-    protected function _delete_question()
497
-    {
498
-        $success = $this->_delete_items($this->_question_model);
499
-        $this->_redirect_after_action(
500
-            $success,
501
-            $this->_question_model->item_name($success),
502
-            'deleted',
503
-            array('action' => 'default', 'status' => 'all')
504
-        );
505
-    }
506
-
507
-
508
-    /**
509
-     * @return void
510
-     * @throws EE_Error
511
-     * @throws InvalidArgumentException
512
-     * @throws InvalidDataTypeException
513
-     * @throws InvalidInterfaceException
514
-     */
515
-    protected function _delete_questions()
516
-    {
517
-        $success = $this->_delete_items($this->_question_model);
518
-        $this->_redirect_after_action(
519
-            $success,
520
-            $this->_question_model->item_name($success),
521
-            'deleted permanently',
522
-            array('action' => 'default', 'status' => 'trash')
523
-        );
524
-    }
525
-
526
-
527
-    /**
528
-     * Performs the deletion of a single or multiple questions or question groups.
529
-     *
530
-     * @param EEM_Soft_Delete_Base $model
531
-     * @return int number of items deleted permanently
532
-     * @throws EE_Error
533
-     * @throws InvalidArgumentException
534
-     * @throws InvalidDataTypeException
535
-     * @throws InvalidInterfaceException
536
-     */
537
-    private function _delete_items(EEM_Soft_Delete_Base $model)
538
-    {
539
-        $success = 0;
540
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
541
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
542
-            // if array has more than one element than success message should be plural
543
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
544
-            // cycle thru bulk action checkboxes
545
-            while (list($ID, $value) = each($this->_req_data['checkbox'])) {
546
-                if (! $this->_delete_item($ID, $model)) {
547
-                    $success = 0;
548
-                }
549
-            }
550
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
551
-            $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
552
-        } elseif (! empty($this->_req_data['QST_ID'])) {
553
-            $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
554
-        } else {
555
-            EE_Error::add_error(
556
-                sprintf(
557
-                    esc_html__(
558
-                        "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.",
559
-                        "event_espresso"
560
-                    )
561
-                ),
562
-                __FILE__,
563
-                __FUNCTION__,
564
-                __LINE__
565
-            );
566
-        }
567
-        return $success;
568
-    }
569
-
570
-
571
-    /**
572
-     * Deletes the specified question (and its associated question options) or question group
573
-     *
574
-     * @param int                  $id
575
-     * @param EEM_Soft_Delete_Base $model
576
-     * @return boolean
577
-     * @throws EE_Error
578
-     * @throws InvalidArgumentException
579
-     * @throws InvalidDataTypeException
580
-     * @throws InvalidInterfaceException
581
-     */
582
-    protected function _delete_item($id, $model)
583
-    {
584
-        if ($model instanceof EEM_Question) {
585
-            EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
586
-        }
587
-        return $model->delete_permanently_by_ID(absint($id));
588
-    }
589
-
590
-
591
-    /******************************    QUESTION GROUPS    ******************************/
592
-
593
-
594
-    /**
595
-     * @param string $type
596
-     * @return void
597
-     * @throws DomainException
598
-     * @throws EE_Error
599
-     * @throws InvalidArgumentException
600
-     * @throws InvalidDataTypeException
601
-     * @throws InvalidInterfaceException
602
-     */
603
-    protected function _edit_question_group($type = 'add')
604
-    {
605
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
606
-        $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID'])
607
-            ? absint($this->_req_data['QSG_ID'])
608
-            : false;
609
-
610
-        switch ($this->_req_action) {
611
-            case 'add_question_group':
612
-                $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
613
-                break;
614
-            case 'edit_question_group':
615
-                $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
616
-                break;
617
-            default:
618
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
619
-        }
620
-        // add ID to title if editing
621
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
622
-        if ($ID) {
623
-            /** @var EE_Question_Group $questionGroup */
624
-            $questionGroup = $this->_question_group_model->get_one_by_ID($ID);
625
-            $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
626
-            $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
627
-        } else {
628
-            /** @var EE_Question_Group $questionGroup */
629
-            $questionGroup = EEM_Question_Group::instance()->create_default_object();
630
-            $questionGroup->set_order_to_latest();
631
-            $this->_set_add_edit_form_tags('insert_question_group');
632
-        }
633
-        $this->_template_args['values'] = $this->_yes_no_values;
634
-        $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
635
-        $this->_template_args['QSG_ID'] = $ID ? $ID : true;
636
-        $this->_template_args['question_group'] = $questionGroup;
637
-
638
-        $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
639
-        $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
640
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
641
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
642
-            $this->_template_args,
643
-            true
644
-        );
645
-
646
-        // the details template wrapper
647
-        $this->display_admin_page_with_sidebar();
648
-    }
649
-
650
-
651
-    /**
652
-     * @return void
653
-     * @throws EE_Error
654
-     * @throws InvalidArgumentException
655
-     * @throws InvalidDataTypeException
656
-     * @throws InvalidInterfaceException
657
-     */
658
-    protected function _delete_question_groups()
659
-    {
660
-        $success = $this->_delete_items($this->_question_group_model);
661
-        $this->_redirect_after_action(
662
-            $success,
663
-            $this->_question_group_model->item_name($success),
664
-            'deleted permanently',
665
-            array('action' => 'question_groups', 'status' => 'trash')
666
-        );
667
-    }
668
-
669
-
670
-    /**
671
-     * @param bool $new_question_group
672
-     * @throws EE_Error
673
-     * @throws InvalidArgumentException
674
-     * @throws InvalidDataTypeException
675
-     * @throws InvalidInterfaceException
676
-     */
677
-    protected function _insert_or_update_question_group($new_question_group = true)
678
-    {
679
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
680
-        $set_column_values = $this->_set_column_values_for($this->_question_group_model);
681
-        if ($new_question_group) {
682
-            // make sure identifier is unique
683
-            $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : '';
684
-            $identifier_exists = ! empty($identifier_value)
685
-                ? $this->_question_group_model->count([['QSG_identifier' => $set_column_values['QSG_identifier']]]) > 0
686
-                : false;
687
-            if ($identifier_exists) {
688
-                $set_column_values['QSG_identifier'] .= uniqid('id', true);
689
-            }
690
-            $QSG_ID = $this->_question_group_model->insert($set_column_values);
691
-            $success = $QSG_ID ? 1 : 0;
692
-            if ($success === 0) {
693
-                EE_Error::add_error(
694
-                    esc_html__('Something went wrong saving the question group.', 'event_espresso'),
695
-                    __FILE__,
696
-                    __FUNCTION__,
697
-                    __LINE__
698
-                );
699
-                $this->_redirect_after_action(
700
-                    false,
701
-                    '',
702
-                    '',
703
-                    array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
704
-                    true
705
-                );
706
-            }
707
-        } else {
708
-            $QSG_ID = absint($this->_req_data['QSG_ID']);
709
-            unset($set_column_values['QSG_ID']);
710
-            $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
711
-        }
712
-
713
-        $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(
714
-            EEM_Attendee::system_question_phone
715
-        );
716
-        // update the existing related questions
717
-        // BUT FIRST...  delete the phone question from the Question_Group_Question
718
-        // if it is being added to this question group (therefore removed from the existing group)
719
-        if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
720
-            // delete where QST ID = system phone question ID and Question Group ID is NOT this group
721
-            EEM_Question_Group_Question::instance()->delete(
722
-                array(
723
-                    array(
724
-                        'QST_ID' => $phone_question_id,
725
-                        'QSG_ID' => array('!=', $QSG_ID),
726
-                    ),
727
-                )
728
-            );
729
-        }
730
-        /** @type EE_Question_Group $question_group */
731
-        $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
732
-        $questions = $question_group->questions();
733
-        // make sure system phone question is added to list of questions for this group
734
-        if (! isset($questions[ $phone_question_id ])) {
735
-            $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
736
-        }
737
-
738
-        foreach ($questions as $question_ID => $question) {
739
-            // first we always check for order.
740
-            if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
741
-                // update question order
742
-                $question_group->update_question_order(
743
-                    $question_ID,
744
-                    $this->_req_data['question_orders'][ $question_ID ]
745
-                );
746
-            }
747
-
748
-            // then we always check if adding or removing.
749
-            if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
750
-                $question_group->add_question($question_ID);
751
-            } else {
752
-                // not found, remove it (but only if not a system question for the personal group
753
-                // with the exception of lname system question - we allow removal of it)
754
-                if (
755
-                    in_array(
756
-                        $question->system_ID(),
757
-                        EEM_Question::instance()->required_system_questions_in_system_question_group(
758
-                            $question_group->system_group()
759
-                        )
760
-                    )
761
-                ) {
762
-                    continue;
763
-                } else {
764
-                    $question_group->remove_question($question_ID);
765
-                }
766
-            }
767
-        }
768
-        // save new related questions
769
-        if (isset($this->_req_data['questions'])) {
770
-            foreach ($this->_req_data['questions'] as $QST_ID) {
771
-                $question_group->add_question($QST_ID);
772
-                if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
773
-                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
774
-                }
775
-            }
776
-        }
777
-
778
-        if ($success !== false) {
779
-            $msg = $new_question_group
780
-                ? sprintf(
781
-                    esc_html__('The %s has been created', 'event_espresso'),
782
-                    $this->_question_group_model->item_name()
783
-                )
784
-                : sprintf(
785
-                    esc_html__(
786
-                        'The %s has been updated',
787
-                        'event_espresso'
788
-                    ),
789
-                    $this->_question_group_model->item_name()
790
-                );
791
-            EE_Error::add_success($msg);
792
-        }
793
-        $this->_redirect_after_action(
794
-            false,
795
-            '',
796
-            '',
797
-            array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
798
-            true
799
-        );
800
-    }
801
-
802
-
803
-    /**
804
-     * duplicates a question and all its question options and redirects to the new question.
805
-     *
806
-     * @return void
807
-     * @throws EE_Error
808
-     * @throws InvalidArgumentException
809
-     * @throws ReflectionException
810
-     * @throws InvalidDataTypeException
811
-     * @throws InvalidInterfaceException
812
-     */
813
-    public function _duplicate_question()
814
-    {
815
-        $question_ID = (int) $this->_req_data['QST_ID'];
816
-        $question = EEM_Question::instance()->get_one_by_ID($question_ID);
817
-        if ($question instanceof EE_Question) {
818
-            $new_question = $question->duplicate();
819
-            if ($new_question instanceof EE_Question) {
820
-                $this->_redirect_after_action(
821
-                    true,
822
-                    esc_html__('Question', 'event_espresso'),
823
-                    esc_html__('Duplicated', 'event_espresso'),
824
-                    array('action' => 'edit_question', 'QST_ID' => $new_question->ID()),
825
-                    true
826
-                );
827
-            } else {
828
-                global $wpdb;
829
-                EE_Error::add_error(
830
-                    sprintf(
831
-                        esc_html__(
832
-                            'Could not duplicate question with ID %1$d because: %2$s',
833
-                            'event_espresso'
834
-                        ),
835
-                        $question_ID,
836
-                        $wpdb->last_error
837
-                    ),
838
-                    __FILE__,
839
-                    __FUNCTION__,
840
-                    __LINE__
841
-                );
842
-                $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
843
-            }
844
-        } else {
845
-            EE_Error::add_error(
846
-                sprintf(
847
-                    esc_html__(
848
-                        'Could not duplicate question with ID %d because it didn\'t exist!',
849
-                        'event_espresso'
850
-                    ),
851
-                    $question_ID
852
-                ),
853
-                __FILE__,
854
-                __FUNCTION__,
855
-                __LINE__
856
-            );
857
-            $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
858
-        }
859
-    }
860
-
861
-
862
-    /**
863
-     * @param bool $trash
864
-     * @throws EE_Error
865
-     */
866
-    protected function _trash_or_restore_question_groups($trash = true)
867
-    {
868
-        $this->_trash_or_restore_items($this->_question_group_model, $trash);
869
-    }
870
-
871
-
872
-    /**
873
-     *_trash_question
874
-     *
875
-     * @return void
876
-     * @throws EE_Error
877
-     */
878
-    protected function _trash_question()
879
-    {
880
-        $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
881
-        $query_args = array('action' => 'default', 'status' => 'all');
882
-        $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
883
-    }
884
-
885
-
886
-    /**
887
-     * @param bool $trash
888
-     * @throws EE_Error
889
-     */
890
-    protected function _trash_or_restore_questions($trash = true)
891
-    {
892
-        $this->_trash_or_restore_items($this->_question_model, $trash);
893
-    }
894
-
895
-
896
-    /**
897
-     * Internally used to delete or restore items, using the request data. Meant to be
898
-     * flexible between question or question groups
899
-     *
900
-     * @param EEM_Soft_Delete_Base $model
901
-     * @param boolean              $trash whether to trash or restore
902
-     * @throws EE_Error
903
-     */
904
-    private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
905
-    {
906
-
907
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
908
-
909
-        $success = 1;
910
-        // Checkboxes
911
-        // echo "trash $trash";
912
-        // var_dump($this->_req_data['checkbox']);die;
913
-        if (isset($this->_req_data['checkbox'])) {
914
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
915
-                // if array has more than one element than success message should be plural
916
-                $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
917
-                // cycle thru bulk action checkboxes
918
-                while (list($ID, $value) = each($this->_req_data['checkbox'])) {
919
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
920
-                        $success = 0;
921
-                    }
922
-                }
923
-            } else {
924
-                // grab single id and delete
925
-                $ID = absint($this->_req_data['checkbox']);
926
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
927
-                    $success = 0;
928
-                }
929
-            }
930
-        } else {
931
-            // delete via trash link
932
-            // grab single id and delete
933
-            $ID = absint($this->_req_data[ $model->primary_key_name() ]);
934
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
935
-                $success = 0;
936
-            }
937
-        }
938
-
939
-
940
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
941
-        // echo "action :$action";
942
-        // $action = 'questions' ? 'default' : $action;
943
-        if ($trash) {
944
-            $action_desc = 'trashed';
945
-            $status = 'trash';
946
-        } else {
947
-            $action_desc = 'restored';
948
-            $status = 'all';
949
-        }
950
-        $this->_redirect_after_action(
951
-            $success,
952
-            $model->item_name($success),
953
-            $action_desc,
954
-            array('action' => $action, 'status' => $status)
955
-        );
956
-    }
957
-
958
-
959
-    /**
960
-     * @param            $per_page
961
-     * @param int        $current_page
962
-     * @param bool|false $count
963
-     * @return EE_Soft_Delete_Base_Class[]|int
964
-     * @throws EE_Error
965
-     * @throws InvalidArgumentException
966
-     * @throws InvalidDataTypeException
967
-     * @throws InvalidInterfaceException
968
-     */
969
-    public function get_trashed_questions($per_page, $current_page = 1, $count = false)
970
-    {
971
-        $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
972
-
973
-        if ($count) {
974
-            // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
975
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
976
-            $results = $this->_question_model->count_deleted($where);
977
-        } else {
978
-            // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
979
-            $results = $this->_question_model->get_all_deleted($query_params);
980
-        }
981
-        return $results;
982
-    }
983
-
984
-
985
-    /**
986
-     * @param            $per_page
987
-     * @param int        $current_page
988
-     * @param bool|false $count
989
-     * @return EE_Soft_Delete_Base_Class[]|int
990
-     * @throws EE_Error
991
-     * @throws InvalidArgumentException
992
-     * @throws InvalidDataTypeException
993
-     * @throws InvalidInterfaceException
994
-     */
995
-    public function get_question_groups($per_page, $current_page = 1, $count = false)
996
-    {
997
-        $questionGroupModel = EEM_Question_Group::instance();
998
-        $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
999
-        if ($count) {
1000
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
1001
-            $results = $questionGroupModel->count($where);
1002
-        } else {
1003
-            $results = $questionGroupModel->get_all($query_params);
1004
-        }
1005
-        return $results;
1006
-    }
1007
-
1008
-
1009
-    /**
1010
-     * @param      $per_page
1011
-     * @param int  $current_page
1012
-     * @param bool $count
1013
-     * @return EE_Soft_Delete_Base_Class[]|int
1014
-     * @throws EE_Error
1015
-     * @throws InvalidArgumentException
1016
-     * @throws InvalidDataTypeException
1017
-     * @throws InvalidInterfaceException
1018
-     */
1019
-    public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
1020
-    {
1021
-        $questionGroupModel = EEM_Question_Group::instance();
1022
-        $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
1023
-        if ($count) {
1024
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
1025
-            $query_params['limit'] = null;
1026
-            $results = $questionGroupModel->count_deleted($where);
1027
-        } else {
1028
-            $results = $questionGroupModel->get_all_deleted($query_params);
1029
-        }
1030
-        return $results;
1031
-    }
1032
-
1033
-
1034
-    /**
1035
-     * method for performing updates to question order
1036
-     *
1037
-     * @return void results array
1038
-     * @throws EE_Error
1039
-     * @throws InvalidArgumentException
1040
-     * @throws InvalidDataTypeException
1041
-     * @throws InvalidInterfaceException
1042
-     */
1043
-    public function update_question_group_order()
1044
-    {
1045
-
1046
-        $success = esc_html__('Question group order was updated successfully.', 'event_espresso');
1047
-
1048
-        // grab our row IDs
1049
-        $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
1050
-            ? explode(',', rtrim($this->_req_data['row_ids'], ','))
1051
-            : array();
1052
-
1053
-        $perpage = ! empty($this->_req_data['perpage'])
1054
-            ? (int) $this->_req_data['perpage']
1055
-            : null;
1056
-        $curpage = ! empty($this->_req_data['curpage'])
1057
-            ? (int) $this->_req_data['curpage']
1058
-            : null;
1059
-
1060
-        if (! empty($row_ids)) {
1061
-            // figure out where we start the row_id count at for the current page.
1062
-            $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1063
-
1064
-            $row_count = count($row_ids);
1065
-            for ($i = 0; $i < $row_count; $i++) {
1066
-                // Update the questions when re-ordering
1067
-                $updated = EEM_Question_Group::instance()->update(
1068
-                    array('QSG_order' => $qsgcount),
1069
-                    array(array('QSG_ID' => $row_ids[ $i ]))
1070
-                );
1071
-                if ($updated === false) {
1072
-                    $success = false;
1073
-                }
1074
-                $qsgcount++;
1075
-            }
1076
-        } else {
1077
-            $success = false;
1078
-        }
1079
-
1080
-        $errors = ! $success
1081
-            ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
1082
-            : false;
1083
-
1084
-        echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
1085
-        die();
1086
-    }
1087
-
1088
-
1089
-
1090
-    /***************************************       REGISTRATION SETTINGS       ***************************************/
1091
-
1092
-
1093
-    /**
1094
-     * @throws DomainException
1095
-     * @throws EE_Error
1096
-     * @throws InvalidArgumentException
1097
-     * @throws InvalidDataTypeException
1098
-     * @throws InvalidInterfaceException
1099
-     */
1100
-    protected function _reg_form_settings()
1101
-    {
1102
-        $this->_template_args['values'] = $this->_yes_no_values;
1103
-        add_action(
1104
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1105
-            array($this, 'email_validation_settings_form'),
1106
-            2
1107
-        );
1108
-        add_action(
1109
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1110
-            array($this, 'copy_attendee_info_settings_form'),
1111
-            4
1112
-        );
1113
-        $this->_template_args = (array) apply_filters(
1114
-            'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
1115
-            $this->_template_args
1116
-        );
1117
-        $this->_set_add_edit_form_tags('update_reg_form_settings');
1118
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1119
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1120
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1121
-            $this->_template_args,
1122
-            true
1123
-        );
1124
-        $this->display_admin_page_with_sidebar();
1125
-    }
1126
-
1127
-
1128
-    /**
1129
-     * @return void
1130
-     * @throws EE_Error
1131
-     * @throws InvalidArgumentException
1132
-     * @throws ReflectionException
1133
-     * @throws InvalidDataTypeException
1134
-     * @throws InvalidInterfaceException
1135
-     */
1136
-    protected function _update_reg_form_settings()
1137
-    {
1138
-        EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
1139
-            EE_Registry::instance()->CFG->registration
1140
-        );
1141
-        EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form(
1142
-            EE_Registry::instance()->CFG->registration
1143
-        );
1144
-        EE_Registry::instance()->CFG->registration = apply_filters(
1145
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
1146
-            EE_Registry::instance()->CFG->registration
1147
-        );
1148
-        $success = $this->_update_espresso_configuration(
1149
-            esc_html__('Registration Form Options', 'event_espresso'),
1150
-            EE_Registry::instance()->CFG,
1151
-            __FILE__,
1152
-            __FUNCTION__,
1153
-            __LINE__
1154
-        );
1155
-        $this->_redirect_after_action(
1156
-            $success,
1157
-            esc_html__('Registration Form Options', 'event_espresso'),
1158
-            'updated',
1159
-            array('action' => 'view_reg_form_settings')
1160
-        );
1161
-    }
1162
-
1163
-
1164
-    /**
1165
-     * @return void
1166
-     * @throws EE_Error
1167
-     * @throws InvalidArgumentException
1168
-     * @throws InvalidDataTypeException
1169
-     * @throws InvalidInterfaceException
1170
-     */
1171
-    public function copy_attendee_info_settings_form()
1172
-    {
1173
-        echo $this->_copy_attendee_info_settings_form()->get_html();
1174
-    }
1175
-
1176
-    /**
1177
-     * _copy_attendee_info_settings_form
1178
-     *
1179
-     * @access protected
1180
-     * @return EE_Form_Section_Proper
1181
-     * @throws \EE_Error
1182
-     */
1183
-    protected function _copy_attendee_info_settings_form()
1184
-    {
1185
-        return new EE_Form_Section_Proper(
1186
-            array(
1187
-                'name'            => 'copy_attendee_info_settings',
1188
-                'html_id'         => 'copy_attendee_info_settings',
1189
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1190
-                'subsections'     => apply_filters(
1191
-                    'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections',
1192
-                    array(
1193
-                        'copy_attendee_info_hdr'   => new EE_Form_Section_HTML(
1194
-                            EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso'))
1195
-                        ),
1196
-                        'copy_attendee_info' => new EE_Yes_No_Input(
1197
-                            array(
1198
-                                'html_label_text' => esc_html__(
1199
-                                    'Allow copy #1 attendee info to extra attendees?',
1200
-                                    'event_espresso'
1201
-                                ),
1202
-                                'html_help_text'  => esc_html__(
1203
-                                    'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.',
1204
-                                    'event_espresso'
1205
-                                ),
1206
-                                'default'         => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(),
1207
-                                'required'        => false,
1208
-                                'display_html_label_text' => false,
1209
-                            )
1210
-                        ),
1211
-                    )
1212
-                ),
1213
-            )
1214
-        );
1215
-    }
1216
-
1217
-    /**
1218
-     * @param EE_Registration_Config $EE_Registration_Config
1219
-     * @return EE_Registration_Config
1220
-     * @throws EE_Error
1221
-     * @throws InvalidArgumentException
1222
-     * @throws ReflectionException
1223
-     * @throws InvalidDataTypeException
1224
-     * @throws InvalidInterfaceException
1225
-     */
1226
-    public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config)
1227
-    {
1228
-        $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo();
1229
-        try {
1230
-            $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form();
1231
-            // if not displaying a form, then check for form submission
1232
-            if ($copy_attendee_info_settings_form->was_submitted()) {
1233
-                // capture form data
1234
-                $copy_attendee_info_settings_form->receive_form_submission();
1235
-                // validate form data
1236
-                if ($copy_attendee_info_settings_form->is_valid()) {
1237
-                    // grab validated data from form
1238
-                    $valid_data = $copy_attendee_info_settings_form->valid_data();
1239
-                    if (isset($valid_data['copy_attendee_info'])) {
1240
-                        $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']);
1241
-                    } else {
1242
-                        EE_Error::add_error(
1243
-                            esc_html__(
1244
-                                'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.',
1245
-                                'event_espresso'
1246
-                            ),
1247
-                            __FILE__,
1248
-                            __FUNCTION__,
1249
-                            __LINE__
1250
-                        );
1251
-                    }
1252
-                } else {
1253
-                    if ($copy_attendee_info_settings_form->submission_error_message() !== '') {
1254
-                        EE_Error::add_error(
1255
-                            $copy_attendee_info_settings_form->submission_error_message(),
1256
-                            __FILE__,
1257
-                            __FUNCTION__,
1258
-                            __LINE__
1259
-                        );
1260
-                    }
1261
-                }
1262
-            }
1263
-        } catch (EE_Error $e) {
1264
-            $e->get_error();
1265
-        }
1266
-        return $EE_Registration_Config;
1267
-    }
1268
-
1269
-
1270
-    /**
1271
-     * @return void
1272
-     * @throws EE_Error
1273
-     * @throws InvalidArgumentException
1274
-     * @throws InvalidDataTypeException
1275
-     * @throws InvalidInterfaceException
1276
-     */
1277
-    public function email_validation_settings_form()
1278
-    {
1279
-        echo $this->_email_validation_settings_form()->get_html();
1280
-    }
1281
-
1282
-
1283
-    /**
1284
-     * _email_validation_settings_form
1285
-     *
1286
-     * @access protected
1287
-     * @return EE_Form_Section_Proper
1288
-     * @throws \EE_Error
1289
-     */
1290
-    protected function _email_validation_settings_form()
1291
-    {
1292
-        return new EE_Form_Section_Proper(
1293
-            array(
1294
-                'name'            => 'email_validation_settings',
1295
-                'html_id'         => 'email_validation_settings',
1296
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1297
-                'subsections'     => apply_filters(
1298
-                    'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
1299
-                    array(
1300
-                        'email_validation_hdr'   => new EE_Form_Section_HTML(
1301
-                            EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
1302
-                        ),
1303
-                        'email_validation_level' => new EE_Select_Input(
1304
-                            array(
1305
-                                'basic'      => esc_html__('Basic', 'event_espresso'),
1306
-                                'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
1307
-                                'i18n'       => esc_html__('International', 'event_espresso'),
1308
-                                'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
1309
-                            ),
1310
-                            array(
1311
-                                'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
1312
-                                                     . EEH_Template::get_help_tab_link('email_validation_info'),
1313
-                                'html_help_text'  => esc_html__(
1314
-                                    '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.',
1315
-                                    'event_espresso'
1316
-                                ),
1317
-                                'default'         => isset(
1318
-                                    EE_Registry::instance()->CFG->registration->email_validation_level
1319
-                                )
1320
-                                    ? EE_Registry::instance()->CFG->registration->email_validation_level
1321
-                                    : 'wp_default',
1322
-                                'required'        => false,
1323
-                            )
1324
-                        ),
1325
-                    )
1326
-                ),
1327
-            )
1328
-        );
1329
-    }
1330
-
1331
-
1332
-    /**
1333
-     * @param EE_Registration_Config $EE_Registration_Config
1334
-     * @return EE_Registration_Config
1335
-     * @throws EE_Error
1336
-     * @throws InvalidArgumentException
1337
-     * @throws ReflectionException
1338
-     * @throws InvalidDataTypeException
1339
-     * @throws InvalidInterfaceException
1340
-     */
1341
-    public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1342
-    {
1343
-        $prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1344
-        try {
1345
-            $email_validation_settings_form = $this->_email_validation_settings_form();
1346
-            // if not displaying a form, then check for form submission
1347
-            if ($email_validation_settings_form->was_submitted()) {
1348
-                // capture form data
1349
-                $email_validation_settings_form->receive_form_submission();
1350
-                // validate form data
1351
-                if ($email_validation_settings_form->is_valid()) {
1352
-                    // grab validated data from form
1353
-                    $valid_data = $email_validation_settings_form->valid_data();
1354
-                    if (isset($valid_data['email_validation_level'])) {
1355
-                        $email_validation_level = $valid_data['email_validation_level'];
1356
-                        // now if they want to use international email addresses
1357
-                        if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1358
-                            // in case we need to reset their email validation level,
1359
-                            // make sure that the previous value wasn't already set to one of the i18n options.
1360
-                            if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1361
-                                // if so, then reset it back to "basic" since that is the only other option that,
1362
-                                // despite offering poor validation, supports i18n email addresses
1363
-                                $prev_email_validation_level = 'basic';
1364
-                            }
1365
-                            // confirm our i18n email validation will work on the server
1366
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1367
-                                // or reset email validation level to previous value
1368
-                                $email_validation_level = $prev_email_validation_level;
1369
-                            }
1370
-                        }
1371
-                        $EE_Registration_Config->email_validation_level = $email_validation_level;
1372
-                    } else {
1373
-                        EE_Error::add_error(
1374
-                            esc_html__(
1375
-                                'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1376
-                                'event_espresso'
1377
-                            ),
1378
-                            __FILE__,
1379
-                            __FUNCTION__,
1380
-                            __LINE__
1381
-                        );
1382
-                    }
1383
-                } else {
1384
-                    if ($email_validation_settings_form->submission_error_message() !== '') {
1385
-                        EE_Error::add_error(
1386
-                            $email_validation_settings_form->submission_error_message(),
1387
-                            __FILE__,
1388
-                            __FUNCTION__,
1389
-                            __LINE__
1390
-                        );
1391
-                    }
1392
-                }
1393
-            }
1394
-        } catch (EE_Error $e) {
1395
-            $e->get_error();
1396
-        }
1397
-        return $EE_Registration_Config;
1398
-    }
1399
-
1400
-
1401
-    /**
1402
-     * confirms that the server's PHP version has the PCRE module enabled,
1403
-     * and that the PCRE version works with our i18n email validation
1404
-     *
1405
-     * @param EE_Registration_Config $EE_Registration_Config
1406
-     * @param string                 $email_validation_level
1407
-     * @return bool
1408
-     */
1409
-    private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1410
-    {
1411
-        // first check that PCRE is enabled
1412
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1413
-            EE_Error::add_error(
1414
-                sprintf(
1415
-                    esc_html__(
1416
-                        '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.',
1417
-                        'event_espresso'
1418
-                    ),
1419
-                    '<br />'
1420
-                ),
1421
-                __FILE__,
1422
-                __FUNCTION__,
1423
-                __LINE__
1424
-            );
1425
-            return false;
1426
-        } else {
1427
-            // PCRE support is enabled, but let's still
1428
-            // perform a test to see if the server will support it.
1429
-            // but first, save the updated validation level to the config,
1430
-            // so that the validation strategy picks it up.
1431
-            // this will get bumped back down if it doesn't work
1432
-            $EE_Registration_Config->email_validation_level = $email_validation_level;
1433
-            try {
1434
-                $email_validator = new EE_Email_Validation_Strategy();
1435
-                $i18n_email_address = apply_filters(
1436
-                    'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1437
-                    'jägerjü[email protected]'
1438
-                );
1439
-                $email_validator->validate($i18n_email_address);
1440
-            } catch (Exception $e) {
1441
-                EE_Error::add_error(
1442
-                    sprintf(
1443
-                        esc_html__(
1444
-                            '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',
1445
-                            'event_espresso'
1446
-                        ),
1447
-                        '<br />',
1448
-                        '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>'
1449
-                    ),
1450
-                    __FILE__,
1451
-                    __FUNCTION__,
1452
-                    __LINE__
1453
-                );
1454
-                return false;
1455
-            }
1456
-        }
1457
-        return true;
1458
-    }
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
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
218
+				// 'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
219
+				'metaboxes'     => $this->_default_espresso_metaboxes,
220
+				'require_nonce' => false,
221
+				'qtips'         => array(
222
+					'EE_Registration_Form_Tips',
223
+				),
224
+			),
225
+
226
+			'add_question' => array(
227
+				'nav'           => array(
228
+					'label'      => esc_html__('Add Question', 'event_espresso'),
229
+					'order'      => 5,
230
+					'persistent' => false,
231
+				),
232
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
233
+				'help_tabs'     => array(
234
+					'registration_form_add_question_help_tab' => array(
235
+						'title'    => esc_html__('Add Question', 'event_espresso'),
236
+						'filename' => 'registration_form_add_question',
237
+					),
238
+				),
239
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
240
+				// 'help_tour'     => array('Registration_Form_Add_Question_Help_Tour'),
241
+				'require_nonce' => false,
242
+			),
243
+
244
+			'add_question_group' => array(
245
+				'nav'           => array(
246
+					'label'      => esc_html__('Add Question Group', 'event_espresso'),
247
+					'order'      => 5,
248
+					'persistent' => false,
249
+				),
250
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
251
+				'help_tabs'     => array(
252
+					'registration_form_add_question_group_help_tab' => array(
253
+						'title'    => esc_html__('Add Question Group', 'event_espresso'),
254
+						'filename' => 'registration_form_add_question_group',
255
+					),
256
+				),
257
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
258
+				// 'help_tour'     => array('Registration_Form_Add_Question_Group_Help_Tour'),
259
+				'require_nonce' => false,
260
+			),
261
+
262
+			'edit_question_group' => array(
263
+				'nav'           => array(
264
+					'label'      => esc_html__('Edit Question Group', 'event_espresso'),
265
+					'order'      => 5,
266
+					'persistent' => false,
267
+					'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(
268
+						array('question_group_id' => $this->_req_data['question_group_id']),
269
+						$this->_current_page_view_url
270
+					) : $this->_admin_base_url,
271
+				),
272
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
273
+				'help_tabs'     => array(
274
+					'registration_form_edit_question_group_help_tab' => array(
275
+						'title'    => esc_html__('Edit Question Group', 'event_espresso'),
276
+						'filename' => 'registration_form_edit_question_group',
277
+					),
278
+				),
279
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
280
+				// 'help_tour'     => array('Registration_Form_Edit_Question_Group_Help_Tour'),
281
+				'require_nonce' => false,
282
+			),
283
+
284
+			'view_reg_form_settings' => array(
285
+				'nav'           => array(
286
+					'label' => esc_html__('Reg Form Settings', 'event_espresso'),
287
+					'order' => 40,
288
+				),
289
+				'labels'        => array(
290
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
291
+				),
292
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
293
+				'help_tabs'     => array(
294
+					'registration_form_reg_form_settings_help_tab' => array(
295
+						'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
296
+						'filename' => 'registration_form_reg_form_settings',
297
+					),
298
+				),
299
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
300
+				// 'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
301
+				'require_nonce' => false,
302
+			),
303
+
304
+		);
305
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
306
+
307
+		// change the list table we're going to use so it's the NEW list table!
308
+		$this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
309
+
310
+
311
+		// additional labels
312
+		$new_labels = array(
313
+			'add_question'          => esc_html__('Add New Question', 'event_espresso'),
314
+			'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
315
+			'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
316
+			'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
317
+			'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
318
+		);
319
+		$this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
320
+	}
321
+
322
+
323
+	/**
324
+	 * @return void
325
+	 */
326
+	protected function _ajax_hooks()
327
+	{
328
+		add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
329
+	}
330
+
331
+
332
+	/**
333
+	 * @return void
334
+	 */
335
+	public function load_scripts_styles_question_groups()
336
+	{
337
+		wp_enqueue_script('espresso_ajax_table_sorting');
338
+	}
339
+
340
+
341
+	/**
342
+	 * @return void
343
+	 */
344
+	public function load_scripts_styles_add_question_group()
345
+	{
346
+		$this->load_scripts_styles_forms();
347
+		$this->load_sortable_question_script();
348
+	}
349
+
350
+
351
+	/**
352
+	 * @return void
353
+	 */
354
+	public function load_scripts_styles_edit_question_group()
355
+	{
356
+		$this->load_scripts_styles_forms();
357
+		$this->load_sortable_question_script();
358
+	}
359
+
360
+
361
+	/**
362
+	 * registers and enqueues script for questions
363
+	 *
364
+	 * @return void
365
+	 */
366
+	public function load_sortable_question_script()
367
+	{
368
+		wp_register_script(
369
+			'ee-question-sortable',
370
+			REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
371
+			array('jquery-ui-sortable'),
372
+			EVENT_ESPRESSO_VERSION,
373
+			true
374
+		);
375
+		wp_enqueue_script('ee-question-sortable');
376
+	}
377
+
378
+
379
+	/**
380
+	 * @return void
381
+	 */
382
+	protected function _set_list_table_views_default()
383
+	{
384
+		$this->_views = array(
385
+			'all' => array(
386
+				'slug'        => 'all',
387
+				'label'       => esc_html__('View All Questions', 'event_espresso'),
388
+				'count'       => 0,
389
+				'bulk_action' => array(
390
+					'trash_questions' => esc_html__('Trash', 'event_espresso'),
391
+				),
392
+			),
393
+		);
394
+
395
+		if (
396
+			EE_Registry::instance()->CAP->current_user_can(
397
+				'ee_delete_questions',
398
+				'espresso_registration_form_trash_questions'
399
+			)
400
+		) {
401
+			$this->_views['trash'] = array(
402
+				'slug'        => 'trash',
403
+				'label'       => esc_html__('Trash', 'event_espresso'),
404
+				'count'       => 0,
405
+				'bulk_action' => array(
406
+					'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
407
+					'restore_questions' => esc_html__('Restore', 'event_espresso'),
408
+				),
409
+			);
410
+		}
411
+	}
412
+
413
+
414
+	/**
415
+	 * @return void
416
+	 */
417
+	protected function _set_list_table_views_question_groups()
418
+	{
419
+		$this->_views = array(
420
+			'all' => array(
421
+				'slug'        => 'all',
422
+				'label'       => esc_html__('All', 'event_espresso'),
423
+				'count'       => 0,
424
+				'bulk_action' => array(
425
+					'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
426
+				),
427
+			),
428
+		);
429
+
430
+		if (
431
+			EE_Registry::instance()->CAP->current_user_can(
432
+				'ee_delete_question_groups',
433
+				'espresso_registration_form_trash_question_groups'
434
+			)
435
+		) {
436
+			$this->_views['trash'] = array(
437
+				'slug'        => 'trash',
438
+				'label'       => esc_html__('Trash', 'event_espresso'),
439
+				'count'       => 0,
440
+				'bulk_action' => array(
441
+					'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
442
+					'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
443
+				),
444
+			);
445
+		}
446
+	}
447
+
448
+
449
+	/**
450
+	 * @return void
451
+	 * @throws EE_Error
452
+	 * @throws InvalidArgumentException
453
+	 * @throws InvalidDataTypeException
454
+	 * @throws InvalidInterfaceException
455
+	 */
456
+	protected function _questions_overview_list_table()
457
+	{
458
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
459
+			'add_question',
460
+			'add_question',
461
+			array(),
462
+			'add-new-h2'
463
+		);
464
+		parent::_questions_overview_list_table();
465
+	}
466
+
467
+
468
+	/**
469
+	 * @return void
470
+	 * @throws DomainException
471
+	 * @throws EE_Error
472
+	 * @throws InvalidArgumentException
473
+	 * @throws InvalidDataTypeException
474
+	 * @throws InvalidInterfaceException
475
+	 */
476
+	protected function _question_groups_overview_list_table()
477
+	{
478
+		$this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
479
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
480
+			'add_question_group',
481
+			'add_question_group',
482
+			array(),
483
+			'add-new-h2'
484
+		);
485
+		$this->display_admin_list_table_page_with_sidebar();
486
+	}
487
+
488
+
489
+	/**
490
+	 * @return void
491
+	 * @throws EE_Error
492
+	 * @throws InvalidArgumentException
493
+	 * @throws InvalidDataTypeException
494
+	 * @throws InvalidInterfaceException
495
+	 */
496
+	protected function _delete_question()
497
+	{
498
+		$success = $this->_delete_items($this->_question_model);
499
+		$this->_redirect_after_action(
500
+			$success,
501
+			$this->_question_model->item_name($success),
502
+			'deleted',
503
+			array('action' => 'default', 'status' => 'all')
504
+		);
505
+	}
506
+
507
+
508
+	/**
509
+	 * @return void
510
+	 * @throws EE_Error
511
+	 * @throws InvalidArgumentException
512
+	 * @throws InvalidDataTypeException
513
+	 * @throws InvalidInterfaceException
514
+	 */
515
+	protected function _delete_questions()
516
+	{
517
+		$success = $this->_delete_items($this->_question_model);
518
+		$this->_redirect_after_action(
519
+			$success,
520
+			$this->_question_model->item_name($success),
521
+			'deleted permanently',
522
+			array('action' => 'default', 'status' => 'trash')
523
+		);
524
+	}
525
+
526
+
527
+	/**
528
+	 * Performs the deletion of a single or multiple questions or question groups.
529
+	 *
530
+	 * @param EEM_Soft_Delete_Base $model
531
+	 * @return int number of items deleted permanently
532
+	 * @throws EE_Error
533
+	 * @throws InvalidArgumentException
534
+	 * @throws InvalidDataTypeException
535
+	 * @throws InvalidInterfaceException
536
+	 */
537
+	private function _delete_items(EEM_Soft_Delete_Base $model)
538
+	{
539
+		$success = 0;
540
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
541
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
542
+			// if array has more than one element than success message should be plural
543
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
544
+			// cycle thru bulk action checkboxes
545
+			while (list($ID, $value) = each($this->_req_data['checkbox'])) {
546
+				if (! $this->_delete_item($ID, $model)) {
547
+					$success = 0;
548
+				}
549
+			}
550
+		} elseif (! empty($this->_req_data['QSG_ID'])) {
551
+			$success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
552
+		} elseif (! empty($this->_req_data['QST_ID'])) {
553
+			$success = $this->_delete_item($this->_req_data['QST_ID'], $model);
554
+		} else {
555
+			EE_Error::add_error(
556
+				sprintf(
557
+					esc_html__(
558
+						"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.",
559
+						"event_espresso"
560
+					)
561
+				),
562
+				__FILE__,
563
+				__FUNCTION__,
564
+				__LINE__
565
+			);
566
+		}
567
+		return $success;
568
+	}
569
+
570
+
571
+	/**
572
+	 * Deletes the specified question (and its associated question options) or question group
573
+	 *
574
+	 * @param int                  $id
575
+	 * @param EEM_Soft_Delete_Base $model
576
+	 * @return boolean
577
+	 * @throws EE_Error
578
+	 * @throws InvalidArgumentException
579
+	 * @throws InvalidDataTypeException
580
+	 * @throws InvalidInterfaceException
581
+	 */
582
+	protected function _delete_item($id, $model)
583
+	{
584
+		if ($model instanceof EEM_Question) {
585
+			EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
586
+		}
587
+		return $model->delete_permanently_by_ID(absint($id));
588
+	}
589
+
590
+
591
+	/******************************    QUESTION GROUPS    ******************************/
592
+
593
+
594
+	/**
595
+	 * @param string $type
596
+	 * @return void
597
+	 * @throws DomainException
598
+	 * @throws EE_Error
599
+	 * @throws InvalidArgumentException
600
+	 * @throws InvalidDataTypeException
601
+	 * @throws InvalidInterfaceException
602
+	 */
603
+	protected function _edit_question_group($type = 'add')
604
+	{
605
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
606
+		$ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID'])
607
+			? absint($this->_req_data['QSG_ID'])
608
+			: false;
609
+
610
+		switch ($this->_req_action) {
611
+			case 'add_question_group':
612
+				$this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
613
+				break;
614
+			case 'edit_question_group':
615
+				$this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
616
+				break;
617
+			default:
618
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
619
+		}
620
+		// add ID to title if editing
621
+		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
622
+		if ($ID) {
623
+			/** @var EE_Question_Group $questionGroup */
624
+			$questionGroup = $this->_question_group_model->get_one_by_ID($ID);
625
+			$additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
626
+			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
627
+		} else {
628
+			/** @var EE_Question_Group $questionGroup */
629
+			$questionGroup = EEM_Question_Group::instance()->create_default_object();
630
+			$questionGroup->set_order_to_latest();
631
+			$this->_set_add_edit_form_tags('insert_question_group');
632
+		}
633
+		$this->_template_args['values'] = $this->_yes_no_values;
634
+		$this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
635
+		$this->_template_args['QSG_ID'] = $ID ? $ID : true;
636
+		$this->_template_args['question_group'] = $questionGroup;
637
+
638
+		$redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
639
+		$this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
640
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
641
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
642
+			$this->_template_args,
643
+			true
644
+		);
645
+
646
+		// the details template wrapper
647
+		$this->display_admin_page_with_sidebar();
648
+	}
649
+
650
+
651
+	/**
652
+	 * @return void
653
+	 * @throws EE_Error
654
+	 * @throws InvalidArgumentException
655
+	 * @throws InvalidDataTypeException
656
+	 * @throws InvalidInterfaceException
657
+	 */
658
+	protected function _delete_question_groups()
659
+	{
660
+		$success = $this->_delete_items($this->_question_group_model);
661
+		$this->_redirect_after_action(
662
+			$success,
663
+			$this->_question_group_model->item_name($success),
664
+			'deleted permanently',
665
+			array('action' => 'question_groups', 'status' => 'trash')
666
+		);
667
+	}
668
+
669
+
670
+	/**
671
+	 * @param bool $new_question_group
672
+	 * @throws EE_Error
673
+	 * @throws InvalidArgumentException
674
+	 * @throws InvalidDataTypeException
675
+	 * @throws InvalidInterfaceException
676
+	 */
677
+	protected function _insert_or_update_question_group($new_question_group = true)
678
+	{
679
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
680
+		$set_column_values = $this->_set_column_values_for($this->_question_group_model);
681
+		if ($new_question_group) {
682
+			// make sure identifier is unique
683
+			$identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : '';
684
+			$identifier_exists = ! empty($identifier_value)
685
+				? $this->_question_group_model->count([['QSG_identifier' => $set_column_values['QSG_identifier']]]) > 0
686
+				: false;
687
+			if ($identifier_exists) {
688
+				$set_column_values['QSG_identifier'] .= uniqid('id', true);
689
+			}
690
+			$QSG_ID = $this->_question_group_model->insert($set_column_values);
691
+			$success = $QSG_ID ? 1 : 0;
692
+			if ($success === 0) {
693
+				EE_Error::add_error(
694
+					esc_html__('Something went wrong saving the question group.', 'event_espresso'),
695
+					__FILE__,
696
+					__FUNCTION__,
697
+					__LINE__
698
+				);
699
+				$this->_redirect_after_action(
700
+					false,
701
+					'',
702
+					'',
703
+					array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
704
+					true
705
+				);
706
+			}
707
+		} else {
708
+			$QSG_ID = absint($this->_req_data['QSG_ID']);
709
+			unset($set_column_values['QSG_ID']);
710
+			$success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
711
+		}
712
+
713
+		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(
714
+			EEM_Attendee::system_question_phone
715
+		);
716
+		// update the existing related questions
717
+		// BUT FIRST...  delete the phone question from the Question_Group_Question
718
+		// if it is being added to this question group (therefore removed from the existing group)
719
+		if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
720
+			// delete where QST ID = system phone question ID and Question Group ID is NOT this group
721
+			EEM_Question_Group_Question::instance()->delete(
722
+				array(
723
+					array(
724
+						'QST_ID' => $phone_question_id,
725
+						'QSG_ID' => array('!=', $QSG_ID),
726
+					),
727
+				)
728
+			);
729
+		}
730
+		/** @type EE_Question_Group $question_group */
731
+		$question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
732
+		$questions = $question_group->questions();
733
+		// make sure system phone question is added to list of questions for this group
734
+		if (! isset($questions[ $phone_question_id ])) {
735
+			$questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
736
+		}
737
+
738
+		foreach ($questions as $question_ID => $question) {
739
+			// first we always check for order.
740
+			if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
741
+				// update question order
742
+				$question_group->update_question_order(
743
+					$question_ID,
744
+					$this->_req_data['question_orders'][ $question_ID ]
745
+				);
746
+			}
747
+
748
+			// then we always check if adding or removing.
749
+			if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
750
+				$question_group->add_question($question_ID);
751
+			} else {
752
+				// not found, remove it (but only if not a system question for the personal group
753
+				// with the exception of lname system question - we allow removal of it)
754
+				if (
755
+					in_array(
756
+						$question->system_ID(),
757
+						EEM_Question::instance()->required_system_questions_in_system_question_group(
758
+							$question_group->system_group()
759
+						)
760
+					)
761
+				) {
762
+					continue;
763
+				} else {
764
+					$question_group->remove_question($question_ID);
765
+				}
766
+			}
767
+		}
768
+		// save new related questions
769
+		if (isset($this->_req_data['questions'])) {
770
+			foreach ($this->_req_data['questions'] as $QST_ID) {
771
+				$question_group->add_question($QST_ID);
772
+				if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
773
+					$question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
774
+				}
775
+			}
776
+		}
777
+
778
+		if ($success !== false) {
779
+			$msg = $new_question_group
780
+				? sprintf(
781
+					esc_html__('The %s has been created', 'event_espresso'),
782
+					$this->_question_group_model->item_name()
783
+				)
784
+				: sprintf(
785
+					esc_html__(
786
+						'The %s has been updated',
787
+						'event_espresso'
788
+					),
789
+					$this->_question_group_model->item_name()
790
+				);
791
+			EE_Error::add_success($msg);
792
+		}
793
+		$this->_redirect_after_action(
794
+			false,
795
+			'',
796
+			'',
797
+			array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
798
+			true
799
+		);
800
+	}
801
+
802
+
803
+	/**
804
+	 * duplicates a question and all its question options and redirects to the new question.
805
+	 *
806
+	 * @return void
807
+	 * @throws EE_Error
808
+	 * @throws InvalidArgumentException
809
+	 * @throws ReflectionException
810
+	 * @throws InvalidDataTypeException
811
+	 * @throws InvalidInterfaceException
812
+	 */
813
+	public function _duplicate_question()
814
+	{
815
+		$question_ID = (int) $this->_req_data['QST_ID'];
816
+		$question = EEM_Question::instance()->get_one_by_ID($question_ID);
817
+		if ($question instanceof EE_Question) {
818
+			$new_question = $question->duplicate();
819
+			if ($new_question instanceof EE_Question) {
820
+				$this->_redirect_after_action(
821
+					true,
822
+					esc_html__('Question', 'event_espresso'),
823
+					esc_html__('Duplicated', 'event_espresso'),
824
+					array('action' => 'edit_question', 'QST_ID' => $new_question->ID()),
825
+					true
826
+				);
827
+			} else {
828
+				global $wpdb;
829
+				EE_Error::add_error(
830
+					sprintf(
831
+						esc_html__(
832
+							'Could not duplicate question with ID %1$d because: %2$s',
833
+							'event_espresso'
834
+						),
835
+						$question_ID,
836
+						$wpdb->last_error
837
+					),
838
+					__FILE__,
839
+					__FUNCTION__,
840
+					__LINE__
841
+				);
842
+				$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
843
+			}
844
+		} else {
845
+			EE_Error::add_error(
846
+				sprintf(
847
+					esc_html__(
848
+						'Could not duplicate question with ID %d because it didn\'t exist!',
849
+						'event_espresso'
850
+					),
851
+					$question_ID
852
+				),
853
+				__FILE__,
854
+				__FUNCTION__,
855
+				__LINE__
856
+			);
857
+			$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
858
+		}
859
+	}
860
+
861
+
862
+	/**
863
+	 * @param bool $trash
864
+	 * @throws EE_Error
865
+	 */
866
+	protected function _trash_or_restore_question_groups($trash = true)
867
+	{
868
+		$this->_trash_or_restore_items($this->_question_group_model, $trash);
869
+	}
870
+
871
+
872
+	/**
873
+	 *_trash_question
874
+	 *
875
+	 * @return void
876
+	 * @throws EE_Error
877
+	 */
878
+	protected function _trash_question()
879
+	{
880
+		$success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
881
+		$query_args = array('action' => 'default', 'status' => 'all');
882
+		$this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
883
+	}
884
+
885
+
886
+	/**
887
+	 * @param bool $trash
888
+	 * @throws EE_Error
889
+	 */
890
+	protected function _trash_or_restore_questions($trash = true)
891
+	{
892
+		$this->_trash_or_restore_items($this->_question_model, $trash);
893
+	}
894
+
895
+
896
+	/**
897
+	 * Internally used to delete or restore items, using the request data. Meant to be
898
+	 * flexible between question or question groups
899
+	 *
900
+	 * @param EEM_Soft_Delete_Base $model
901
+	 * @param boolean              $trash whether to trash or restore
902
+	 * @throws EE_Error
903
+	 */
904
+	private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
905
+	{
906
+
907
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
908
+
909
+		$success = 1;
910
+		// Checkboxes
911
+		// echo "trash $trash";
912
+		// var_dump($this->_req_data['checkbox']);die;
913
+		if (isset($this->_req_data['checkbox'])) {
914
+			if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
915
+				// if array has more than one element than success message should be plural
916
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
917
+				// cycle thru bulk action checkboxes
918
+				while (list($ID, $value) = each($this->_req_data['checkbox'])) {
919
+					if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
920
+						$success = 0;
921
+					}
922
+				}
923
+			} else {
924
+				// grab single id and delete
925
+				$ID = absint($this->_req_data['checkbox']);
926
+				if (! $model->delete_or_restore_by_ID($trash, $ID)) {
927
+					$success = 0;
928
+				}
929
+			}
930
+		} else {
931
+			// delete via trash link
932
+			// grab single id and delete
933
+			$ID = absint($this->_req_data[ $model->primary_key_name() ]);
934
+			if (! $model->delete_or_restore_by_ID($trash, $ID)) {
935
+				$success = 0;
936
+			}
937
+		}
938
+
939
+
940
+		$action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
941
+		// echo "action :$action";
942
+		// $action = 'questions' ? 'default' : $action;
943
+		if ($trash) {
944
+			$action_desc = 'trashed';
945
+			$status = 'trash';
946
+		} else {
947
+			$action_desc = 'restored';
948
+			$status = 'all';
949
+		}
950
+		$this->_redirect_after_action(
951
+			$success,
952
+			$model->item_name($success),
953
+			$action_desc,
954
+			array('action' => $action, 'status' => $status)
955
+		);
956
+	}
957
+
958
+
959
+	/**
960
+	 * @param            $per_page
961
+	 * @param int        $current_page
962
+	 * @param bool|false $count
963
+	 * @return EE_Soft_Delete_Base_Class[]|int
964
+	 * @throws EE_Error
965
+	 * @throws InvalidArgumentException
966
+	 * @throws InvalidDataTypeException
967
+	 * @throws InvalidInterfaceException
968
+	 */
969
+	public function get_trashed_questions($per_page, $current_page = 1, $count = false)
970
+	{
971
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
972
+
973
+		if ($count) {
974
+			// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
975
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
976
+			$results = $this->_question_model->count_deleted($where);
977
+		} else {
978
+			// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
979
+			$results = $this->_question_model->get_all_deleted($query_params);
980
+		}
981
+		return $results;
982
+	}
983
+
984
+
985
+	/**
986
+	 * @param            $per_page
987
+	 * @param int        $current_page
988
+	 * @param bool|false $count
989
+	 * @return EE_Soft_Delete_Base_Class[]|int
990
+	 * @throws EE_Error
991
+	 * @throws InvalidArgumentException
992
+	 * @throws InvalidDataTypeException
993
+	 * @throws InvalidInterfaceException
994
+	 */
995
+	public function get_question_groups($per_page, $current_page = 1, $count = false)
996
+	{
997
+		$questionGroupModel = EEM_Question_Group::instance();
998
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
999
+		if ($count) {
1000
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
1001
+			$results = $questionGroupModel->count($where);
1002
+		} else {
1003
+			$results = $questionGroupModel->get_all($query_params);
1004
+		}
1005
+		return $results;
1006
+	}
1007
+
1008
+
1009
+	/**
1010
+	 * @param      $per_page
1011
+	 * @param int  $current_page
1012
+	 * @param bool $count
1013
+	 * @return EE_Soft_Delete_Base_Class[]|int
1014
+	 * @throws EE_Error
1015
+	 * @throws InvalidArgumentException
1016
+	 * @throws InvalidDataTypeException
1017
+	 * @throws InvalidInterfaceException
1018
+	 */
1019
+	public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
1020
+	{
1021
+		$questionGroupModel = EEM_Question_Group::instance();
1022
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
1023
+		if ($count) {
1024
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
1025
+			$query_params['limit'] = null;
1026
+			$results = $questionGroupModel->count_deleted($where);
1027
+		} else {
1028
+			$results = $questionGroupModel->get_all_deleted($query_params);
1029
+		}
1030
+		return $results;
1031
+	}
1032
+
1033
+
1034
+	/**
1035
+	 * method for performing updates to question order
1036
+	 *
1037
+	 * @return void results array
1038
+	 * @throws EE_Error
1039
+	 * @throws InvalidArgumentException
1040
+	 * @throws InvalidDataTypeException
1041
+	 * @throws InvalidInterfaceException
1042
+	 */
1043
+	public function update_question_group_order()
1044
+	{
1045
+
1046
+		$success = esc_html__('Question group order was updated successfully.', 'event_espresso');
1047
+
1048
+		// grab our row IDs
1049
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
1050
+			? explode(',', rtrim($this->_req_data['row_ids'], ','))
1051
+			: array();
1052
+
1053
+		$perpage = ! empty($this->_req_data['perpage'])
1054
+			? (int) $this->_req_data['perpage']
1055
+			: null;
1056
+		$curpage = ! empty($this->_req_data['curpage'])
1057
+			? (int) $this->_req_data['curpage']
1058
+			: null;
1059
+
1060
+		if (! empty($row_ids)) {
1061
+			// figure out where we start the row_id count at for the current page.
1062
+			$qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1063
+
1064
+			$row_count = count($row_ids);
1065
+			for ($i = 0; $i < $row_count; $i++) {
1066
+				// Update the questions when re-ordering
1067
+				$updated = EEM_Question_Group::instance()->update(
1068
+					array('QSG_order' => $qsgcount),
1069
+					array(array('QSG_ID' => $row_ids[ $i ]))
1070
+				);
1071
+				if ($updated === false) {
1072
+					$success = false;
1073
+				}
1074
+				$qsgcount++;
1075
+			}
1076
+		} else {
1077
+			$success = false;
1078
+		}
1079
+
1080
+		$errors = ! $success
1081
+			? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
1082
+			: false;
1083
+
1084
+		echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
1085
+		die();
1086
+	}
1087
+
1088
+
1089
+
1090
+	/***************************************       REGISTRATION SETTINGS       ***************************************/
1091
+
1092
+
1093
+	/**
1094
+	 * @throws DomainException
1095
+	 * @throws EE_Error
1096
+	 * @throws InvalidArgumentException
1097
+	 * @throws InvalidDataTypeException
1098
+	 * @throws InvalidInterfaceException
1099
+	 */
1100
+	protected function _reg_form_settings()
1101
+	{
1102
+		$this->_template_args['values'] = $this->_yes_no_values;
1103
+		add_action(
1104
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1105
+			array($this, 'email_validation_settings_form'),
1106
+			2
1107
+		);
1108
+		add_action(
1109
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1110
+			array($this, 'copy_attendee_info_settings_form'),
1111
+			4
1112
+		);
1113
+		$this->_template_args = (array) apply_filters(
1114
+			'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
1115
+			$this->_template_args
1116
+		);
1117
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
1118
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1119
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1120
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1121
+			$this->_template_args,
1122
+			true
1123
+		);
1124
+		$this->display_admin_page_with_sidebar();
1125
+	}
1126
+
1127
+
1128
+	/**
1129
+	 * @return void
1130
+	 * @throws EE_Error
1131
+	 * @throws InvalidArgumentException
1132
+	 * @throws ReflectionException
1133
+	 * @throws InvalidDataTypeException
1134
+	 * @throws InvalidInterfaceException
1135
+	 */
1136
+	protected function _update_reg_form_settings()
1137
+	{
1138
+		EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
1139
+			EE_Registry::instance()->CFG->registration
1140
+		);
1141
+		EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form(
1142
+			EE_Registry::instance()->CFG->registration
1143
+		);
1144
+		EE_Registry::instance()->CFG->registration = apply_filters(
1145
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
1146
+			EE_Registry::instance()->CFG->registration
1147
+		);
1148
+		$success = $this->_update_espresso_configuration(
1149
+			esc_html__('Registration Form Options', 'event_espresso'),
1150
+			EE_Registry::instance()->CFG,
1151
+			__FILE__,
1152
+			__FUNCTION__,
1153
+			__LINE__
1154
+		);
1155
+		$this->_redirect_after_action(
1156
+			$success,
1157
+			esc_html__('Registration Form Options', 'event_espresso'),
1158
+			'updated',
1159
+			array('action' => 'view_reg_form_settings')
1160
+		);
1161
+	}
1162
+
1163
+
1164
+	/**
1165
+	 * @return void
1166
+	 * @throws EE_Error
1167
+	 * @throws InvalidArgumentException
1168
+	 * @throws InvalidDataTypeException
1169
+	 * @throws InvalidInterfaceException
1170
+	 */
1171
+	public function copy_attendee_info_settings_form()
1172
+	{
1173
+		echo $this->_copy_attendee_info_settings_form()->get_html();
1174
+	}
1175
+
1176
+	/**
1177
+	 * _copy_attendee_info_settings_form
1178
+	 *
1179
+	 * @access protected
1180
+	 * @return EE_Form_Section_Proper
1181
+	 * @throws \EE_Error
1182
+	 */
1183
+	protected function _copy_attendee_info_settings_form()
1184
+	{
1185
+		return new EE_Form_Section_Proper(
1186
+			array(
1187
+				'name'            => 'copy_attendee_info_settings',
1188
+				'html_id'         => 'copy_attendee_info_settings',
1189
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1190
+				'subsections'     => apply_filters(
1191
+					'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections',
1192
+					array(
1193
+						'copy_attendee_info_hdr'   => new EE_Form_Section_HTML(
1194
+							EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso'))
1195
+						),
1196
+						'copy_attendee_info' => new EE_Yes_No_Input(
1197
+							array(
1198
+								'html_label_text' => esc_html__(
1199
+									'Allow copy #1 attendee info to extra attendees?',
1200
+									'event_espresso'
1201
+								),
1202
+								'html_help_text'  => esc_html__(
1203
+									'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.',
1204
+									'event_espresso'
1205
+								),
1206
+								'default'         => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(),
1207
+								'required'        => false,
1208
+								'display_html_label_text' => false,
1209
+							)
1210
+						),
1211
+					)
1212
+				),
1213
+			)
1214
+		);
1215
+	}
1216
+
1217
+	/**
1218
+	 * @param EE_Registration_Config $EE_Registration_Config
1219
+	 * @return EE_Registration_Config
1220
+	 * @throws EE_Error
1221
+	 * @throws InvalidArgumentException
1222
+	 * @throws ReflectionException
1223
+	 * @throws InvalidDataTypeException
1224
+	 * @throws InvalidInterfaceException
1225
+	 */
1226
+	public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config)
1227
+	{
1228
+		$prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo();
1229
+		try {
1230
+			$copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form();
1231
+			// if not displaying a form, then check for form submission
1232
+			if ($copy_attendee_info_settings_form->was_submitted()) {
1233
+				// capture form data
1234
+				$copy_attendee_info_settings_form->receive_form_submission();
1235
+				// validate form data
1236
+				if ($copy_attendee_info_settings_form->is_valid()) {
1237
+					// grab validated data from form
1238
+					$valid_data = $copy_attendee_info_settings_form->valid_data();
1239
+					if (isset($valid_data['copy_attendee_info'])) {
1240
+						$EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']);
1241
+					} else {
1242
+						EE_Error::add_error(
1243
+							esc_html__(
1244
+								'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.',
1245
+								'event_espresso'
1246
+							),
1247
+							__FILE__,
1248
+							__FUNCTION__,
1249
+							__LINE__
1250
+						);
1251
+					}
1252
+				} else {
1253
+					if ($copy_attendee_info_settings_form->submission_error_message() !== '') {
1254
+						EE_Error::add_error(
1255
+							$copy_attendee_info_settings_form->submission_error_message(),
1256
+							__FILE__,
1257
+							__FUNCTION__,
1258
+							__LINE__
1259
+						);
1260
+					}
1261
+				}
1262
+			}
1263
+		} catch (EE_Error $e) {
1264
+			$e->get_error();
1265
+		}
1266
+		return $EE_Registration_Config;
1267
+	}
1268
+
1269
+
1270
+	/**
1271
+	 * @return void
1272
+	 * @throws EE_Error
1273
+	 * @throws InvalidArgumentException
1274
+	 * @throws InvalidDataTypeException
1275
+	 * @throws InvalidInterfaceException
1276
+	 */
1277
+	public function email_validation_settings_form()
1278
+	{
1279
+		echo $this->_email_validation_settings_form()->get_html();
1280
+	}
1281
+
1282
+
1283
+	/**
1284
+	 * _email_validation_settings_form
1285
+	 *
1286
+	 * @access protected
1287
+	 * @return EE_Form_Section_Proper
1288
+	 * @throws \EE_Error
1289
+	 */
1290
+	protected function _email_validation_settings_form()
1291
+	{
1292
+		return new EE_Form_Section_Proper(
1293
+			array(
1294
+				'name'            => 'email_validation_settings',
1295
+				'html_id'         => 'email_validation_settings',
1296
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1297
+				'subsections'     => apply_filters(
1298
+					'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
1299
+					array(
1300
+						'email_validation_hdr'   => new EE_Form_Section_HTML(
1301
+							EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
1302
+						),
1303
+						'email_validation_level' => new EE_Select_Input(
1304
+							array(
1305
+								'basic'      => esc_html__('Basic', 'event_espresso'),
1306
+								'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
1307
+								'i18n'       => esc_html__('International', 'event_espresso'),
1308
+								'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
1309
+							),
1310
+							array(
1311
+								'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
1312
+													 . EEH_Template::get_help_tab_link('email_validation_info'),
1313
+								'html_help_text'  => esc_html__(
1314
+									'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.',
1315
+									'event_espresso'
1316
+								),
1317
+								'default'         => isset(
1318
+									EE_Registry::instance()->CFG->registration->email_validation_level
1319
+								)
1320
+									? EE_Registry::instance()->CFG->registration->email_validation_level
1321
+									: 'wp_default',
1322
+								'required'        => false,
1323
+							)
1324
+						),
1325
+					)
1326
+				),
1327
+			)
1328
+		);
1329
+	}
1330
+
1331
+
1332
+	/**
1333
+	 * @param EE_Registration_Config $EE_Registration_Config
1334
+	 * @return EE_Registration_Config
1335
+	 * @throws EE_Error
1336
+	 * @throws InvalidArgumentException
1337
+	 * @throws ReflectionException
1338
+	 * @throws InvalidDataTypeException
1339
+	 * @throws InvalidInterfaceException
1340
+	 */
1341
+	public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1342
+	{
1343
+		$prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1344
+		try {
1345
+			$email_validation_settings_form = $this->_email_validation_settings_form();
1346
+			// if not displaying a form, then check for form submission
1347
+			if ($email_validation_settings_form->was_submitted()) {
1348
+				// capture form data
1349
+				$email_validation_settings_form->receive_form_submission();
1350
+				// validate form data
1351
+				if ($email_validation_settings_form->is_valid()) {
1352
+					// grab validated data from form
1353
+					$valid_data = $email_validation_settings_form->valid_data();
1354
+					if (isset($valid_data['email_validation_level'])) {
1355
+						$email_validation_level = $valid_data['email_validation_level'];
1356
+						// now if they want to use international email addresses
1357
+						if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1358
+							// in case we need to reset their email validation level,
1359
+							// make sure that the previous value wasn't already set to one of the i18n options.
1360
+							if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1361
+								// if so, then reset it back to "basic" since that is the only other option that,
1362
+								// despite offering poor validation, supports i18n email addresses
1363
+								$prev_email_validation_level = 'basic';
1364
+							}
1365
+							// confirm our i18n email validation will work on the server
1366
+							if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1367
+								// or reset email validation level to previous value
1368
+								$email_validation_level = $prev_email_validation_level;
1369
+							}
1370
+						}
1371
+						$EE_Registration_Config->email_validation_level = $email_validation_level;
1372
+					} else {
1373
+						EE_Error::add_error(
1374
+							esc_html__(
1375
+								'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1376
+								'event_espresso'
1377
+							),
1378
+							__FILE__,
1379
+							__FUNCTION__,
1380
+							__LINE__
1381
+						);
1382
+					}
1383
+				} else {
1384
+					if ($email_validation_settings_form->submission_error_message() !== '') {
1385
+						EE_Error::add_error(
1386
+							$email_validation_settings_form->submission_error_message(),
1387
+							__FILE__,
1388
+							__FUNCTION__,
1389
+							__LINE__
1390
+						);
1391
+					}
1392
+				}
1393
+			}
1394
+		} catch (EE_Error $e) {
1395
+			$e->get_error();
1396
+		}
1397
+		return $EE_Registration_Config;
1398
+	}
1399
+
1400
+
1401
+	/**
1402
+	 * confirms that the server's PHP version has the PCRE module enabled,
1403
+	 * and that the PCRE version works with our i18n email validation
1404
+	 *
1405
+	 * @param EE_Registration_Config $EE_Registration_Config
1406
+	 * @param string                 $email_validation_level
1407
+	 * @return bool
1408
+	 */
1409
+	private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1410
+	{
1411
+		// first check that PCRE is enabled
1412
+		if (! defined('PREG_BAD_UTF8_ERROR')) {
1413
+			EE_Error::add_error(
1414
+				sprintf(
1415
+					esc_html__(
1416
+						'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.',
1417
+						'event_espresso'
1418
+					),
1419
+					'<br />'
1420
+				),
1421
+				__FILE__,
1422
+				__FUNCTION__,
1423
+				__LINE__
1424
+			);
1425
+			return false;
1426
+		} else {
1427
+			// PCRE support is enabled, but let's still
1428
+			// perform a test to see if the server will support it.
1429
+			// but first, save the updated validation level to the config,
1430
+			// so that the validation strategy picks it up.
1431
+			// this will get bumped back down if it doesn't work
1432
+			$EE_Registration_Config->email_validation_level = $email_validation_level;
1433
+			try {
1434
+				$email_validator = new EE_Email_Validation_Strategy();
1435
+				$i18n_email_address = apply_filters(
1436
+					'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1437
+					'jägerjü[email protected]'
1438
+				);
1439
+				$email_validator->validate($i18n_email_address);
1440
+			} catch (Exception $e) {
1441
+				EE_Error::add_error(
1442
+					sprintf(
1443
+						esc_html__(
1444
+							'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',
1445
+							'event_espresso'
1446
+						),
1447
+						'<br />',
1448
+						'<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>'
1449
+					),
1450
+					__FILE__,
1451
+					__FUNCTION__,
1452
+					__LINE__
1453
+				);
1454
+				return false;
1455
+			}
1456
+		}
1457
+		return true;
1458
+	}
1459 1459
 }
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
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.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -29,84 +29,84 @@
 block discarded – undo
29 29
 class BootstrapRequestResponseObjects
30 30
 {
31 31
 
32
-    /**
33
-     * @type LegacyRequestInterface $legacy_request
34
-     */
35
-    protected $legacy_request;
32
+	/**
33
+	 * @type LegacyRequestInterface $legacy_request
34
+	 */
35
+	protected $legacy_request;
36 36
 
37
-    /**
38
-     * @type LoaderInterface $loader
39
-     */
40
-    protected $loader;
37
+	/**
38
+	 * @type LoaderInterface $loader
39
+	 */
40
+	protected $loader;
41 41
 
42
-    /**
43
-     * @var RequestInterface $request
44
-     */
45
-    protected $request;
42
+	/**
43
+	 * @var RequestInterface $request
44
+	 */
45
+	protected $request;
46 46
 
47
-    /**
48
-     * @var ResponseInterface $response
49
-     */
50
-    protected $response;
47
+	/**
48
+	 * @var ResponseInterface $response
49
+	 */
50
+	protected $response;
51 51
 
52 52
 
53
-    /**
54
-     * BootstrapRequestResponseObjects constructor.
55
-     *
56
-     * @param LoaderInterface $loader
57
-     */
58
-    public function __construct(LoaderInterface $loader)
59
-    {
60
-        $this->loader = $loader;
61
-    }
53
+	/**
54
+	 * BootstrapRequestResponseObjects constructor.
55
+	 *
56
+	 * @param LoaderInterface $loader
57
+	 */
58
+	public function __construct(LoaderInterface $loader)
59
+	{
60
+		$this->loader = $loader;
61
+	}
62 62
 
63 63
 
64
-    /**
65
-     * @return void
66
-     */
67
-    public function buildRequestResponse()
68
-    {
69
-        $request_params = new RequestParams(new RequestSanitizer());
70
-        $server_params = new ServerParams(new ServerSanitizer());
71
-        // load our Request and Response objects
72
-        $this->request = new Request($request_params, $server_params);
73
-        $this->response = new Response();
74
-        $this->loader->share(RequestParams::class, $request_params);
75
-        $this->loader->share(ServerParams::class, $server_params);
76
-    }
64
+	/**
65
+	 * @return void
66
+	 */
67
+	public function buildRequestResponse()
68
+	{
69
+		$request_params = new RequestParams(new RequestSanitizer());
70
+		$server_params = new ServerParams(new ServerSanitizer());
71
+		// load our Request and Response objects
72
+		$this->request = new Request($request_params, $server_params);
73
+		$this->response = new Response();
74
+		$this->loader->share(RequestParams::class, $request_params);
75
+		$this->loader->share(ServerParams::class, $server_params);
76
+	}
77 77
 
78 78
 
79
-    /**
80
-     * @return void
81
-     * @throws InvalidArgumentException
82
-     */
83
-    public function shareRequestResponse()
84
-    {
85
-        $this->loader->share('EventEspresso\core\services\request\Request', $this->request);
86
-        $this->loader->share('EventEspresso\core\services\request\Response', $this->response);
87
-        EE_Dependency_Map::instance()->setRequest($this->request);
88
-        EE_Dependency_Map::instance()->setResponse($this->response);
89
-    }
79
+	/**
80
+	 * @return void
81
+	 * @throws InvalidArgumentException
82
+	 */
83
+	public function shareRequestResponse()
84
+	{
85
+		$this->loader->share('EventEspresso\core\services\request\Request', $this->request);
86
+		$this->loader->share('EventEspresso\core\services\request\Response', $this->response);
87
+		EE_Dependency_Map::instance()->setRequest($this->request);
88
+		EE_Dependency_Map::instance()->setResponse($this->response);
89
+	}
90 90
 
91 91
 
92
-    /**
93
-     * @return void
94
-     * @throws InvalidArgumentException
95
-     * @throws EE_Error
96
-     */
97
-    public function setupLegacyRequest()
98
-    {
99
-        espresso_load_required(
100
-            'EE_Request',
101
-            EE_CORE . 'request_stack/EE_Request.core.php'
102
-        );
103
-        $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
104
-        $this->legacy_request->setRequest($this->request);
105
-        $this->legacy_request->admin = $this->request->isAdmin();
106
-        $this->legacy_request->ajax = $this->request->isAjax();
107
-        $this->legacy_request->front_ajax = $this->request->isFrontAjax();
108
-        EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
109
-        $this->loader->share('EE_Request', $this->legacy_request);
110
-        $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
111
-    }
92
+	/**
93
+	 * @return void
94
+	 * @throws InvalidArgumentException
95
+	 * @throws EE_Error
96
+	 */
97
+	public function setupLegacyRequest()
98
+	{
99
+		espresso_load_required(
100
+			'EE_Request',
101
+			EE_CORE . 'request_stack/EE_Request.core.php'
102
+		);
103
+		$this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
104
+		$this->legacy_request->setRequest($this->request);
105
+		$this->legacy_request->admin = $this->request->isAdmin();
106
+		$this->legacy_request->ajax = $this->request->isAjax();
107
+		$this->legacy_request->front_ajax = $this->request->isFrontAjax();
108
+		EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
109
+		$this->loader->share('EE_Request', $this->legacy_request);
110
+		$this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
111
+	}
112 112
 }
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.
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.
core/services/shortcodes/LegacyShortcodesManager.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
75 75
             array()
76 76
         );
77
-        if (! empty($shortcodes_to_register)) {
77
+        if ( ! empty($shortcodes_to_register)) {
78 78
             // cycle thru shortcode folders
79 79
             foreach ($shortcodes_to_register as $shortcode_path) {
80 80
                 // add to list of installed shortcode modules
@@ -119,44 +119,44 @@  discard block
 block discarded – undo
119 119
             // remove last segment
120 120
             array_pop($shortcode_path);
121 121
             // glue it back together
122
-            $shortcode_path = implode('/', $shortcode_path) . '/';
122
+            $shortcode_path = implode('/', $shortcode_path).'/';
123 123
         } else {
124 124
             // we need to generate the filename based off of the folder name
125 125
             // grab and sanitize shortcode directory name
126 126
             $shortcode = sanitize_key(basename($shortcode_path));
127
-            $shortcode_path = rtrim($shortcode_path, '/') . '/';
127
+            $shortcode_path = rtrim($shortcode_path, '/').'/';
128 128
         }
129 129
         // create classname from shortcode directory or file name
130 130
         $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
131 131
         // add class prefix
132
-        $shortcode_class = 'EES_' . $shortcode;
132
+        $shortcode_class = 'EES_'.$shortcode;
133 133
         // does the shortcode exist ?
134
-        if (! is_readable($shortcode_path . '/' . $shortcode_class . $shortcode_ext)) {
134
+        if ( ! is_readable($shortcode_path.'/'.$shortcode_class.$shortcode_ext)) {
135 135
             $msg = sprintf(
136 136
                 esc_html__(
137 137
                     'The requested %1$s shortcode file could not be found or is not readable due to file permissions. It should be in %2$s',
138 138
                     'event_espresso'
139 139
                 ),
140 140
                 $shortcode_class,
141
-                $shortcode_path . '/' . $shortcode_class . $shortcode_ext
141
+                $shortcode_path.'/'.$shortcode_class.$shortcode_ext
142 142
             );
143
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
143
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
144 144
             return false;
145 145
         }
146 146
         // load the shortcode class file
147
-        require_once($shortcode_path . $shortcode_class . $shortcode_ext);
147
+        require_once($shortcode_path.$shortcode_class.$shortcode_ext);
148 148
         // verify that class exists
149
-        if (! class_exists($shortcode_class)) {
149
+        if ( ! class_exists($shortcode_class)) {
150 150
             $msg = sprintf(
151 151
                 esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'),
152 152
                 $shortcode_class
153 153
             );
154
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
154
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
155 155
             return false;
156 156
         }
157 157
         $shortcode = strtoupper($shortcode);
158 158
         // add to array of registered shortcodes
159
-        $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
159
+        $this->registry->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext;
160 160
         return true;
161 161
     }
162 162
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         // cycle thru shortcode folders
174 174
         foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) {
175 175
             // add class prefix
176
-            $shortcode_class = 'EES_' . $shortcode;
176
+            $shortcode_class = 'EES_'.$shortcode;
177 177
             // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
178 178
             // which set hooks ?
179 179
             if (is_admin()) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 $shortcode_tag = strtoupper($shortcode);
190 190
                 // but first check if the shortcode has already
191 191
                 // been added before assigning 'fallback_shortcode_processor'
192
-                if (! shortcode_exists($shortcode_tag)) {
192
+                if ( ! shortcode_exists($shortcode_tag)) {
193 193
                     // NOTE: this shortcode declaration will get overridden if the shortcode
194 194
                     // is successfully detected in the post content in initializeShortcode()
195 195
                     add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
      */
396 396
     public static function addShortcodeClassPrefix($class_name)
397 397
     {
398
-        return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name;
398
+        return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_'.$class_name;
399 399
     }
400 400
 
401 401
 
Please login to merge, or discard this patch.
Indentation   +416 added lines, -416 removed lines patch added patch discarded remove patch
@@ -23,421 +23,421 @@
 block discarded – undo
23 23
  */
24 24
 class LegacyShortcodesManager
25 25
 {
26
-    /**
27
-     * @type CurrentPage
28
-     */
29
-    protected $current_page;
30
-
31
-    /**
32
-     * @var EE_Registry $registry
33
-     */
34
-    private $registry;
35
-
36
-
37
-    /**
38
-     * LegacyShortcodesManager constructor.
39
-     *
40
-     * @param EE_Registry $registry
41
-     * @param CurrentPage $current_page
42
-     */
43
-    public function __construct(EE_Registry $registry, CurrentPage $current_page)
44
-    {
45
-        $this->registry = $registry;
46
-        $this->current_page = $current_page;
47
-    }
48
-
49
-
50
-    /**
51
-     * @return EE_Registry
52
-     */
53
-    public function registry()
54
-    {
55
-        return $this->registry;
56
-    }
57
-
58
-
59
-    /**
60
-     * registerShortcodes
61
-     *
62
-     * @return void
63
-     */
64
-    public function registerShortcodes()
65
-    {
66
-        $this->registry->shortcodes = $this->getShortcodes();
67
-    }
68
-
69
-
70
-    /**
71
-     * getShortcodes
72
-     *
73
-     * @return array
74
-     */
75
-    public function getShortcodes()
76
-    {
77
-        // previously this method would glob the shortcodes directory
78
-        // then filter that list of shortcodes to register,
79
-        // but now we are going to just supply an empty array.
80
-        // this allows any shortcodes that have not yet been converted to the new system
81
-        // to still get loaded and processed, albeit using the same legacy logic as before
82
-        $shortcodes_to_register = apply_filters(
83
-            'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
84
-            array()
85
-        );
86
-        if (! empty($shortcodes_to_register)) {
87
-            // cycle thru shortcode folders
88
-            foreach ($shortcodes_to_register as $shortcode_path) {
89
-                // add to list of installed shortcode modules
90
-                $this->registerShortcode($shortcode_path);
91
-            }
92
-        }
93
-        // filter list of installed modules
94
-        return apply_filters(
95
-            'FHEE__EE_Config___register_shortcodes__installed_shortcodes',
96
-            ! empty($this->registry->shortcodes)
97
-                ? $this->registry->shortcodes
98
-                : array()
99
-        );
100
-    }
101
-
102
-
103
-    /**
104
-     * register_shortcode - makes core aware of this shortcode
105
-     *
106
-     * @param    string $shortcode_path - full path up to and including shortcode folder
107
-     * @return    bool
108
-     */
109
-    public function registerShortcode($shortcode_path = null)
110
-    {
111
-        do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
112
-        $shortcode_ext = '.shortcode.php';
113
-        // make all separators match
114
-        $shortcode_path = str_replace(array('\\', '/'), '/', $shortcode_path);
115
-        // does the file path INCLUDE the actual file name as part of the path ?
116
-        if (strpos($shortcode_path, $shortcode_ext) !== false) {
117
-            // grab shortcode file name from directory name and break apart at dots
118
-            $shortcode_file = explode('.', basename($shortcode_path));
119
-            // take first segment from file name pieces and remove class prefix if it exists
120
-            $shortcode = strpos($shortcode_file[0], 'EES_') === 0
121
-                ? substr($shortcode_file[0], 4)
122
-                : $shortcode_file[0];
123
-            // sanitize shortcode directory name
124
-            $shortcode = sanitize_key($shortcode);
125
-            // now we need to rebuild the shortcode path
126
-            $shortcode_path = explode('/', $shortcode_path);
127
-            // remove last segment
128
-            array_pop($shortcode_path);
129
-            // glue it back together
130
-            $shortcode_path = implode('/', $shortcode_path) . '/';
131
-        } else {
132
-            // we need to generate the filename based off of the folder name
133
-            // grab and sanitize shortcode directory name
134
-            $shortcode = sanitize_key(basename($shortcode_path));
135
-            $shortcode_path = rtrim($shortcode_path, '/') . '/';
136
-        }
137
-        // create classname from shortcode directory or file name
138
-        $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
139
-        // add class prefix
140
-        $shortcode_class = 'EES_' . $shortcode;
141
-        // does the shortcode exist ?
142
-        if (! is_readable($shortcode_path . '/' . $shortcode_class . $shortcode_ext)) {
143
-            $msg = sprintf(
144
-                esc_html__(
145
-                    'The requested %1$s shortcode file could not be found or is not readable due to file permissions. It should be in %2$s',
146
-                    'event_espresso'
147
-                ),
148
-                $shortcode_class,
149
-                $shortcode_path . '/' . $shortcode_class . $shortcode_ext
150
-            );
151
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
152
-            return false;
153
-        }
154
-        // load the shortcode class file
155
-        require_once($shortcode_path . $shortcode_class . $shortcode_ext);
156
-        // verify that class exists
157
-        if (! class_exists($shortcode_class)) {
158
-            $msg = sprintf(
159
-                esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'),
160
-                $shortcode_class
161
-            );
162
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
163
-            return false;
164
-        }
165
-        $shortcode = strtoupper($shortcode);
166
-        // add to array of registered shortcodes
167
-        $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
168
-        return true;
169
-    }
170
-
171
-
172
-    /**
173
-     *    _initialize_shortcodes
174
-     *    allow shortcodes to set hooks for the rest of the system
175
-     *
176
-     * @return void
177
-     */
178
-    public function addShortcodes()
179
-    {
180
-        // cycle thru shortcode folders
181
-        foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) {
182
-            // add class prefix
183
-            $shortcode_class = 'EES_' . $shortcode;
184
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
185
-            // which set hooks ?
186
-            if (is_admin()) {
187
-                // fire immediately
188
-                call_user_func(array($shortcode_class, 'set_hooks_admin'));
189
-            } else {
190
-                // delay until other systems are online
191
-                add_action(
192
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
193
-                    array($shortcode_class, 'set_hooks')
194
-                );
195
-                // convert classname to UPPERCASE and create WP shortcode.
196
-                $shortcode_tag = strtoupper($shortcode);
197
-                // but first check if the shortcode has already
198
-                // been added before assigning 'fallback_shortcode_processor'
199
-                if (! shortcode_exists($shortcode_tag)) {
200
-                    // NOTE: this shortcode declaration will get overridden if the shortcode
201
-                    // is successfully detected in the post content in initializeShortcode()
202
-                    add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
203
-                }
204
-            }
205
-        }
206
-    }
207
-
208
-
209
-    /**
210
-     * callback for the WP "get_header" hook point
211
-     * checks posts for EE shortcodes, and initializes them,
212
-     * then toggles filter switch that loads core default assets
213
-     *
214
-     * @param WP_Query $wp_query
215
-     * @return void
216
-     * @throws ReflectionException
217
-     */
218
-    public function initializeShortcodes(WP_Query $wp_query)
219
-    {
220
-        if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) {
221
-            return;
222
-        }
223
-        global $wp;
224
-        /** @var EE_Front_controller $Front_Controller */
225
-        $Front_Controller = LoaderFactory::getLoader()->getShared('EE_Front_Controller');
226
-        do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller);
227
-        $this->current_page->parseQueryVars();
228
-        // grab post_name from request
229
-        $current_post = apply_filters(
230
-            'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name',
231
-            $this->current_page->postName()
232
-        );
233
-        $show_on_front = get_option('show_on_front');
234
-        // if it's not set, then check if frontpage is blog
235
-        if (empty($current_post)) {
236
-            // yup.. this is the posts page, prepare to load all shortcode modules
237
-            $current_post = 'posts';
238
-            // unless..
239
-            if ($show_on_front === 'page') {
240
-                // some other page is set as the homepage
241
-                $page_on_front = get_option('page_on_front');
242
-                if ($page_on_front) {
243
-                    // k now we need to find the post_name for this page
244
-                    global $wpdb;
245
-                    $page_on_front = $wpdb->get_var(
246
-                        $wpdb->prepare(
247
-                            "SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d",
248
-                            $page_on_front
249
-                        )
250
-                    );
251
-                    // set the current post slug to what it actually is
252
-                    $current_post = $page_on_front ?: $current_post;
253
-                }
254
-            }
255
-        }
256
-        // in case $current_post is hierarchical like: /parent-page/current-page
257
-        $current_post = basename($current_post);
258
-        if (
26
+	/**
27
+	 * @type CurrentPage
28
+	 */
29
+	protected $current_page;
30
+
31
+	/**
32
+	 * @var EE_Registry $registry
33
+	 */
34
+	private $registry;
35
+
36
+
37
+	/**
38
+	 * LegacyShortcodesManager constructor.
39
+	 *
40
+	 * @param EE_Registry $registry
41
+	 * @param CurrentPage $current_page
42
+	 */
43
+	public function __construct(EE_Registry $registry, CurrentPage $current_page)
44
+	{
45
+		$this->registry = $registry;
46
+		$this->current_page = $current_page;
47
+	}
48
+
49
+
50
+	/**
51
+	 * @return EE_Registry
52
+	 */
53
+	public function registry()
54
+	{
55
+		return $this->registry;
56
+	}
57
+
58
+
59
+	/**
60
+	 * registerShortcodes
61
+	 *
62
+	 * @return void
63
+	 */
64
+	public function registerShortcodes()
65
+	{
66
+		$this->registry->shortcodes = $this->getShortcodes();
67
+	}
68
+
69
+
70
+	/**
71
+	 * getShortcodes
72
+	 *
73
+	 * @return array
74
+	 */
75
+	public function getShortcodes()
76
+	{
77
+		// previously this method would glob the shortcodes directory
78
+		// then filter that list of shortcodes to register,
79
+		// but now we are going to just supply an empty array.
80
+		// this allows any shortcodes that have not yet been converted to the new system
81
+		// to still get loaded and processed, albeit using the same legacy logic as before
82
+		$shortcodes_to_register = apply_filters(
83
+			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
84
+			array()
85
+		);
86
+		if (! empty($shortcodes_to_register)) {
87
+			// cycle thru shortcode folders
88
+			foreach ($shortcodes_to_register as $shortcode_path) {
89
+				// add to list of installed shortcode modules
90
+				$this->registerShortcode($shortcode_path);
91
+			}
92
+		}
93
+		// filter list of installed modules
94
+		return apply_filters(
95
+			'FHEE__EE_Config___register_shortcodes__installed_shortcodes',
96
+			! empty($this->registry->shortcodes)
97
+				? $this->registry->shortcodes
98
+				: array()
99
+		);
100
+	}
101
+
102
+
103
+	/**
104
+	 * register_shortcode - makes core aware of this shortcode
105
+	 *
106
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
107
+	 * @return    bool
108
+	 */
109
+	public function registerShortcode($shortcode_path = null)
110
+	{
111
+		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
112
+		$shortcode_ext = '.shortcode.php';
113
+		// make all separators match
114
+		$shortcode_path = str_replace(array('\\', '/'), '/', $shortcode_path);
115
+		// does the file path INCLUDE the actual file name as part of the path ?
116
+		if (strpos($shortcode_path, $shortcode_ext) !== false) {
117
+			// grab shortcode file name from directory name and break apart at dots
118
+			$shortcode_file = explode('.', basename($shortcode_path));
119
+			// take first segment from file name pieces and remove class prefix if it exists
120
+			$shortcode = strpos($shortcode_file[0], 'EES_') === 0
121
+				? substr($shortcode_file[0], 4)
122
+				: $shortcode_file[0];
123
+			// sanitize shortcode directory name
124
+			$shortcode = sanitize_key($shortcode);
125
+			// now we need to rebuild the shortcode path
126
+			$shortcode_path = explode('/', $shortcode_path);
127
+			// remove last segment
128
+			array_pop($shortcode_path);
129
+			// glue it back together
130
+			$shortcode_path = implode('/', $shortcode_path) . '/';
131
+		} else {
132
+			// we need to generate the filename based off of the folder name
133
+			// grab and sanitize shortcode directory name
134
+			$shortcode = sanitize_key(basename($shortcode_path));
135
+			$shortcode_path = rtrim($shortcode_path, '/') . '/';
136
+		}
137
+		// create classname from shortcode directory or file name
138
+		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
139
+		// add class prefix
140
+		$shortcode_class = 'EES_' . $shortcode;
141
+		// does the shortcode exist ?
142
+		if (! is_readable($shortcode_path . '/' . $shortcode_class . $shortcode_ext)) {
143
+			$msg = sprintf(
144
+				esc_html__(
145
+					'The requested %1$s shortcode file could not be found or is not readable due to file permissions. It should be in %2$s',
146
+					'event_espresso'
147
+				),
148
+				$shortcode_class,
149
+				$shortcode_path . '/' . $shortcode_class . $shortcode_ext
150
+			);
151
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
152
+			return false;
153
+		}
154
+		// load the shortcode class file
155
+		require_once($shortcode_path . $shortcode_class . $shortcode_ext);
156
+		// verify that class exists
157
+		if (! class_exists($shortcode_class)) {
158
+			$msg = sprintf(
159
+				esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'),
160
+				$shortcode_class
161
+			);
162
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
163
+			return false;
164
+		}
165
+		$shortcode = strtoupper($shortcode);
166
+		// add to array of registered shortcodes
167
+		$this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
168
+		return true;
169
+	}
170
+
171
+
172
+	/**
173
+	 *    _initialize_shortcodes
174
+	 *    allow shortcodes to set hooks for the rest of the system
175
+	 *
176
+	 * @return void
177
+	 */
178
+	public function addShortcodes()
179
+	{
180
+		// cycle thru shortcode folders
181
+		foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) {
182
+			// add class prefix
183
+			$shortcode_class = 'EES_' . $shortcode;
184
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
185
+			// which set hooks ?
186
+			if (is_admin()) {
187
+				// fire immediately
188
+				call_user_func(array($shortcode_class, 'set_hooks_admin'));
189
+			} else {
190
+				// delay until other systems are online
191
+				add_action(
192
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
193
+					array($shortcode_class, 'set_hooks')
194
+				);
195
+				// convert classname to UPPERCASE and create WP shortcode.
196
+				$shortcode_tag = strtoupper($shortcode);
197
+				// but first check if the shortcode has already
198
+				// been added before assigning 'fallback_shortcode_processor'
199
+				if (! shortcode_exists($shortcode_tag)) {
200
+					// NOTE: this shortcode declaration will get overridden if the shortcode
201
+					// is successfully detected in the post content in initializeShortcode()
202
+					add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
203
+				}
204
+			}
205
+		}
206
+	}
207
+
208
+
209
+	/**
210
+	 * callback for the WP "get_header" hook point
211
+	 * checks posts for EE shortcodes, and initializes them,
212
+	 * then toggles filter switch that loads core default assets
213
+	 *
214
+	 * @param WP_Query $wp_query
215
+	 * @return void
216
+	 * @throws ReflectionException
217
+	 */
218
+	public function initializeShortcodes(WP_Query $wp_query)
219
+	{
220
+		if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) {
221
+			return;
222
+		}
223
+		global $wp;
224
+		/** @var EE_Front_controller $Front_Controller */
225
+		$Front_Controller = LoaderFactory::getLoader()->getShared('EE_Front_Controller');
226
+		do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller);
227
+		$this->current_page->parseQueryVars();
228
+		// grab post_name from request
229
+		$current_post = apply_filters(
230
+			'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name',
231
+			$this->current_page->postName()
232
+		);
233
+		$show_on_front = get_option('show_on_front');
234
+		// if it's not set, then check if frontpage is blog
235
+		if (empty($current_post)) {
236
+			// yup.. this is the posts page, prepare to load all shortcode modules
237
+			$current_post = 'posts';
238
+			// unless..
239
+			if ($show_on_front === 'page') {
240
+				// some other page is set as the homepage
241
+				$page_on_front = get_option('page_on_front');
242
+				if ($page_on_front) {
243
+					// k now we need to find the post_name for this page
244
+					global $wpdb;
245
+					$page_on_front = $wpdb->get_var(
246
+						$wpdb->prepare(
247
+							"SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d",
248
+							$page_on_front
249
+						)
250
+					);
251
+					// set the current post slug to what it actually is
252
+					$current_post = $page_on_front ?: $current_post;
253
+				}
254
+			}
255
+		}
256
+		// in case $current_post is hierarchical like: /parent-page/current-page
257
+		$current_post = basename($current_post);
258
+		if (
259 259
 // is current page/post the "blog" page ?
260
-            $current_post === EE_Config::get_page_for_posts()
261
-            // or are we on a category page?
262
-            || (
263
-                is_array(term_exists($current_post, 'category'))
264
-                || array_key_exists('category_name', $wp->query_vars)
265
-            )
266
-        ) {
267
-            // initialize all legacy shortcodes
268
-            $load_assets = $this->parseContentForShortcodes('', true);
269
-        } else {
270
-            global $wpdb;
271
-            $post_content = $wpdb->get_var(
272
-                $wpdb->prepare(
273
-                    "SELECT post_content from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s",
274
-                    $current_post
275
-                )
276
-            );
277
-            $load_assets = $this->parseContentForShortcodes($post_content);
278
-        }
279
-        if ($load_assets) {
280
-            $this->current_page->setEspressoPage(true);
281
-            add_filter('FHEE_load_css', '__return_true');
282
-            add_filter('FHEE_load_js', '__return_true');
283
-        }
284
-        do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller);
285
-    }
286
-
287
-
288
-    /**
289
-     * checks supplied content against list of legacy shortcodes,
290
-     * then initializes any found shortcodes, and returns true.
291
-     * returns false if no shortcodes found.
292
-     *
293
-     * @param string $content
294
-     * @param bool   $load_all if true, then ALL active legacy shortcodes will be initialized
295
-     * @return bool
296
-     * @throws ReflectionException
297
-     */
298
-    public function parseContentForShortcodes($content = '', $load_all = false)
299
-    {
300
-        $has_shortcode = false;
301
-        foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) {
302
-            if ($load_all || has_shortcode($content, $shortcode_class)) {
303
-                // load up the shortcode
304
-                $this->initializeShortcode($shortcode_class);
305
-                $has_shortcode = true;
306
-            }
307
-        }
308
-        return $has_shortcode;
309
-    }
310
-
311
-
312
-    /**
313
-     * given a shortcode name, will instantiate the shortcode and call it's run() method
314
-     *
315
-     * @param string $shortcode_class
316
-     * @param WP     $wp
317
-     * @throws ReflectionException
318
-     */
319
-    public function initializeShortcode($shortcode_class = '', WP $wp = null)
320
-    {
321
-        // don't do anything if shortcode is already initialized
322
-        if (
323
-            empty($this->registry->shortcodes->{$shortcode_class})
324
-            || ! is_string($this->registry->shortcodes->{$shortcode_class})
325
-        ) {
326
-            return;
327
-        }
328
-        // let's pause to reflect on this...
329
-        $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class));
330
-        // ensure that class is actually a shortcode
331
-        if (
332
-            defined('WP_DEBUG')
333
-            && WP_DEBUG === true
334
-            && ! $sc_reflector->isSubclassOf('EES_Shortcode')
335
-        ) {
336
-            EE_Error::add_error(
337
-                sprintf(
338
-                    esc_html__(
339
-                        'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.',
340
-                        'event_espresso'
341
-                    ),
342
-                    $shortcode_class
343
-                ),
344
-                __FILE__,
345
-                __FUNCTION__,
346
-                __LINE__
347
-            );
348
-            add_filter('FHEE_run_EE_the_content', '__return_true');
349
-            return;
350
-        }
351
-        global $wp;
352
-        // and pass the request object to the run method
353
-        $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance();
354
-        // fire the shortcode class's run method, so that it can activate resources
355
-        $this->registry->shortcodes->{$shortcode_class}->run($wp);
356
-    }
357
-
358
-
359
-    /**
360
-     * get classname, remove EES_prefix, and convert to UPPERCASE
361
-     *
362
-     * @param string $class_name
363
-     * @return string
364
-     */
365
-    public static function generateShortcodeTagFromClassName($class_name)
366
-    {
367
-        return strtoupper(str_replace('EES_', '', $class_name));
368
-    }
369
-
370
-
371
-    /**
372
-     * add EES_prefix and Capitalize words
373
-     *
374
-     * @param string $tag
375
-     * @return string
376
-     */
377
-    public static function generateShortcodeClassNameFromTag($tag)
378
-    {
379
-        // order of operation runs from inside to out
380
-        // 5) maybe add prefix
381
-        return LegacyShortcodesManager::addShortcodeClassPrefix(
382
-            // 4) find spaces, replace with underscores
383
-            str_replace(
384
-                ' ',
385
-                '_',
386
-                // 3) capitalize first letter of each word
387
-                ucwords(
388
-                    // 2) also change to lowercase so ucwords() will work
389
-                    strtolower(
390
-                        // 1) find underscores, replace with spaces so ucwords() will work
391
-                        str_replace(
392
-                            '_',
393
-                            ' ',
394
-                            $tag
395
-                        )
396
-                    )
397
-                )
398
-            )
399
-        );
400
-    }
401
-
402
-
403
-    /**
404
-     * maybe add EES_prefix
405
-     *
406
-     * @param string $class_name
407
-     * @return string
408
-     */
409
-    public static function addShortcodeClassPrefix($class_name)
410
-    {
411
-        return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name;
412
-    }
413
-
414
-
415
-    /**
416
-     * @return array
417
-     */
418
-    public function getEspressoShortcodeTags()
419
-    {
420
-        static $shortcode_tags = array();
421
-        if (empty($shortcode_tags)) {
422
-            $shortcode_tags = array_keys((array) $this->registry->shortcodes);
423
-        }
424
-        return $shortcode_tags;
425
-    }
426
-
427
-
428
-    /**
429
-     * @param string $content
430
-     * @return string
431
-     * @throws ReflectionException
432
-     */
433
-    public function doShortcode($content)
434
-    {
435
-        foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) {
436
-            if (strpos($content, $shortcode_tag) !== false) {
437
-                $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag);
438
-                $this->initializeShortcode($shortcode_class);
439
-            }
440
-        }
441
-        return do_shortcode($content);
442
-    }
260
+			$current_post === EE_Config::get_page_for_posts()
261
+			// or are we on a category page?
262
+			|| (
263
+				is_array(term_exists($current_post, 'category'))
264
+				|| array_key_exists('category_name', $wp->query_vars)
265
+			)
266
+		) {
267
+			// initialize all legacy shortcodes
268
+			$load_assets = $this->parseContentForShortcodes('', true);
269
+		} else {
270
+			global $wpdb;
271
+			$post_content = $wpdb->get_var(
272
+				$wpdb->prepare(
273
+					"SELECT post_content from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s",
274
+					$current_post
275
+				)
276
+			);
277
+			$load_assets = $this->parseContentForShortcodes($post_content);
278
+		}
279
+		if ($load_assets) {
280
+			$this->current_page->setEspressoPage(true);
281
+			add_filter('FHEE_load_css', '__return_true');
282
+			add_filter('FHEE_load_js', '__return_true');
283
+		}
284
+		do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller);
285
+	}
286
+
287
+
288
+	/**
289
+	 * checks supplied content against list of legacy shortcodes,
290
+	 * then initializes any found shortcodes, and returns true.
291
+	 * returns false if no shortcodes found.
292
+	 *
293
+	 * @param string $content
294
+	 * @param bool   $load_all if true, then ALL active legacy shortcodes will be initialized
295
+	 * @return bool
296
+	 * @throws ReflectionException
297
+	 */
298
+	public function parseContentForShortcodes($content = '', $load_all = false)
299
+	{
300
+		$has_shortcode = false;
301
+		foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) {
302
+			if ($load_all || has_shortcode($content, $shortcode_class)) {
303
+				// load up the shortcode
304
+				$this->initializeShortcode($shortcode_class);
305
+				$has_shortcode = true;
306
+			}
307
+		}
308
+		return $has_shortcode;
309
+	}
310
+
311
+
312
+	/**
313
+	 * given a shortcode name, will instantiate the shortcode and call it's run() method
314
+	 *
315
+	 * @param string $shortcode_class
316
+	 * @param WP     $wp
317
+	 * @throws ReflectionException
318
+	 */
319
+	public function initializeShortcode($shortcode_class = '', WP $wp = null)
320
+	{
321
+		// don't do anything if shortcode is already initialized
322
+		if (
323
+			empty($this->registry->shortcodes->{$shortcode_class})
324
+			|| ! is_string($this->registry->shortcodes->{$shortcode_class})
325
+		) {
326
+			return;
327
+		}
328
+		// let's pause to reflect on this...
329
+		$sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class));
330
+		// ensure that class is actually a shortcode
331
+		if (
332
+			defined('WP_DEBUG')
333
+			&& WP_DEBUG === true
334
+			&& ! $sc_reflector->isSubclassOf('EES_Shortcode')
335
+		) {
336
+			EE_Error::add_error(
337
+				sprintf(
338
+					esc_html__(
339
+						'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.',
340
+						'event_espresso'
341
+					),
342
+					$shortcode_class
343
+				),
344
+				__FILE__,
345
+				__FUNCTION__,
346
+				__LINE__
347
+			);
348
+			add_filter('FHEE_run_EE_the_content', '__return_true');
349
+			return;
350
+		}
351
+		global $wp;
352
+		// and pass the request object to the run method
353
+		$this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance();
354
+		// fire the shortcode class's run method, so that it can activate resources
355
+		$this->registry->shortcodes->{$shortcode_class}->run($wp);
356
+	}
357
+
358
+
359
+	/**
360
+	 * get classname, remove EES_prefix, and convert to UPPERCASE
361
+	 *
362
+	 * @param string $class_name
363
+	 * @return string
364
+	 */
365
+	public static function generateShortcodeTagFromClassName($class_name)
366
+	{
367
+		return strtoupper(str_replace('EES_', '', $class_name));
368
+	}
369
+
370
+
371
+	/**
372
+	 * add EES_prefix and Capitalize words
373
+	 *
374
+	 * @param string $tag
375
+	 * @return string
376
+	 */
377
+	public static function generateShortcodeClassNameFromTag($tag)
378
+	{
379
+		// order of operation runs from inside to out
380
+		// 5) maybe add prefix
381
+		return LegacyShortcodesManager::addShortcodeClassPrefix(
382
+			// 4) find spaces, replace with underscores
383
+			str_replace(
384
+				' ',
385
+				'_',
386
+				// 3) capitalize first letter of each word
387
+				ucwords(
388
+					// 2) also change to lowercase so ucwords() will work
389
+					strtolower(
390
+						// 1) find underscores, replace with spaces so ucwords() will work
391
+						str_replace(
392
+							'_',
393
+							' ',
394
+							$tag
395
+						)
396
+					)
397
+				)
398
+			)
399
+		);
400
+	}
401
+
402
+
403
+	/**
404
+	 * maybe add EES_prefix
405
+	 *
406
+	 * @param string $class_name
407
+	 * @return string
408
+	 */
409
+	public static function addShortcodeClassPrefix($class_name)
410
+	{
411
+		return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name;
412
+	}
413
+
414
+
415
+	/**
416
+	 * @return array
417
+	 */
418
+	public function getEspressoShortcodeTags()
419
+	{
420
+		static $shortcode_tags = array();
421
+		if (empty($shortcode_tags)) {
422
+			$shortcode_tags = array_keys((array) $this->registry->shortcodes);
423
+		}
424
+		return $shortcode_tags;
425
+	}
426
+
427
+
428
+	/**
429
+	 * @param string $content
430
+	 * @return string
431
+	 * @throws ReflectionException
432
+	 */
433
+	public function doShortcode($content)
434
+	{
435
+		foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) {
436
+			if (strpos($content, $shortcode_tag) !== false) {
437
+				$shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag);
438
+				$this->initializeShortcode($shortcode_class);
439
+			}
440
+		}
441
+		return do_shortcode($content);
442
+	}
443 443
 }
Please login to merge, or discard this patch.