Completed
Branch master (2f51c0)
by
unknown
19:47 queued 19:47
created
payment_methods/Paypal_Express/EE_PMT_Paypal_Express.pm.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -15,89 +15,89 @@
 block discarded – undo
15 15
 class EE_PMT_Paypal_Express extends EE_PMT_Base
16 16
 {
17 17
 
18
-    /**
19
-     * EE_PMT_Paypal_Express constructor.
20
-     */
21
-    public function __construct($pm_instance = null)
22
-    {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
24
-        $this->_gateway = new EEG_Paypal_Express();
18
+	/**
19
+	 * EE_PMT_Paypal_Express constructor.
20
+	 */
21
+	public function __construct($pm_instance = null)
22
+	{
23
+		require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
24
+		$this->_gateway = new EEG_Paypal_Express();
25 25
 
26
-        $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
-        $this->_template_path = $this->file_folder() . 'templates/';
28
-        $this->_default_description = esc_html__(
29
-            // @codingStandardsIgnoreStart
30
-            'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31
-            // @codingStandardsIgnoreEnd
32
-            'event_espresso'
33
-        );
34
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
26
+		$this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
+		$this->_template_path = $this->file_folder() . 'templates/';
28
+		$this->_default_description = esc_html__(
29
+			// @codingStandardsIgnoreStart
30
+			'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31
+			// @codingStandardsIgnoreEnd
32
+			'event_espresso'
33
+		);
34
+		$this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
35 35
 
36
-        parent::__construct($pm_instance);
37
-    }
36
+		parent::__construct($pm_instance);
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * Adds the help tab.
42
-     *
43
-     * @see EE_PMT_Base::help_tabs_config()
44
-     * @return array
45
-     */
46
-    public function help_tabs_config()
47
-    {
48
-        return array(
49
-            $this->get_help_tab_name() => array(
50
-                'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
51
-                'filename' => 'payment_methods_overview_paypal_express'
52
-            )
53
-        );
54
-    }
40
+	/**
41
+	 * Adds the help tab.
42
+	 *
43
+	 * @see EE_PMT_Base::help_tabs_config()
44
+	 * @return array
45
+	 */
46
+	public function help_tabs_config()
47
+	{
48
+		return array(
49
+			$this->get_help_tab_name() => array(
50
+				'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
51
+				'filename' => 'payment_methods_overview_paypal_express'
52
+			)
53
+		);
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * Gets the form for all the settings related to this payment method type.
59
-     *
60
-     * @return EE_Payment_Method_Form
61
-     */
62
-    public function generate_new_settings_form()
63
-    {
64
-        return new SettingsForm(array(), $this->get_help_tab_link());
65
-    }
57
+	/**
58
+	 * Gets the form for all the settings related to this payment method type.
59
+	 *
60
+	 * @return EE_Payment_Method_Form
61
+	 */
62
+	public function generate_new_settings_form()
63
+	{
64
+		return new SettingsForm(array(), $this->get_help_tab_link());
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * Creates a billing form for this payment method type.
70
-     *
71
-     * @param \EE_Transaction $transaction
72
-     * @return \EE_Billing_Info_Form
73
-     */
74
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
75
-    {
76
-        if ($this->_pm_instance->debug_mode()) {
77
-            $form = new EE_Billing_Info_Form(
78
-                $this->_pm_instance,
79
-                array(
80
-                    'name' => 'paypal_express_Info_Form',
81
-                    'subsections' => array(
82
-                        'paypal_express_debug_info' => new EE_Form_Section_Proper(
83
-                            array(
84
-                                'layout_strategy' => new EE_Template_Layout(
85
-                                    array(
86
-                                        'layout_template_file' => $this->_template_path
87
-                                                                    . 'paypal_express_debug_info.template.php',
88
-                                        'template_args'        => array(
89
-                                            'debug_mode' => $this->_pm_instance->debug_mode()
90
-                                        )
91
-                                    )
92
-                                )
93
-                            )
94
-                        )
95
-                    )
96
-                )
97
-            );
98
-            return $form;
99
-        }
68
+	/**
69
+	 * Creates a billing form for this payment method type.
70
+	 *
71
+	 * @param \EE_Transaction $transaction
72
+	 * @return \EE_Billing_Info_Form
73
+	 */
74
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
75
+	{
76
+		if ($this->_pm_instance->debug_mode()) {
77
+			$form = new EE_Billing_Info_Form(
78
+				$this->_pm_instance,
79
+				array(
80
+					'name' => 'paypal_express_Info_Form',
81
+					'subsections' => array(
82
+						'paypal_express_debug_info' => new EE_Form_Section_Proper(
83
+							array(
84
+								'layout_strategy' => new EE_Template_Layout(
85
+									array(
86
+										'layout_template_file' => $this->_template_path
87
+																	. 'paypal_express_debug_info.template.php',
88
+										'template_args'        => array(
89
+											'debug_mode' => $this->_pm_instance->debug_mode()
90
+										)
91
+									)
92
+								)
93
+							)
94
+						)
95
+					)
96
+				)
97
+			);
98
+			return $form;
99
+		}
100 100
 
101
-        return false;
102
-    }
101
+		return false;
102
+	}
103 103
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@
 block discarded – undo
20 20
      */
21 21
     public function __construct($pm_instance = null)
22 22
     {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
23
+        require_once($this->file_folder().'EEG_Paypal_Express.gateway.php');
24 24
         $this->_gateway = new EEG_Paypal_Express();
25 25
 
26 26
         $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
-        $this->_template_path = $this->file_folder() . 'templates/';
27
+        $this->_template_path = $this->file_folder().'templates/';
28 28
         $this->_default_description = esc_html__(
29 29
             // @codingStandardsIgnoreStart
30 30
             'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31 31
             // @codingStandardsIgnoreEnd
32 32
             'event_espresso'
33 33
         );
34
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
34
+        $this->_default_button_url = $this->file_url().'lib/paypal-express-checkout-logo-gold-160.png';
35 35
 
36 36
         parent::__construct($pm_instance);
37 37
     }
Please login to merge, or discard this patch.
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   +1432 added lines, -1432 removed lines patch added patch discarded remove patch
@@ -14,1436 +14,1436 @@
 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
-                'metaboxes'     => $this->_default_espresso_metaboxes,
218
-                'require_nonce' => false,
219
-                'qtips'         => array(
220
-                    'EE_Registration_Form_Tips',
221
-                ),
222
-            ),
223
-
224
-            'add_question' => array(
225
-                'nav'           => array(
226
-                    'label'      => esc_html__('Add Question', 'event_espresso'),
227
-                    'order'      => 5,
228
-                    'persistent' => false,
229
-                ),
230
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
231
-                'help_tabs'     => array(
232
-                    'registration_form_add_question_help_tab' => array(
233
-                        'title'    => esc_html__('Add Question', 'event_espresso'),
234
-                        'filename' => 'registration_form_add_question',
235
-                    ),
236
-                ),
237
-                'require_nonce' => false,
238
-            ),
239
-
240
-            'add_question_group' => array(
241
-                'nav'           => array(
242
-                    'label'      => esc_html__('Add Question Group', 'event_espresso'),
243
-                    'order'      => 5,
244
-                    'persistent' => false,
245
-                ),
246
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
247
-                'help_tabs'     => array(
248
-                    'registration_form_add_question_group_help_tab' => array(
249
-                        'title'    => esc_html__('Add Question Group', 'event_espresso'),
250
-                        'filename' => 'registration_form_add_question_group',
251
-                    ),
252
-                ),
253
-                'require_nonce' => false,
254
-            ),
255
-
256
-            'edit_question_group' => array(
257
-                'nav'           => array(
258
-                    'label'      => esc_html__('Edit Question Group', 'event_espresso'),
259
-                    'order'      => 5,
260
-                    'persistent' => false,
261
-                    'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(
262
-                        array('question_group_id' => $this->_req_data['question_group_id']),
263
-                        $this->_current_page_view_url
264
-                    ) : $this->_admin_base_url,
265
-                ),
266
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
267
-                'help_tabs'     => array(
268
-                    'registration_form_edit_question_group_help_tab' => array(
269
-                        'title'    => esc_html__('Edit Question Group', 'event_espresso'),
270
-                        'filename' => 'registration_form_edit_question_group',
271
-                    ),
272
-                ),
273
-                'require_nonce' => false,
274
-            ),
275
-
276
-            'view_reg_form_settings' => array(
277
-                'nav'           => array(
278
-                    'label' => esc_html__('Reg Form Settings', 'event_espresso'),
279
-                    'order' => 40,
280
-                ),
281
-                'labels'        => array(
282
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
283
-                ),
284
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
285
-                'help_tabs'     => array(
286
-                    'registration_form_reg_form_settings_help_tab' => array(
287
-                        'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
288
-                        'filename' => 'registration_form_reg_form_settings',
289
-                    ),
290
-                ),
291
-                'require_nonce' => false,
292
-            ),
293
-
294
-        );
295
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
296
-
297
-        // change the list table we're going to use so it's the NEW list table!
298
-        $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
299
-
300
-
301
-        // additional labels
302
-        $new_labels = array(
303
-            'add_question'          => esc_html__('Add New Question', 'event_espresso'),
304
-            'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
305
-            'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
306
-            'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
307
-            'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
308
-        );
309
-        $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
310
-    }
311
-
312
-
313
-    /**
314
-     * @return void
315
-     */
316
-    protected function _ajax_hooks()
317
-    {
318
-        add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
319
-    }
320
-
321
-
322
-    /**
323
-     * @return void
324
-     */
325
-    public function load_scripts_styles_question_groups()
326
-    {
327
-        wp_enqueue_script('espresso_ajax_table_sorting');
328
-    }
329
-
330
-
331
-    /**
332
-     * @return void
333
-     */
334
-    public function load_scripts_styles_add_question_group()
335
-    {
336
-        $this->load_scripts_styles_forms();
337
-        $this->load_sortable_question_script();
338
-    }
339
-
340
-
341
-    /**
342
-     * @return void
343
-     */
344
-    public function load_scripts_styles_edit_question_group()
345
-    {
346
-        $this->load_scripts_styles_forms();
347
-        $this->load_sortable_question_script();
348
-    }
349
-
350
-
351
-    /**
352
-     * registers and enqueues script for questions
353
-     *
354
-     * @return void
355
-     */
356
-    public function load_sortable_question_script()
357
-    {
358
-        wp_register_script(
359
-            'ee-question-sortable',
360
-            REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
361
-            array('jquery-ui-sortable'),
362
-            EVENT_ESPRESSO_VERSION,
363
-            true
364
-        );
365
-        wp_enqueue_script('ee-question-sortable');
366
-    }
367
-
368
-
369
-    /**
370
-     * @return void
371
-     */
372
-    protected function _set_list_table_views_default()
373
-    {
374
-        $this->_views = array(
375
-            'all' => array(
376
-                'slug'        => 'all',
377
-                'label'       => esc_html__('View All Questions', 'event_espresso'),
378
-                'count'       => 0,
379
-                'bulk_action' => array(
380
-                    'trash_questions' => esc_html__('Trash', 'event_espresso'),
381
-                ),
382
-            ),
383
-        );
384
-
385
-        if (
386
-            EE_Registry::instance()->CAP->current_user_can(
387
-                'ee_delete_questions',
388
-                'espresso_registration_form_trash_questions'
389
-            )
390
-        ) {
391
-            $this->_views['trash'] = array(
392
-                'slug'        => 'trash',
393
-                'label'       => esc_html__('Trash', 'event_espresso'),
394
-                'count'       => 0,
395
-                'bulk_action' => array(
396
-                    'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
397
-                    'restore_questions' => esc_html__('Restore', 'event_espresso'),
398
-                ),
399
-            );
400
-        }
401
-    }
402
-
403
-
404
-    /**
405
-     * @return void
406
-     */
407
-    protected function _set_list_table_views_question_groups()
408
-    {
409
-        $this->_views = array(
410
-            'all' => array(
411
-                'slug'        => 'all',
412
-                'label'       => esc_html__('All', 'event_espresso'),
413
-                'count'       => 0,
414
-                'bulk_action' => array(
415
-                    'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
416
-                ),
417
-            ),
418
-        );
419
-
420
-        if (
421
-            EE_Registry::instance()->CAP->current_user_can(
422
-                'ee_delete_question_groups',
423
-                'espresso_registration_form_trash_question_groups'
424
-            )
425
-        ) {
426
-            $this->_views['trash'] = array(
427
-                'slug'        => 'trash',
428
-                'label'       => esc_html__('Trash', 'event_espresso'),
429
-                'count'       => 0,
430
-                'bulk_action' => array(
431
-                    'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
432
-                    'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
433
-                ),
434
-            );
435
-        }
436
-    }
437
-
438
-
439
-    /**
440
-     * @return void
441
-     * @throws EE_Error
442
-     * @throws InvalidArgumentException
443
-     * @throws InvalidDataTypeException
444
-     * @throws InvalidInterfaceException
445
-     */
446
-    protected function _questions_overview_list_table()
447
-    {
448
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
449
-            'add_question',
450
-            'add_question',
451
-            array(),
452
-            'add-new-h2'
453
-        );
454
-        parent::_questions_overview_list_table();
455
-    }
456
-
457
-
458
-    /**
459
-     * @return void
460
-     * @throws DomainException
461
-     * @throws EE_Error
462
-     * @throws InvalidArgumentException
463
-     * @throws InvalidDataTypeException
464
-     * @throws InvalidInterfaceException
465
-     */
466
-    protected function _question_groups_overview_list_table()
467
-    {
468
-        $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
469
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
470
-            'add_question_group',
471
-            'add_question_group',
472
-            array(),
473
-            'add-new-h2'
474
-        );
475
-        $this->display_admin_list_table_page_with_sidebar();
476
-    }
477
-
478
-
479
-    /**
480
-     * @return void
481
-     * @throws EE_Error
482
-     * @throws InvalidArgumentException
483
-     * @throws InvalidDataTypeException
484
-     * @throws InvalidInterfaceException
485
-     */
486
-    protected function _delete_question()
487
-    {
488
-        $success = $this->_delete_items($this->_question_model);
489
-        $this->_redirect_after_action(
490
-            $success,
491
-            $this->_question_model->item_name($success),
492
-            'deleted',
493
-            array('action' => 'default', 'status' => 'all')
494
-        );
495
-    }
496
-
497
-
498
-    /**
499
-     * @return void
500
-     * @throws EE_Error
501
-     * @throws InvalidArgumentException
502
-     * @throws InvalidDataTypeException
503
-     * @throws InvalidInterfaceException
504
-     */
505
-    protected function _delete_questions()
506
-    {
507
-        $success = $this->_delete_items($this->_question_model);
508
-        $this->_redirect_after_action(
509
-            $success,
510
-            $this->_question_model->item_name($success),
511
-            'deleted permanently',
512
-            array('action' => 'default', 'status' => 'trash')
513
-        );
514
-    }
515
-
516
-
517
-    /**
518
-     * Performs the deletion of a single or multiple questions or question groups.
519
-     *
520
-     * @param EEM_Soft_Delete_Base $model
521
-     * @return int number of items deleted permanently
522
-     * @throws EE_Error
523
-     * @throws InvalidArgumentException
524
-     * @throws InvalidDataTypeException
525
-     * @throws InvalidInterfaceException
526
-     */
527
-    private function _delete_items(EEM_Soft_Delete_Base $model)
528
-    {
529
-        $success = 0;
530
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
531
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
532
-            // if array has more than one element than success message should be plural
533
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
534
-            // cycle thru bulk action checkboxes
535
-            while (list($ID, $value) = each($this->_req_data['checkbox'])) {
536
-                if (! $this->_delete_item($ID, $model)) {
537
-                    $success = 0;
538
-                }
539
-            }
540
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
541
-            $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
542
-        } elseif (! empty($this->_req_data['QST_ID'])) {
543
-            $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
544
-        } else {
545
-            EE_Error::add_error(
546
-                sprintf(
547
-                    esc_html__(
548
-                        "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.",
549
-                        "event_espresso"
550
-                    )
551
-                ),
552
-                __FILE__,
553
-                __FUNCTION__,
554
-                __LINE__
555
-            );
556
-        }
557
-        return $success;
558
-    }
559
-
560
-
561
-    /**
562
-     * Deletes the specified question (and its associated question options) or question group
563
-     *
564
-     * @param int                  $id
565
-     * @param EEM_Soft_Delete_Base $model
566
-     * @return boolean
567
-     * @throws EE_Error
568
-     * @throws InvalidArgumentException
569
-     * @throws InvalidDataTypeException
570
-     * @throws InvalidInterfaceException
571
-     */
572
-    protected function _delete_item($id, $model)
573
-    {
574
-        if ($model instanceof EEM_Question) {
575
-            EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
576
-        }
577
-        return $model->delete_permanently_by_ID(absint($id));
578
-    }
579
-
580
-
581
-    /******************************    QUESTION GROUPS    ******************************/
582
-
583
-
584
-    /**
585
-     * @param string $type
586
-     * @return void
587
-     * @throws DomainException
588
-     * @throws EE_Error
589
-     * @throws InvalidArgumentException
590
-     * @throws InvalidDataTypeException
591
-     * @throws InvalidInterfaceException
592
-     */
593
-    protected function _edit_question_group($type = 'add')
594
-    {
595
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
596
-        $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID'])
597
-            ? absint($this->_req_data['QSG_ID'])
598
-            : false;
599
-
600
-        switch ($this->_req_action) {
601
-            case 'add_question_group':
602
-                $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
603
-                break;
604
-            case 'edit_question_group':
605
-                $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
606
-                break;
607
-            default:
608
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
609
-        }
610
-        // add ID to title if editing
611
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
612
-        if ($ID) {
613
-            /** @var EE_Question_Group $questionGroup */
614
-            $questionGroup = $this->_question_group_model->get_one_by_ID($ID);
615
-            $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
616
-            $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
617
-        } else {
618
-            /** @var EE_Question_Group $questionGroup */
619
-            $questionGroup = EEM_Question_Group::instance()->create_default_object();
620
-            $questionGroup->set_order_to_latest();
621
-            $this->_set_add_edit_form_tags('insert_question_group');
622
-        }
623
-        $this->_template_args['values'] = $this->_yes_no_values;
624
-        $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
625
-        $this->_template_args['QSG_ID'] = $ID ? $ID : true;
626
-        $this->_template_args['question_group'] = $questionGroup;
627
-
628
-        $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
629
-        $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
630
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
631
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
632
-            $this->_template_args,
633
-            true
634
-        );
635
-
636
-        // the details template wrapper
637
-        $this->display_admin_page_with_sidebar();
638
-    }
639
-
640
-
641
-    /**
642
-     * @return void
643
-     * @throws EE_Error
644
-     * @throws InvalidArgumentException
645
-     * @throws InvalidDataTypeException
646
-     * @throws InvalidInterfaceException
647
-     */
648
-    protected function _delete_question_groups()
649
-    {
650
-        $success = $this->_delete_items($this->_question_group_model);
651
-        $this->_redirect_after_action(
652
-            $success,
653
-            $this->_question_group_model->item_name($success),
654
-            'deleted permanently',
655
-            array('action' => 'question_groups', 'status' => 'trash')
656
-        );
657
-    }
658
-
659
-
660
-    /**
661
-     * @param bool $new_question_group
662
-     * @throws EE_Error
663
-     * @throws InvalidArgumentException
664
-     * @throws InvalidDataTypeException
665
-     * @throws InvalidInterfaceException
666
-     */
667
-    protected function _insert_or_update_question_group($new_question_group = true)
668
-    {
669
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
670
-        $set_column_values = $this->_set_column_values_for($this->_question_group_model);
671
-        if ($new_question_group) {
672
-            // make sure identifier is unique
673
-            $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : '';
674
-            $identifier_exists = ! empty($identifier_value)
675
-                ? $this->_question_group_model->count([['QSG_identifier' => $set_column_values['QSG_identifier']]]) > 0
676
-                : false;
677
-            if ($identifier_exists) {
678
-                $set_column_values['QSG_identifier'] .= uniqid('id', true);
679
-            }
680
-            $QSG_ID = $this->_question_group_model->insert($set_column_values);
681
-            $success = $QSG_ID ? 1 : 0;
682
-            if ($success === 0) {
683
-                EE_Error::add_error(
684
-                    esc_html__('Something went wrong saving the question group.', 'event_espresso'),
685
-                    __FILE__,
686
-                    __FUNCTION__,
687
-                    __LINE__
688
-                );
689
-                $this->_redirect_after_action(
690
-                    false,
691
-                    '',
692
-                    '',
693
-                    array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
694
-                    true
695
-                );
696
-            }
697
-        } else {
698
-            $QSG_ID = absint($this->_req_data['QSG_ID']);
699
-            unset($set_column_values['QSG_ID']);
700
-            $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
701
-        }
702
-
703
-        $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(
704
-            EEM_Attendee::system_question_phone
705
-        );
706
-        // update the existing related questions
707
-        // BUT FIRST...  delete the phone question from the Question_Group_Question
708
-        // if it is being added to this question group (therefore removed from the existing group)
709
-        if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
710
-            // delete where QST ID = system phone question ID and Question Group ID is NOT this group
711
-            EEM_Question_Group_Question::instance()->delete(
712
-                array(
713
-                    array(
714
-                        'QST_ID' => $phone_question_id,
715
-                        'QSG_ID' => array('!=', $QSG_ID),
716
-                    ),
717
-                )
718
-            );
719
-        }
720
-        /** @type EE_Question_Group $question_group */
721
-        $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
722
-        $questions = $question_group->questions();
723
-        // make sure system phone question is added to list of questions for this group
724
-        if (! isset($questions[ $phone_question_id ])) {
725
-            $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
726
-        }
727
-
728
-        foreach ($questions as $question_ID => $question) {
729
-            // first we always check for order.
730
-            if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
731
-                // update question order
732
-                $question_group->update_question_order(
733
-                    $question_ID,
734
-                    $this->_req_data['question_orders'][ $question_ID ]
735
-                );
736
-            }
737
-
738
-            // then we always check if adding or removing.
739
-            if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
740
-                $question_group->add_question($question_ID);
741
-            } else {
742
-                // not found, remove it (but only if not a system question for the personal group
743
-                // with the exception of lname system question - we allow removal of it)
744
-                if (
745
-                    in_array(
746
-                        $question->system_ID(),
747
-                        EEM_Question::instance()->required_system_questions_in_system_question_group(
748
-                            $question_group->system_group()
749
-                        )
750
-                    )
751
-                ) {
752
-                    continue;
753
-                } else {
754
-                    $question_group->remove_question($question_ID);
755
-                }
756
-            }
757
-        }
758
-        // save new related questions
759
-        if (isset($this->_req_data['questions'])) {
760
-            foreach ($this->_req_data['questions'] as $QST_ID) {
761
-                $question_group->add_question($QST_ID);
762
-                if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
763
-                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
764
-                }
765
-            }
766
-        }
767
-
768
-        if ($success !== false) {
769
-            $msg = $new_question_group
770
-                ? sprintf(
771
-                    esc_html__('The %s has been created', 'event_espresso'),
772
-                    $this->_question_group_model->item_name()
773
-                )
774
-                : sprintf(
775
-                    esc_html__(
776
-                        'The %s has been updated',
777
-                        'event_espresso'
778
-                    ),
779
-                    $this->_question_group_model->item_name()
780
-                );
781
-            EE_Error::add_success($msg);
782
-        }
783
-        $this->_redirect_after_action(
784
-            false,
785
-            '',
786
-            '',
787
-            array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
788
-            true
789
-        );
790
-    }
791
-
792
-
793
-    /**
794
-     * duplicates a question and all its question options and redirects to the new question.
795
-     *
796
-     * @return void
797
-     * @throws EE_Error
798
-     * @throws InvalidArgumentException
799
-     * @throws ReflectionException
800
-     * @throws InvalidDataTypeException
801
-     * @throws InvalidInterfaceException
802
-     */
803
-    public function _duplicate_question()
804
-    {
805
-        $question_ID = (int) $this->_req_data['QST_ID'];
806
-        $question = EEM_Question::instance()->get_one_by_ID($question_ID);
807
-        if ($question instanceof EE_Question) {
808
-            $new_question = $question->duplicate();
809
-            if ($new_question instanceof EE_Question) {
810
-                $this->_redirect_after_action(
811
-                    true,
812
-                    esc_html__('Question', 'event_espresso'),
813
-                    esc_html__('Duplicated', 'event_espresso'),
814
-                    array('action' => 'edit_question', 'QST_ID' => $new_question->ID()),
815
-                    true
816
-                );
817
-            } else {
818
-                global $wpdb;
819
-                EE_Error::add_error(
820
-                    sprintf(
821
-                        esc_html__(
822
-                            'Could not duplicate question with ID %1$d because: %2$s',
823
-                            'event_espresso'
824
-                        ),
825
-                        $question_ID,
826
-                        $wpdb->last_error
827
-                    ),
828
-                    __FILE__,
829
-                    __FUNCTION__,
830
-                    __LINE__
831
-                );
832
-                $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
833
-            }
834
-        } else {
835
-            EE_Error::add_error(
836
-                sprintf(
837
-                    esc_html__(
838
-                        'Could not duplicate question with ID %d because it didn\'t exist!',
839
-                        'event_espresso'
840
-                    ),
841
-                    $question_ID
842
-                ),
843
-                __FILE__,
844
-                __FUNCTION__,
845
-                __LINE__
846
-            );
847
-            $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
848
-        }
849
-    }
850
-
851
-
852
-    /**
853
-     * @param bool $trash
854
-     * @throws EE_Error
855
-     */
856
-    protected function _trash_or_restore_question_groups($trash = true)
857
-    {
858
-        $this->_trash_or_restore_items($this->_question_group_model, $trash);
859
-    }
860
-
861
-
862
-    /**
863
-     *_trash_question
864
-     *
865
-     * @return void
866
-     * @throws EE_Error
867
-     */
868
-    protected function _trash_question()
869
-    {
870
-        $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
871
-        $query_args = array('action' => 'default', 'status' => 'all');
872
-        $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
873
-    }
874
-
875
-
876
-    /**
877
-     * @param bool $trash
878
-     * @throws EE_Error
879
-     */
880
-    protected function _trash_or_restore_questions($trash = true)
881
-    {
882
-        $this->_trash_or_restore_items($this->_question_model, $trash);
883
-    }
884
-
885
-
886
-    /**
887
-     * Internally used to delete or restore items, using the request data. Meant to be
888
-     * flexible between question or question groups
889
-     *
890
-     * @param EEM_Soft_Delete_Base $model
891
-     * @param boolean              $trash whether to trash or restore
892
-     * @throws EE_Error
893
-     */
894
-    private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
895
-    {
896
-
897
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
898
-
899
-        $success = 1;
900
-        // Checkboxes
901
-        // echo "trash $trash";
902
-        // var_dump($this->_req_data['checkbox']);die;
903
-        if (isset($this->_req_data['checkbox'])) {
904
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
905
-                // if array has more than one element than success message should be plural
906
-                $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
907
-                // cycle thru bulk action checkboxes
908
-                while (list($ID, $value) = each($this->_req_data['checkbox'])) {
909
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
910
-                        $success = 0;
911
-                    }
912
-                }
913
-            } else {
914
-                // grab single id and delete
915
-                $ID = absint($this->_req_data['checkbox']);
916
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
917
-                    $success = 0;
918
-                }
919
-            }
920
-        } else {
921
-            // delete via trash link
922
-            // grab single id and delete
923
-            $ID = absint($this->_req_data[ $model->primary_key_name() ]);
924
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
925
-                $success = 0;
926
-            }
927
-        }
928
-
929
-
930
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
931
-        // echo "action :$action";
932
-        // $action = 'questions' ? 'default' : $action;
933
-        if ($trash) {
934
-            $action_desc = 'trashed';
935
-            $status = 'trash';
936
-        } else {
937
-            $action_desc = 'restored';
938
-            $status = 'all';
939
-        }
940
-        $this->_redirect_after_action(
941
-            $success,
942
-            $model->item_name($success),
943
-            $action_desc,
944
-            array('action' => $action, 'status' => $status)
945
-        );
946
-    }
947
-
948
-
949
-    /**
950
-     * @param            $per_page
951
-     * @param int        $current_page
952
-     * @param bool|false $count
953
-     * @return EE_Soft_Delete_Base_Class[]|int
954
-     * @throws EE_Error
955
-     * @throws InvalidArgumentException
956
-     * @throws InvalidDataTypeException
957
-     * @throws InvalidInterfaceException
958
-     */
959
-    public function get_trashed_questions($per_page, $current_page = 1, $count = false)
960
-    {
961
-        $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
962
-
963
-        if ($count) {
964
-            // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
965
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
966
-            $results = $this->_question_model->count_deleted($where);
967
-        } else {
968
-            // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
969
-            $results = $this->_question_model->get_all_deleted($query_params);
970
-        }
971
-        return $results;
972
-    }
973
-
974
-
975
-    /**
976
-     * @param            $per_page
977
-     * @param int        $current_page
978
-     * @param bool|false $count
979
-     * @return EE_Soft_Delete_Base_Class[]|int
980
-     * @throws EE_Error
981
-     * @throws InvalidArgumentException
982
-     * @throws InvalidDataTypeException
983
-     * @throws InvalidInterfaceException
984
-     */
985
-    public function get_question_groups($per_page, $current_page = 1, $count = false)
986
-    {
987
-        $questionGroupModel = EEM_Question_Group::instance();
988
-        $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
989
-        if ($count) {
990
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
991
-            $results = $questionGroupModel->count($where);
992
-        } else {
993
-            $results = $questionGroupModel->get_all($query_params);
994
-        }
995
-        return $results;
996
-    }
997
-
998
-
999
-    /**
1000
-     * @param      $per_page
1001
-     * @param int  $current_page
1002
-     * @param bool $count
1003
-     * @return EE_Soft_Delete_Base_Class[]|int
1004
-     * @throws EE_Error
1005
-     * @throws InvalidArgumentException
1006
-     * @throws InvalidDataTypeException
1007
-     * @throws InvalidInterfaceException
1008
-     */
1009
-    public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
1010
-    {
1011
-        $questionGroupModel = EEM_Question_Group::instance();
1012
-        $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
1013
-        if ($count) {
1014
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
1015
-            $query_params['limit'] = null;
1016
-            $results = $questionGroupModel->count_deleted($where);
1017
-        } else {
1018
-            $results = $questionGroupModel->get_all_deleted($query_params);
1019
-        }
1020
-        return $results;
1021
-    }
1022
-
1023
-
1024
-    /**
1025
-     * method for performing updates to question order
1026
-     *
1027
-     * @return void results array
1028
-     * @throws EE_Error
1029
-     * @throws InvalidArgumentException
1030
-     * @throws InvalidDataTypeException
1031
-     * @throws InvalidInterfaceException
1032
-     */
1033
-    public function update_question_group_order()
1034
-    {
1035
-
1036
-        $success = esc_html__('Question group order was updated successfully.', 'event_espresso');
1037
-
1038
-        // grab our row IDs
1039
-        $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
1040
-            ? explode(',', rtrim($this->_req_data['row_ids'], ','))
1041
-            : array();
1042
-
1043
-        $perpage = ! empty($this->_req_data['perpage'])
1044
-            ? (int) $this->_req_data['perpage']
1045
-            : null;
1046
-        $curpage = ! empty($this->_req_data['curpage'])
1047
-            ? (int) $this->_req_data['curpage']
1048
-            : null;
1049
-
1050
-        if (! empty($row_ids)) {
1051
-            // figure out where we start the row_id count at for the current page.
1052
-            $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1053
-
1054
-            $row_count = count($row_ids);
1055
-            for ($i = 0; $i < $row_count; $i++) {
1056
-                // Update the questions when re-ordering
1057
-                $updated = EEM_Question_Group::instance()->update(
1058
-                    array('QSG_order' => $qsgcount),
1059
-                    array(array('QSG_ID' => $row_ids[ $i ]))
1060
-                );
1061
-                if ($updated === false) {
1062
-                    $success = false;
1063
-                }
1064
-                $qsgcount++;
1065
-            }
1066
-        } else {
1067
-            $success = false;
1068
-        }
1069
-
1070
-        $errors = ! $success
1071
-            ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
1072
-            : false;
1073
-
1074
-        echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
1075
-        die();
1076
-    }
1077
-
1078
-
1079
-
1080
-    /***************************************       REGISTRATION SETTINGS       ***************************************/
1081
-
1082
-
1083
-    /**
1084
-     * @throws DomainException
1085
-     * @throws EE_Error
1086
-     * @throws InvalidArgumentException
1087
-     * @throws InvalidDataTypeException
1088
-     * @throws InvalidInterfaceException
1089
-     */
1090
-    protected function _reg_form_settings()
1091
-    {
1092
-        $this->_template_args['values'] = $this->_yes_no_values;
1093
-        add_action(
1094
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1095
-            array($this, 'email_validation_settings_form'),
1096
-            2
1097
-        );
1098
-        add_action(
1099
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1100
-            array($this, 'copy_attendee_info_settings_form'),
1101
-            4
1102
-        );
1103
-        $this->_template_args = (array) apply_filters(
1104
-            'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
1105
-            $this->_template_args
1106
-        );
1107
-        $this->_set_add_edit_form_tags('update_reg_form_settings');
1108
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1109
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1110
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1111
-            $this->_template_args,
1112
-            true
1113
-        );
1114
-        $this->display_admin_page_with_sidebar();
1115
-    }
1116
-
1117
-
1118
-    /**
1119
-     * @return void
1120
-     * @throws EE_Error
1121
-     * @throws InvalidArgumentException
1122
-     * @throws ReflectionException
1123
-     * @throws InvalidDataTypeException
1124
-     * @throws InvalidInterfaceException
1125
-     */
1126
-    protected function _update_reg_form_settings()
1127
-    {
1128
-        EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
1129
-            EE_Registry::instance()->CFG->registration
1130
-        );
1131
-        EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form(
1132
-            EE_Registry::instance()->CFG->registration
1133
-        );
1134
-        EE_Registry::instance()->CFG->registration = apply_filters(
1135
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
1136
-            EE_Registry::instance()->CFG->registration
1137
-        );
1138
-        $success = $this->_update_espresso_configuration(
1139
-            esc_html__('Registration Form Options', 'event_espresso'),
1140
-            EE_Registry::instance()->CFG,
1141
-            __FILE__,
1142
-            __FUNCTION__,
1143
-            __LINE__
1144
-        );
1145
-        $this->_redirect_after_action(
1146
-            $success,
1147
-            esc_html__('Registration Form Options', 'event_espresso'),
1148
-            'updated',
1149
-            array('action' => 'view_reg_form_settings')
1150
-        );
1151
-    }
1152
-
1153
-
1154
-    /**
1155
-     * @return void
1156
-     * @throws EE_Error
1157
-     * @throws InvalidArgumentException
1158
-     * @throws InvalidDataTypeException
1159
-     * @throws InvalidInterfaceException
1160
-     */
1161
-    public function copy_attendee_info_settings_form()
1162
-    {
1163
-        echo $this->_copy_attendee_info_settings_form()->get_html();
1164
-    }
1165
-
1166
-    /**
1167
-     * _copy_attendee_info_settings_form
1168
-     *
1169
-     * @access protected
1170
-     * @return EE_Form_Section_Proper
1171
-     * @throws \EE_Error
1172
-     */
1173
-    protected function _copy_attendee_info_settings_form()
1174
-    {
1175
-        return new EE_Form_Section_Proper(
1176
-            array(
1177
-                'name'            => 'copy_attendee_info_settings',
1178
-                'html_id'         => 'copy_attendee_info_settings',
1179
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1180
-                'subsections'     => apply_filters(
1181
-                    'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections',
1182
-                    array(
1183
-                        'copy_attendee_info_hdr'   => new EE_Form_Section_HTML(
1184
-                            EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso'))
1185
-                        ),
1186
-                        'copy_attendee_info' => new EE_Yes_No_Input(
1187
-                            array(
1188
-                                'html_label_text' => esc_html__(
1189
-                                    'Allow copy #1 attendee info to extra attendees?',
1190
-                                    'event_espresso'
1191
-                                ),
1192
-                                'html_help_text'  => esc_html__(
1193
-                                    'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.',
1194
-                                    'event_espresso'
1195
-                                ),
1196
-                                'default'         => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(),
1197
-                                'required'        => false,
1198
-                                'display_html_label_text' => false,
1199
-                            )
1200
-                        ),
1201
-                    )
1202
-                ),
1203
-            )
1204
-        );
1205
-    }
1206
-
1207
-    /**
1208
-     * @param EE_Registration_Config $EE_Registration_Config
1209
-     * @return EE_Registration_Config
1210
-     * @throws EE_Error
1211
-     * @throws InvalidArgumentException
1212
-     * @throws ReflectionException
1213
-     * @throws InvalidDataTypeException
1214
-     * @throws InvalidInterfaceException
1215
-     */
1216
-    public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config)
1217
-    {
1218
-        $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo();
1219
-        try {
1220
-            $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form();
1221
-            // if not displaying a form, then check for form submission
1222
-            if ($copy_attendee_info_settings_form->was_submitted()) {
1223
-                // capture form data
1224
-                $copy_attendee_info_settings_form->receive_form_submission();
1225
-                // validate form data
1226
-                if ($copy_attendee_info_settings_form->is_valid()) {
1227
-                    // grab validated data from form
1228
-                    $valid_data = $copy_attendee_info_settings_form->valid_data();
1229
-                    if (isset($valid_data['copy_attendee_info'])) {
1230
-                        $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']);
1231
-                    } else {
1232
-                        EE_Error::add_error(
1233
-                            esc_html__(
1234
-                                'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.',
1235
-                                'event_espresso'
1236
-                            ),
1237
-                            __FILE__,
1238
-                            __FUNCTION__,
1239
-                            __LINE__
1240
-                        );
1241
-                    }
1242
-                } else {
1243
-                    if ($copy_attendee_info_settings_form->submission_error_message() !== '') {
1244
-                        EE_Error::add_error(
1245
-                            $copy_attendee_info_settings_form->submission_error_message(),
1246
-                            __FILE__,
1247
-                            __FUNCTION__,
1248
-                            __LINE__
1249
-                        );
1250
-                    }
1251
-                }
1252
-            }
1253
-        } catch (EE_Error $e) {
1254
-            $e->get_error();
1255
-        }
1256
-        return $EE_Registration_Config;
1257
-    }
1258
-
1259
-
1260
-    /**
1261
-     * @return void
1262
-     * @throws EE_Error
1263
-     * @throws InvalidArgumentException
1264
-     * @throws InvalidDataTypeException
1265
-     * @throws InvalidInterfaceException
1266
-     */
1267
-    public function email_validation_settings_form()
1268
-    {
1269
-        echo $this->_email_validation_settings_form()->get_html();
1270
-    }
1271
-
1272
-
1273
-    /**
1274
-     * _email_validation_settings_form
1275
-     *
1276
-     * @access protected
1277
-     * @return EE_Form_Section_Proper
1278
-     * @throws \EE_Error
1279
-     */
1280
-    protected function _email_validation_settings_form()
1281
-    {
1282
-        return new EE_Form_Section_Proper(
1283
-            array(
1284
-                'name'            => 'email_validation_settings',
1285
-                'html_id'         => 'email_validation_settings',
1286
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1287
-                'subsections'     => apply_filters(
1288
-                    'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
1289
-                    array(
1290
-                        'email_validation_hdr'   => new EE_Form_Section_HTML(
1291
-                            EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
1292
-                        ),
1293
-                        'email_validation_level' => new EE_Select_Input(
1294
-                            array(
1295
-                                'basic'      => esc_html__('Basic', 'event_espresso'),
1296
-                                'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
1297
-                                'i18n'       => esc_html__('International', 'event_espresso'),
1298
-                                'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
1299
-                            ),
1300
-                            array(
1301
-                                'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
1302
-                                                     . EEH_Template::get_help_tab_link('email_validation_info'),
1303
-                                'html_help_text'  => esc_html__(
1304
-                                    '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.',
1305
-                                    'event_espresso'
1306
-                                ),
1307
-                                'default'         => isset(
1308
-                                    EE_Registry::instance()->CFG->registration->email_validation_level
1309
-                                )
1310
-                                    ? EE_Registry::instance()->CFG->registration->email_validation_level
1311
-                                    : 'wp_default',
1312
-                                'required'        => false,
1313
-                            )
1314
-                        ),
1315
-                    )
1316
-                ),
1317
-            )
1318
-        );
1319
-    }
1320
-
1321
-
1322
-    /**
1323
-     * @param EE_Registration_Config $EE_Registration_Config
1324
-     * @return EE_Registration_Config
1325
-     * @throws EE_Error
1326
-     * @throws InvalidArgumentException
1327
-     * @throws ReflectionException
1328
-     * @throws InvalidDataTypeException
1329
-     * @throws InvalidInterfaceException
1330
-     */
1331
-    public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1332
-    {
1333
-        $prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1334
-        try {
1335
-            $email_validation_settings_form = $this->_email_validation_settings_form();
1336
-            // if not displaying a form, then check for form submission
1337
-            if ($email_validation_settings_form->was_submitted()) {
1338
-                // capture form data
1339
-                $email_validation_settings_form->receive_form_submission();
1340
-                // validate form data
1341
-                if ($email_validation_settings_form->is_valid()) {
1342
-                    // grab validated data from form
1343
-                    $valid_data = $email_validation_settings_form->valid_data();
1344
-                    if (isset($valid_data['email_validation_level'])) {
1345
-                        $email_validation_level = $valid_data['email_validation_level'];
1346
-                        // now if they want to use international email addresses
1347
-                        if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1348
-                            // in case we need to reset their email validation level,
1349
-                            // make sure that the previous value wasn't already set to one of the i18n options.
1350
-                            if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1351
-                                // if so, then reset it back to "basic" since that is the only other option that,
1352
-                                // despite offering poor validation, supports i18n email addresses
1353
-                                $prev_email_validation_level = 'basic';
1354
-                            }
1355
-                            // confirm our i18n email validation will work on the server
1356
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1357
-                                // or reset email validation level to previous value
1358
-                                $email_validation_level = $prev_email_validation_level;
1359
-                            }
1360
-                        }
1361
-                        $EE_Registration_Config->email_validation_level = $email_validation_level;
1362
-                    } else {
1363
-                        EE_Error::add_error(
1364
-                            esc_html__(
1365
-                                'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1366
-                                'event_espresso'
1367
-                            ),
1368
-                            __FILE__,
1369
-                            __FUNCTION__,
1370
-                            __LINE__
1371
-                        );
1372
-                    }
1373
-                } else {
1374
-                    if ($email_validation_settings_form->submission_error_message() !== '') {
1375
-                        EE_Error::add_error(
1376
-                            $email_validation_settings_form->submission_error_message(),
1377
-                            __FILE__,
1378
-                            __FUNCTION__,
1379
-                            __LINE__
1380
-                        );
1381
-                    }
1382
-                }
1383
-            }
1384
-        } catch (EE_Error $e) {
1385
-            $e->get_error();
1386
-        }
1387
-        return $EE_Registration_Config;
1388
-    }
1389
-
1390
-
1391
-    /**
1392
-     * confirms that the server's PHP version has the PCRE module enabled,
1393
-     * and that the PCRE version works with our i18n email validation
1394
-     *
1395
-     * @param EE_Registration_Config $EE_Registration_Config
1396
-     * @param string                 $email_validation_level
1397
-     * @return bool
1398
-     */
1399
-    private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1400
-    {
1401
-        // first check that PCRE is enabled
1402
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1403
-            EE_Error::add_error(
1404
-                sprintf(
1405
-                    esc_html__(
1406
-                        '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.',
1407
-                        'event_espresso'
1408
-                    ),
1409
-                    '<br />'
1410
-                ),
1411
-                __FILE__,
1412
-                __FUNCTION__,
1413
-                __LINE__
1414
-            );
1415
-            return false;
1416
-        } else {
1417
-            // PCRE support is enabled, but let's still
1418
-            // perform a test to see if the server will support it.
1419
-            // but first, save the updated validation level to the config,
1420
-            // so that the validation strategy picks it up.
1421
-            // this will get bumped back down if it doesn't work
1422
-            $EE_Registration_Config->email_validation_level = $email_validation_level;
1423
-            try {
1424
-                $email_validator = new EE_Email_Validation_Strategy();
1425
-                $i18n_email_address = apply_filters(
1426
-                    'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1427
-                    'jägerjü[email protected]'
1428
-                );
1429
-                $email_validator->validate($i18n_email_address);
1430
-            } catch (Exception $e) {
1431
-                EE_Error::add_error(
1432
-                    sprintf(
1433
-                        esc_html__(
1434
-                            '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',
1435
-                            'event_espresso'
1436
-                        ),
1437
-                        '<br />',
1438
-                        '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>'
1439
-                    ),
1440
-                    __FILE__,
1441
-                    __FUNCTION__,
1442
-                    __LINE__
1443
-                );
1444
-                return false;
1445
-            }
1446
-        }
1447
-        return true;
1448
-    }
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
+				'metaboxes'     => $this->_default_espresso_metaboxes,
218
+				'require_nonce' => false,
219
+				'qtips'         => array(
220
+					'EE_Registration_Form_Tips',
221
+				),
222
+			),
223
+
224
+			'add_question' => array(
225
+				'nav'           => array(
226
+					'label'      => esc_html__('Add Question', 'event_espresso'),
227
+					'order'      => 5,
228
+					'persistent' => false,
229
+				),
230
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
231
+				'help_tabs'     => array(
232
+					'registration_form_add_question_help_tab' => array(
233
+						'title'    => esc_html__('Add Question', 'event_espresso'),
234
+						'filename' => 'registration_form_add_question',
235
+					),
236
+				),
237
+				'require_nonce' => false,
238
+			),
239
+
240
+			'add_question_group' => array(
241
+				'nav'           => array(
242
+					'label'      => esc_html__('Add Question Group', 'event_espresso'),
243
+					'order'      => 5,
244
+					'persistent' => false,
245
+				),
246
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
247
+				'help_tabs'     => array(
248
+					'registration_form_add_question_group_help_tab' => array(
249
+						'title'    => esc_html__('Add Question Group', 'event_espresso'),
250
+						'filename' => 'registration_form_add_question_group',
251
+					),
252
+				),
253
+				'require_nonce' => false,
254
+			),
255
+
256
+			'edit_question_group' => array(
257
+				'nav'           => array(
258
+					'label'      => esc_html__('Edit Question Group', 'event_espresso'),
259
+					'order'      => 5,
260
+					'persistent' => false,
261
+					'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(
262
+						array('question_group_id' => $this->_req_data['question_group_id']),
263
+						$this->_current_page_view_url
264
+					) : $this->_admin_base_url,
265
+				),
266
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
267
+				'help_tabs'     => array(
268
+					'registration_form_edit_question_group_help_tab' => array(
269
+						'title'    => esc_html__('Edit Question Group', 'event_espresso'),
270
+						'filename' => 'registration_form_edit_question_group',
271
+					),
272
+				),
273
+				'require_nonce' => false,
274
+			),
275
+
276
+			'view_reg_form_settings' => array(
277
+				'nav'           => array(
278
+					'label' => esc_html__('Reg Form Settings', 'event_espresso'),
279
+					'order' => 40,
280
+				),
281
+				'labels'        => array(
282
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
283
+				),
284
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
285
+				'help_tabs'     => array(
286
+					'registration_form_reg_form_settings_help_tab' => array(
287
+						'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
288
+						'filename' => 'registration_form_reg_form_settings',
289
+					),
290
+				),
291
+				'require_nonce' => false,
292
+			),
293
+
294
+		);
295
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
296
+
297
+		// change the list table we're going to use so it's the NEW list table!
298
+		$this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
299
+
300
+
301
+		// additional labels
302
+		$new_labels = array(
303
+			'add_question'          => esc_html__('Add New Question', 'event_espresso'),
304
+			'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
305
+			'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
306
+			'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
307
+			'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
308
+		);
309
+		$this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
310
+	}
311
+
312
+
313
+	/**
314
+	 * @return void
315
+	 */
316
+	protected function _ajax_hooks()
317
+	{
318
+		add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
319
+	}
320
+
321
+
322
+	/**
323
+	 * @return void
324
+	 */
325
+	public function load_scripts_styles_question_groups()
326
+	{
327
+		wp_enqueue_script('espresso_ajax_table_sorting');
328
+	}
329
+
330
+
331
+	/**
332
+	 * @return void
333
+	 */
334
+	public function load_scripts_styles_add_question_group()
335
+	{
336
+		$this->load_scripts_styles_forms();
337
+		$this->load_sortable_question_script();
338
+	}
339
+
340
+
341
+	/**
342
+	 * @return void
343
+	 */
344
+	public function load_scripts_styles_edit_question_group()
345
+	{
346
+		$this->load_scripts_styles_forms();
347
+		$this->load_sortable_question_script();
348
+	}
349
+
350
+
351
+	/**
352
+	 * registers and enqueues script for questions
353
+	 *
354
+	 * @return void
355
+	 */
356
+	public function load_sortable_question_script()
357
+	{
358
+		wp_register_script(
359
+			'ee-question-sortable',
360
+			REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
361
+			array('jquery-ui-sortable'),
362
+			EVENT_ESPRESSO_VERSION,
363
+			true
364
+		);
365
+		wp_enqueue_script('ee-question-sortable');
366
+	}
367
+
368
+
369
+	/**
370
+	 * @return void
371
+	 */
372
+	protected function _set_list_table_views_default()
373
+	{
374
+		$this->_views = array(
375
+			'all' => array(
376
+				'slug'        => 'all',
377
+				'label'       => esc_html__('View All Questions', 'event_espresso'),
378
+				'count'       => 0,
379
+				'bulk_action' => array(
380
+					'trash_questions' => esc_html__('Trash', 'event_espresso'),
381
+				),
382
+			),
383
+		);
384
+
385
+		if (
386
+			EE_Registry::instance()->CAP->current_user_can(
387
+				'ee_delete_questions',
388
+				'espresso_registration_form_trash_questions'
389
+			)
390
+		) {
391
+			$this->_views['trash'] = array(
392
+				'slug'        => 'trash',
393
+				'label'       => esc_html__('Trash', 'event_espresso'),
394
+				'count'       => 0,
395
+				'bulk_action' => array(
396
+					'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
397
+					'restore_questions' => esc_html__('Restore', 'event_espresso'),
398
+				),
399
+			);
400
+		}
401
+	}
402
+
403
+
404
+	/**
405
+	 * @return void
406
+	 */
407
+	protected function _set_list_table_views_question_groups()
408
+	{
409
+		$this->_views = array(
410
+			'all' => array(
411
+				'slug'        => 'all',
412
+				'label'       => esc_html__('All', 'event_espresso'),
413
+				'count'       => 0,
414
+				'bulk_action' => array(
415
+					'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
416
+				),
417
+			),
418
+		);
419
+
420
+		if (
421
+			EE_Registry::instance()->CAP->current_user_can(
422
+				'ee_delete_question_groups',
423
+				'espresso_registration_form_trash_question_groups'
424
+			)
425
+		) {
426
+			$this->_views['trash'] = array(
427
+				'slug'        => 'trash',
428
+				'label'       => esc_html__('Trash', 'event_espresso'),
429
+				'count'       => 0,
430
+				'bulk_action' => array(
431
+					'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
432
+					'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
433
+				),
434
+			);
435
+		}
436
+	}
437
+
438
+
439
+	/**
440
+	 * @return void
441
+	 * @throws EE_Error
442
+	 * @throws InvalidArgumentException
443
+	 * @throws InvalidDataTypeException
444
+	 * @throws InvalidInterfaceException
445
+	 */
446
+	protected function _questions_overview_list_table()
447
+	{
448
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
449
+			'add_question',
450
+			'add_question',
451
+			array(),
452
+			'add-new-h2'
453
+		);
454
+		parent::_questions_overview_list_table();
455
+	}
456
+
457
+
458
+	/**
459
+	 * @return void
460
+	 * @throws DomainException
461
+	 * @throws EE_Error
462
+	 * @throws InvalidArgumentException
463
+	 * @throws InvalidDataTypeException
464
+	 * @throws InvalidInterfaceException
465
+	 */
466
+	protected function _question_groups_overview_list_table()
467
+	{
468
+		$this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
469
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
470
+			'add_question_group',
471
+			'add_question_group',
472
+			array(),
473
+			'add-new-h2'
474
+		);
475
+		$this->display_admin_list_table_page_with_sidebar();
476
+	}
477
+
478
+
479
+	/**
480
+	 * @return void
481
+	 * @throws EE_Error
482
+	 * @throws InvalidArgumentException
483
+	 * @throws InvalidDataTypeException
484
+	 * @throws InvalidInterfaceException
485
+	 */
486
+	protected function _delete_question()
487
+	{
488
+		$success = $this->_delete_items($this->_question_model);
489
+		$this->_redirect_after_action(
490
+			$success,
491
+			$this->_question_model->item_name($success),
492
+			'deleted',
493
+			array('action' => 'default', 'status' => 'all')
494
+		);
495
+	}
496
+
497
+
498
+	/**
499
+	 * @return void
500
+	 * @throws EE_Error
501
+	 * @throws InvalidArgumentException
502
+	 * @throws InvalidDataTypeException
503
+	 * @throws InvalidInterfaceException
504
+	 */
505
+	protected function _delete_questions()
506
+	{
507
+		$success = $this->_delete_items($this->_question_model);
508
+		$this->_redirect_after_action(
509
+			$success,
510
+			$this->_question_model->item_name($success),
511
+			'deleted permanently',
512
+			array('action' => 'default', 'status' => 'trash')
513
+		);
514
+	}
515
+
516
+
517
+	/**
518
+	 * Performs the deletion of a single or multiple questions or question groups.
519
+	 *
520
+	 * @param EEM_Soft_Delete_Base $model
521
+	 * @return int number of items deleted permanently
522
+	 * @throws EE_Error
523
+	 * @throws InvalidArgumentException
524
+	 * @throws InvalidDataTypeException
525
+	 * @throws InvalidInterfaceException
526
+	 */
527
+	private function _delete_items(EEM_Soft_Delete_Base $model)
528
+	{
529
+		$success = 0;
530
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
531
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
532
+			// if array has more than one element than success message should be plural
533
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
534
+			// cycle thru bulk action checkboxes
535
+			while (list($ID, $value) = each($this->_req_data['checkbox'])) {
536
+				if (! $this->_delete_item($ID, $model)) {
537
+					$success = 0;
538
+				}
539
+			}
540
+		} elseif (! empty($this->_req_data['QSG_ID'])) {
541
+			$success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
542
+		} elseif (! empty($this->_req_data['QST_ID'])) {
543
+			$success = $this->_delete_item($this->_req_data['QST_ID'], $model);
544
+		} else {
545
+			EE_Error::add_error(
546
+				sprintf(
547
+					esc_html__(
548
+						"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.",
549
+						"event_espresso"
550
+					)
551
+				),
552
+				__FILE__,
553
+				__FUNCTION__,
554
+				__LINE__
555
+			);
556
+		}
557
+		return $success;
558
+	}
559
+
560
+
561
+	/**
562
+	 * Deletes the specified question (and its associated question options) or question group
563
+	 *
564
+	 * @param int                  $id
565
+	 * @param EEM_Soft_Delete_Base $model
566
+	 * @return boolean
567
+	 * @throws EE_Error
568
+	 * @throws InvalidArgumentException
569
+	 * @throws InvalidDataTypeException
570
+	 * @throws InvalidInterfaceException
571
+	 */
572
+	protected function _delete_item($id, $model)
573
+	{
574
+		if ($model instanceof EEM_Question) {
575
+			EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
576
+		}
577
+		return $model->delete_permanently_by_ID(absint($id));
578
+	}
579
+
580
+
581
+	/******************************    QUESTION GROUPS    ******************************/
582
+
583
+
584
+	/**
585
+	 * @param string $type
586
+	 * @return void
587
+	 * @throws DomainException
588
+	 * @throws EE_Error
589
+	 * @throws InvalidArgumentException
590
+	 * @throws InvalidDataTypeException
591
+	 * @throws InvalidInterfaceException
592
+	 */
593
+	protected function _edit_question_group($type = 'add')
594
+	{
595
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
596
+		$ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID'])
597
+			? absint($this->_req_data['QSG_ID'])
598
+			: false;
599
+
600
+		switch ($this->_req_action) {
601
+			case 'add_question_group':
602
+				$this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
603
+				break;
604
+			case 'edit_question_group':
605
+				$this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
606
+				break;
607
+			default:
608
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
609
+		}
610
+		// add ID to title if editing
611
+		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
612
+		if ($ID) {
613
+			/** @var EE_Question_Group $questionGroup */
614
+			$questionGroup = $this->_question_group_model->get_one_by_ID($ID);
615
+			$additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
616
+			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
617
+		} else {
618
+			/** @var EE_Question_Group $questionGroup */
619
+			$questionGroup = EEM_Question_Group::instance()->create_default_object();
620
+			$questionGroup->set_order_to_latest();
621
+			$this->_set_add_edit_form_tags('insert_question_group');
622
+		}
623
+		$this->_template_args['values'] = $this->_yes_no_values;
624
+		$this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
625
+		$this->_template_args['QSG_ID'] = $ID ? $ID : true;
626
+		$this->_template_args['question_group'] = $questionGroup;
627
+
628
+		$redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
629
+		$this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
630
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
631
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
632
+			$this->_template_args,
633
+			true
634
+		);
635
+
636
+		// the details template wrapper
637
+		$this->display_admin_page_with_sidebar();
638
+	}
639
+
640
+
641
+	/**
642
+	 * @return void
643
+	 * @throws EE_Error
644
+	 * @throws InvalidArgumentException
645
+	 * @throws InvalidDataTypeException
646
+	 * @throws InvalidInterfaceException
647
+	 */
648
+	protected function _delete_question_groups()
649
+	{
650
+		$success = $this->_delete_items($this->_question_group_model);
651
+		$this->_redirect_after_action(
652
+			$success,
653
+			$this->_question_group_model->item_name($success),
654
+			'deleted permanently',
655
+			array('action' => 'question_groups', 'status' => 'trash')
656
+		);
657
+	}
658
+
659
+
660
+	/**
661
+	 * @param bool $new_question_group
662
+	 * @throws EE_Error
663
+	 * @throws InvalidArgumentException
664
+	 * @throws InvalidDataTypeException
665
+	 * @throws InvalidInterfaceException
666
+	 */
667
+	protected function _insert_or_update_question_group($new_question_group = true)
668
+	{
669
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
670
+		$set_column_values = $this->_set_column_values_for($this->_question_group_model);
671
+		if ($new_question_group) {
672
+			// make sure identifier is unique
673
+			$identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : '';
674
+			$identifier_exists = ! empty($identifier_value)
675
+				? $this->_question_group_model->count([['QSG_identifier' => $set_column_values['QSG_identifier']]]) > 0
676
+				: false;
677
+			if ($identifier_exists) {
678
+				$set_column_values['QSG_identifier'] .= uniqid('id', true);
679
+			}
680
+			$QSG_ID = $this->_question_group_model->insert($set_column_values);
681
+			$success = $QSG_ID ? 1 : 0;
682
+			if ($success === 0) {
683
+				EE_Error::add_error(
684
+					esc_html__('Something went wrong saving the question group.', 'event_espresso'),
685
+					__FILE__,
686
+					__FUNCTION__,
687
+					__LINE__
688
+				);
689
+				$this->_redirect_after_action(
690
+					false,
691
+					'',
692
+					'',
693
+					array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
694
+					true
695
+				);
696
+			}
697
+		} else {
698
+			$QSG_ID = absint($this->_req_data['QSG_ID']);
699
+			unset($set_column_values['QSG_ID']);
700
+			$success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
701
+		}
702
+
703
+		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(
704
+			EEM_Attendee::system_question_phone
705
+		);
706
+		// update the existing related questions
707
+		// BUT FIRST...  delete the phone question from the Question_Group_Question
708
+		// if it is being added to this question group (therefore removed from the existing group)
709
+		if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) {
710
+			// delete where QST ID = system phone question ID and Question Group ID is NOT this group
711
+			EEM_Question_Group_Question::instance()->delete(
712
+				array(
713
+					array(
714
+						'QST_ID' => $phone_question_id,
715
+						'QSG_ID' => array('!=', $QSG_ID),
716
+					),
717
+				)
718
+			);
719
+		}
720
+		/** @type EE_Question_Group $question_group */
721
+		$question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
722
+		$questions = $question_group->questions();
723
+		// make sure system phone question is added to list of questions for this group
724
+		if (! isset($questions[ $phone_question_id ])) {
725
+			$questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
726
+		}
727
+
728
+		foreach ($questions as $question_ID => $question) {
729
+			// first we always check for order.
730
+			if (! empty($this->_req_data['question_orders'][ $question_ID ])) {
731
+				// update question order
732
+				$question_group->update_question_order(
733
+					$question_ID,
734
+					$this->_req_data['question_orders'][ $question_ID ]
735
+				);
736
+			}
737
+
738
+			// then we always check if adding or removing.
739
+			if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) {
740
+				$question_group->add_question($question_ID);
741
+			} else {
742
+				// not found, remove it (but only if not a system question for the personal group
743
+				// with the exception of lname system question - we allow removal of it)
744
+				if (
745
+					in_array(
746
+						$question->system_ID(),
747
+						EEM_Question::instance()->required_system_questions_in_system_question_group(
748
+							$question_group->system_group()
749
+						)
750
+					)
751
+				) {
752
+					continue;
753
+				} else {
754
+					$question_group->remove_question($question_ID);
755
+				}
756
+			}
757
+		}
758
+		// save new related questions
759
+		if (isset($this->_req_data['questions'])) {
760
+			foreach ($this->_req_data['questions'] as $QST_ID) {
761
+				$question_group->add_question($QST_ID);
762
+				if (isset($this->_req_data['question_orders'][ $QST_ID ])) {
763
+					$question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]);
764
+				}
765
+			}
766
+		}
767
+
768
+		if ($success !== false) {
769
+			$msg = $new_question_group
770
+				? sprintf(
771
+					esc_html__('The %s has been created', 'event_espresso'),
772
+					$this->_question_group_model->item_name()
773
+				)
774
+				: sprintf(
775
+					esc_html__(
776
+						'The %s has been updated',
777
+						'event_espresso'
778
+					),
779
+					$this->_question_group_model->item_name()
780
+				);
781
+			EE_Error::add_success($msg);
782
+		}
783
+		$this->_redirect_after_action(
784
+			false,
785
+			'',
786
+			'',
787
+			array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
788
+			true
789
+		);
790
+	}
791
+
792
+
793
+	/**
794
+	 * duplicates a question and all its question options and redirects to the new question.
795
+	 *
796
+	 * @return void
797
+	 * @throws EE_Error
798
+	 * @throws InvalidArgumentException
799
+	 * @throws ReflectionException
800
+	 * @throws InvalidDataTypeException
801
+	 * @throws InvalidInterfaceException
802
+	 */
803
+	public function _duplicate_question()
804
+	{
805
+		$question_ID = (int) $this->_req_data['QST_ID'];
806
+		$question = EEM_Question::instance()->get_one_by_ID($question_ID);
807
+		if ($question instanceof EE_Question) {
808
+			$new_question = $question->duplicate();
809
+			if ($new_question instanceof EE_Question) {
810
+				$this->_redirect_after_action(
811
+					true,
812
+					esc_html__('Question', 'event_espresso'),
813
+					esc_html__('Duplicated', 'event_espresso'),
814
+					array('action' => 'edit_question', 'QST_ID' => $new_question->ID()),
815
+					true
816
+				);
817
+			} else {
818
+				global $wpdb;
819
+				EE_Error::add_error(
820
+					sprintf(
821
+						esc_html__(
822
+							'Could not duplicate question with ID %1$d because: %2$s',
823
+							'event_espresso'
824
+						),
825
+						$question_ID,
826
+						$wpdb->last_error
827
+					),
828
+					__FILE__,
829
+					__FUNCTION__,
830
+					__LINE__
831
+				);
832
+				$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
833
+			}
834
+		} else {
835
+			EE_Error::add_error(
836
+				sprintf(
837
+					esc_html__(
838
+						'Could not duplicate question with ID %d because it didn\'t exist!',
839
+						'event_espresso'
840
+					),
841
+					$question_ID
842
+				),
843
+				__FILE__,
844
+				__FUNCTION__,
845
+				__LINE__
846
+			);
847
+			$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
848
+		}
849
+	}
850
+
851
+
852
+	/**
853
+	 * @param bool $trash
854
+	 * @throws EE_Error
855
+	 */
856
+	protected function _trash_or_restore_question_groups($trash = true)
857
+	{
858
+		$this->_trash_or_restore_items($this->_question_group_model, $trash);
859
+	}
860
+
861
+
862
+	/**
863
+	 *_trash_question
864
+	 *
865
+	 * @return void
866
+	 * @throws EE_Error
867
+	 */
868
+	protected function _trash_question()
869
+	{
870
+		$success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
871
+		$query_args = array('action' => 'default', 'status' => 'all');
872
+		$this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
873
+	}
874
+
875
+
876
+	/**
877
+	 * @param bool $trash
878
+	 * @throws EE_Error
879
+	 */
880
+	protected function _trash_or_restore_questions($trash = true)
881
+	{
882
+		$this->_trash_or_restore_items($this->_question_model, $trash);
883
+	}
884
+
885
+
886
+	/**
887
+	 * Internally used to delete or restore items, using the request data. Meant to be
888
+	 * flexible between question or question groups
889
+	 *
890
+	 * @param EEM_Soft_Delete_Base $model
891
+	 * @param boolean              $trash whether to trash or restore
892
+	 * @throws EE_Error
893
+	 */
894
+	private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
895
+	{
896
+
897
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
898
+
899
+		$success = 1;
900
+		// Checkboxes
901
+		// echo "trash $trash";
902
+		// var_dump($this->_req_data['checkbox']);die;
903
+		if (isset($this->_req_data['checkbox'])) {
904
+			if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
905
+				// if array has more than one element than success message should be plural
906
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
907
+				// cycle thru bulk action checkboxes
908
+				while (list($ID, $value) = each($this->_req_data['checkbox'])) {
909
+					if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
910
+						$success = 0;
911
+					}
912
+				}
913
+			} else {
914
+				// grab single id and delete
915
+				$ID = absint($this->_req_data['checkbox']);
916
+				if (! $model->delete_or_restore_by_ID($trash, $ID)) {
917
+					$success = 0;
918
+				}
919
+			}
920
+		} else {
921
+			// delete via trash link
922
+			// grab single id and delete
923
+			$ID = absint($this->_req_data[ $model->primary_key_name() ]);
924
+			if (! $model->delete_or_restore_by_ID($trash, $ID)) {
925
+				$success = 0;
926
+			}
927
+		}
928
+
929
+
930
+		$action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) );
931
+		// echo "action :$action";
932
+		// $action = 'questions' ? 'default' : $action;
933
+		if ($trash) {
934
+			$action_desc = 'trashed';
935
+			$status = 'trash';
936
+		} else {
937
+			$action_desc = 'restored';
938
+			$status = 'all';
939
+		}
940
+		$this->_redirect_after_action(
941
+			$success,
942
+			$model->item_name($success),
943
+			$action_desc,
944
+			array('action' => $action, 'status' => $status)
945
+		);
946
+	}
947
+
948
+
949
+	/**
950
+	 * @param            $per_page
951
+	 * @param int        $current_page
952
+	 * @param bool|false $count
953
+	 * @return EE_Soft_Delete_Base_Class[]|int
954
+	 * @throws EE_Error
955
+	 * @throws InvalidArgumentException
956
+	 * @throws InvalidDataTypeException
957
+	 * @throws InvalidInterfaceException
958
+	 */
959
+	public function get_trashed_questions($per_page, $current_page = 1, $count = false)
960
+	{
961
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
962
+
963
+		if ($count) {
964
+			// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
965
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
966
+			$results = $this->_question_model->count_deleted($where);
967
+		} else {
968
+			// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
969
+			$results = $this->_question_model->get_all_deleted($query_params);
970
+		}
971
+		return $results;
972
+	}
973
+
974
+
975
+	/**
976
+	 * @param            $per_page
977
+	 * @param int        $current_page
978
+	 * @param bool|false $count
979
+	 * @return EE_Soft_Delete_Base_Class[]|int
980
+	 * @throws EE_Error
981
+	 * @throws InvalidArgumentException
982
+	 * @throws InvalidDataTypeException
983
+	 * @throws InvalidInterfaceException
984
+	 */
985
+	public function get_question_groups($per_page, $current_page = 1, $count = false)
986
+	{
987
+		$questionGroupModel = EEM_Question_Group::instance();
988
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
989
+		if ($count) {
990
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
991
+			$results = $questionGroupModel->count($where);
992
+		} else {
993
+			$results = $questionGroupModel->get_all($query_params);
994
+		}
995
+		return $results;
996
+	}
997
+
998
+
999
+	/**
1000
+	 * @param      $per_page
1001
+	 * @param int  $current_page
1002
+	 * @param bool $count
1003
+	 * @return EE_Soft_Delete_Base_Class[]|int
1004
+	 * @throws EE_Error
1005
+	 * @throws InvalidArgumentException
1006
+	 * @throws InvalidDataTypeException
1007
+	 * @throws InvalidInterfaceException
1008
+	 */
1009
+	public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
1010
+	{
1011
+		$questionGroupModel = EEM_Question_Group::instance();
1012
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
1013
+		if ($count) {
1014
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
1015
+			$query_params['limit'] = null;
1016
+			$results = $questionGroupModel->count_deleted($where);
1017
+		} else {
1018
+			$results = $questionGroupModel->get_all_deleted($query_params);
1019
+		}
1020
+		return $results;
1021
+	}
1022
+
1023
+
1024
+	/**
1025
+	 * method for performing updates to question order
1026
+	 *
1027
+	 * @return void results array
1028
+	 * @throws EE_Error
1029
+	 * @throws InvalidArgumentException
1030
+	 * @throws InvalidDataTypeException
1031
+	 * @throws InvalidInterfaceException
1032
+	 */
1033
+	public function update_question_group_order()
1034
+	{
1035
+
1036
+		$success = esc_html__('Question group order was updated successfully.', 'event_espresso');
1037
+
1038
+		// grab our row IDs
1039
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
1040
+			? explode(',', rtrim($this->_req_data['row_ids'], ','))
1041
+			: array();
1042
+
1043
+		$perpage = ! empty($this->_req_data['perpage'])
1044
+			? (int) $this->_req_data['perpage']
1045
+			: null;
1046
+		$curpage = ! empty($this->_req_data['curpage'])
1047
+			? (int) $this->_req_data['curpage']
1048
+			: null;
1049
+
1050
+		if (! empty($row_ids)) {
1051
+			// figure out where we start the row_id count at for the current page.
1052
+			$qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
1053
+
1054
+			$row_count = count($row_ids);
1055
+			for ($i = 0; $i < $row_count; $i++) {
1056
+				// Update the questions when re-ordering
1057
+				$updated = EEM_Question_Group::instance()->update(
1058
+					array('QSG_order' => $qsgcount),
1059
+					array(array('QSG_ID' => $row_ids[ $i ]))
1060
+				);
1061
+				if ($updated === false) {
1062
+					$success = false;
1063
+				}
1064
+				$qsgcount++;
1065
+			}
1066
+		} else {
1067
+			$success = false;
1068
+		}
1069
+
1070
+		$errors = ! $success
1071
+			? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
1072
+			: false;
1073
+
1074
+		echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
1075
+		die();
1076
+	}
1077
+
1078
+
1079
+
1080
+	/***************************************       REGISTRATION SETTINGS       ***************************************/
1081
+
1082
+
1083
+	/**
1084
+	 * @throws DomainException
1085
+	 * @throws EE_Error
1086
+	 * @throws InvalidArgumentException
1087
+	 * @throws InvalidDataTypeException
1088
+	 * @throws InvalidInterfaceException
1089
+	 */
1090
+	protected function _reg_form_settings()
1091
+	{
1092
+		$this->_template_args['values'] = $this->_yes_no_values;
1093
+		add_action(
1094
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1095
+			array($this, 'email_validation_settings_form'),
1096
+			2
1097
+		);
1098
+		add_action(
1099
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
1100
+			array($this, 'copy_attendee_info_settings_form'),
1101
+			4
1102
+		);
1103
+		$this->_template_args = (array) apply_filters(
1104
+			'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
1105
+			$this->_template_args
1106
+		);
1107
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
1108
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1109
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1110
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
1111
+			$this->_template_args,
1112
+			true
1113
+		);
1114
+		$this->display_admin_page_with_sidebar();
1115
+	}
1116
+
1117
+
1118
+	/**
1119
+	 * @return void
1120
+	 * @throws EE_Error
1121
+	 * @throws InvalidArgumentException
1122
+	 * @throws ReflectionException
1123
+	 * @throws InvalidDataTypeException
1124
+	 * @throws InvalidInterfaceException
1125
+	 */
1126
+	protected function _update_reg_form_settings()
1127
+	{
1128
+		EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
1129
+			EE_Registry::instance()->CFG->registration
1130
+		);
1131
+		EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form(
1132
+			EE_Registry::instance()->CFG->registration
1133
+		);
1134
+		EE_Registry::instance()->CFG->registration = apply_filters(
1135
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
1136
+			EE_Registry::instance()->CFG->registration
1137
+		);
1138
+		$success = $this->_update_espresso_configuration(
1139
+			esc_html__('Registration Form Options', 'event_espresso'),
1140
+			EE_Registry::instance()->CFG,
1141
+			__FILE__,
1142
+			__FUNCTION__,
1143
+			__LINE__
1144
+		);
1145
+		$this->_redirect_after_action(
1146
+			$success,
1147
+			esc_html__('Registration Form Options', 'event_espresso'),
1148
+			'updated',
1149
+			array('action' => 'view_reg_form_settings')
1150
+		);
1151
+	}
1152
+
1153
+
1154
+	/**
1155
+	 * @return void
1156
+	 * @throws EE_Error
1157
+	 * @throws InvalidArgumentException
1158
+	 * @throws InvalidDataTypeException
1159
+	 * @throws InvalidInterfaceException
1160
+	 */
1161
+	public function copy_attendee_info_settings_form()
1162
+	{
1163
+		echo $this->_copy_attendee_info_settings_form()->get_html();
1164
+	}
1165
+
1166
+	/**
1167
+	 * _copy_attendee_info_settings_form
1168
+	 *
1169
+	 * @access protected
1170
+	 * @return EE_Form_Section_Proper
1171
+	 * @throws \EE_Error
1172
+	 */
1173
+	protected function _copy_attendee_info_settings_form()
1174
+	{
1175
+		return new EE_Form_Section_Proper(
1176
+			array(
1177
+				'name'            => 'copy_attendee_info_settings',
1178
+				'html_id'         => 'copy_attendee_info_settings',
1179
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1180
+				'subsections'     => apply_filters(
1181
+					'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections',
1182
+					array(
1183
+						'copy_attendee_info_hdr'   => new EE_Form_Section_HTML(
1184
+							EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso'))
1185
+						),
1186
+						'copy_attendee_info' => new EE_Yes_No_Input(
1187
+							array(
1188
+								'html_label_text' => esc_html__(
1189
+									'Allow copy #1 attendee info to extra attendees?',
1190
+									'event_espresso'
1191
+								),
1192
+								'html_help_text'  => esc_html__(
1193
+									'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.',
1194
+									'event_espresso'
1195
+								),
1196
+								'default'         => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(),
1197
+								'required'        => false,
1198
+								'display_html_label_text' => false,
1199
+							)
1200
+						),
1201
+					)
1202
+				),
1203
+			)
1204
+		);
1205
+	}
1206
+
1207
+	/**
1208
+	 * @param EE_Registration_Config $EE_Registration_Config
1209
+	 * @return EE_Registration_Config
1210
+	 * @throws EE_Error
1211
+	 * @throws InvalidArgumentException
1212
+	 * @throws ReflectionException
1213
+	 * @throws InvalidDataTypeException
1214
+	 * @throws InvalidInterfaceException
1215
+	 */
1216
+	public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config)
1217
+	{
1218
+		$prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo();
1219
+		try {
1220
+			$copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form();
1221
+			// if not displaying a form, then check for form submission
1222
+			if ($copy_attendee_info_settings_form->was_submitted()) {
1223
+				// capture form data
1224
+				$copy_attendee_info_settings_form->receive_form_submission();
1225
+				// validate form data
1226
+				if ($copy_attendee_info_settings_form->is_valid()) {
1227
+					// grab validated data from form
1228
+					$valid_data = $copy_attendee_info_settings_form->valid_data();
1229
+					if (isset($valid_data['copy_attendee_info'])) {
1230
+						$EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']);
1231
+					} else {
1232
+						EE_Error::add_error(
1233
+							esc_html__(
1234
+								'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.',
1235
+								'event_espresso'
1236
+							),
1237
+							__FILE__,
1238
+							__FUNCTION__,
1239
+							__LINE__
1240
+						);
1241
+					}
1242
+				} else {
1243
+					if ($copy_attendee_info_settings_form->submission_error_message() !== '') {
1244
+						EE_Error::add_error(
1245
+							$copy_attendee_info_settings_form->submission_error_message(),
1246
+							__FILE__,
1247
+							__FUNCTION__,
1248
+							__LINE__
1249
+						);
1250
+					}
1251
+				}
1252
+			}
1253
+		} catch (EE_Error $e) {
1254
+			$e->get_error();
1255
+		}
1256
+		return $EE_Registration_Config;
1257
+	}
1258
+
1259
+
1260
+	/**
1261
+	 * @return void
1262
+	 * @throws EE_Error
1263
+	 * @throws InvalidArgumentException
1264
+	 * @throws InvalidDataTypeException
1265
+	 * @throws InvalidInterfaceException
1266
+	 */
1267
+	public function email_validation_settings_form()
1268
+	{
1269
+		echo $this->_email_validation_settings_form()->get_html();
1270
+	}
1271
+
1272
+
1273
+	/**
1274
+	 * _email_validation_settings_form
1275
+	 *
1276
+	 * @access protected
1277
+	 * @return EE_Form_Section_Proper
1278
+	 * @throws \EE_Error
1279
+	 */
1280
+	protected function _email_validation_settings_form()
1281
+	{
1282
+		return new EE_Form_Section_Proper(
1283
+			array(
1284
+				'name'            => 'email_validation_settings',
1285
+				'html_id'         => 'email_validation_settings',
1286
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1287
+				'subsections'     => apply_filters(
1288
+					'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections',
1289
+					array(
1290
+						'email_validation_hdr'   => new EE_Form_Section_HTML(
1291
+							EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
1292
+						),
1293
+						'email_validation_level' => new EE_Select_Input(
1294
+							array(
1295
+								'basic'      => esc_html__('Basic', 'event_espresso'),
1296
+								'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
1297
+								'i18n'       => esc_html__('International', 'event_espresso'),
1298
+								'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
1299
+							),
1300
+							array(
1301
+								'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
1302
+													 . EEH_Template::get_help_tab_link('email_validation_info'),
1303
+								'html_help_text'  => esc_html__(
1304
+									'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.',
1305
+									'event_espresso'
1306
+								),
1307
+								'default'         => isset(
1308
+									EE_Registry::instance()->CFG->registration->email_validation_level
1309
+								)
1310
+									? EE_Registry::instance()->CFG->registration->email_validation_level
1311
+									: 'wp_default',
1312
+								'required'        => false,
1313
+							)
1314
+						),
1315
+					)
1316
+				),
1317
+			)
1318
+		);
1319
+	}
1320
+
1321
+
1322
+	/**
1323
+	 * @param EE_Registration_Config $EE_Registration_Config
1324
+	 * @return EE_Registration_Config
1325
+	 * @throws EE_Error
1326
+	 * @throws InvalidArgumentException
1327
+	 * @throws ReflectionException
1328
+	 * @throws InvalidDataTypeException
1329
+	 * @throws InvalidInterfaceException
1330
+	 */
1331
+	public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1332
+	{
1333
+		$prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1334
+		try {
1335
+			$email_validation_settings_form = $this->_email_validation_settings_form();
1336
+			// if not displaying a form, then check for form submission
1337
+			if ($email_validation_settings_form->was_submitted()) {
1338
+				// capture form data
1339
+				$email_validation_settings_form->receive_form_submission();
1340
+				// validate form data
1341
+				if ($email_validation_settings_form->is_valid()) {
1342
+					// grab validated data from form
1343
+					$valid_data = $email_validation_settings_form->valid_data();
1344
+					if (isset($valid_data['email_validation_level'])) {
1345
+						$email_validation_level = $valid_data['email_validation_level'];
1346
+						// now if they want to use international email addresses
1347
+						if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1348
+							// in case we need to reset their email validation level,
1349
+							// make sure that the previous value wasn't already set to one of the i18n options.
1350
+							if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1351
+								// if so, then reset it back to "basic" since that is the only other option that,
1352
+								// despite offering poor validation, supports i18n email addresses
1353
+								$prev_email_validation_level = 'basic';
1354
+							}
1355
+							// confirm our i18n email validation will work on the server
1356
+							if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1357
+								// or reset email validation level to previous value
1358
+								$email_validation_level = $prev_email_validation_level;
1359
+							}
1360
+						}
1361
+						$EE_Registration_Config->email_validation_level = $email_validation_level;
1362
+					} else {
1363
+						EE_Error::add_error(
1364
+							esc_html__(
1365
+								'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1366
+								'event_espresso'
1367
+							),
1368
+							__FILE__,
1369
+							__FUNCTION__,
1370
+							__LINE__
1371
+						);
1372
+					}
1373
+				} else {
1374
+					if ($email_validation_settings_form->submission_error_message() !== '') {
1375
+						EE_Error::add_error(
1376
+							$email_validation_settings_form->submission_error_message(),
1377
+							__FILE__,
1378
+							__FUNCTION__,
1379
+							__LINE__
1380
+						);
1381
+					}
1382
+				}
1383
+			}
1384
+		} catch (EE_Error $e) {
1385
+			$e->get_error();
1386
+		}
1387
+		return $EE_Registration_Config;
1388
+	}
1389
+
1390
+
1391
+	/**
1392
+	 * confirms that the server's PHP version has the PCRE module enabled,
1393
+	 * and that the PCRE version works with our i18n email validation
1394
+	 *
1395
+	 * @param EE_Registration_Config $EE_Registration_Config
1396
+	 * @param string                 $email_validation_level
1397
+	 * @return bool
1398
+	 */
1399
+	private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1400
+	{
1401
+		// first check that PCRE is enabled
1402
+		if (! defined('PREG_BAD_UTF8_ERROR')) {
1403
+			EE_Error::add_error(
1404
+				sprintf(
1405
+					esc_html__(
1406
+						'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.',
1407
+						'event_espresso'
1408
+					),
1409
+					'<br />'
1410
+				),
1411
+				__FILE__,
1412
+				__FUNCTION__,
1413
+				__LINE__
1414
+			);
1415
+			return false;
1416
+		} else {
1417
+			// PCRE support is enabled, but let's still
1418
+			// perform a test to see if the server will support it.
1419
+			// but first, save the updated validation level to the config,
1420
+			// so that the validation strategy picks it up.
1421
+			// this will get bumped back down if it doesn't work
1422
+			$EE_Registration_Config->email_validation_level = $email_validation_level;
1423
+			try {
1424
+				$email_validator = new EE_Email_Validation_Strategy();
1425
+				$i18n_email_address = apply_filters(
1426
+					'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1427
+					'jägerjü[email protected]'
1428
+				);
1429
+				$email_validator->validate($i18n_email_address);
1430
+			} catch (Exception $e) {
1431
+				EE_Error::add_error(
1432
+					sprintf(
1433
+						esc_html__(
1434
+							'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',
1435
+							'event_espresso'
1436
+						),
1437
+						'<br />',
1438
+						'<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>'
1439
+					),
1440
+					__FILE__,
1441
+					__FUNCTION__,
1442
+					__LINE__
1443
+				);
1444
+				return false;
1445
+			}
1446
+		}
1447
+		return true;
1448
+	}
1449 1449
 }
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.