Completed
Branch FET/reg-form-builder/main (69a760)
by
unknown
04:39 queued 02:08
created
core/db_models/fields/EE_Boolean_Field.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -2,62 +2,62 @@
 block discarded – undo
2 2
 
3 3
 class EE_Boolean_Field extends EE_Integer_Field
4 4
 {
5
-    /**
6
-     * @param string $table_column
7
-     * @param string $nicename
8
-     * @param bool   $nullable
9
-     * @param null   $default_value
10
-     */
11
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
12
-    {
13
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
14
-        $this->setSchemaType('boolean');
15
-    }
5
+	/**
6
+	 * @param string $table_column
7
+	 * @param string $nicename
8
+	 * @param bool   $nullable
9
+	 * @param null   $default_value
10
+	 */
11
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
12
+	{
13
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
14
+		$this->setSchemaType('boolean');
15
+	}
16 16
 
17
-    /**
18
-     * Double-checks the value being returned is an boolean.
19
-     * @since 4.9.74.p
20
-     * @param mixed $value_of_field_on_model_object
21
-     * @return boolean
22
-     */
23
-    public function prepare_for_get($value_of_field_on_model_object)
24
-    {
25
-        return (bool) parent::prepare_for_get($value_of_field_on_model_object);
26
-    }
17
+	/**
18
+	 * Double-checks the value being returned is an boolean.
19
+	 * @since 4.9.74.p
20
+	 * @param mixed $value_of_field_on_model_object
21
+	 * @return boolean
22
+	 */
23
+	public function prepare_for_get($value_of_field_on_model_object)
24
+	{
25
+		return (bool) parent::prepare_for_get($value_of_field_on_model_object);
26
+	}
27 27
 
28
-    /**
29
-     * @since 4.9.74.p
30
-     * @param $value_inputted_for_field_on_model_object
31
-     * @return boolean
32
-     */
33
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
34
-    {
35
-        return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN);
36
-    }
28
+	/**
29
+	 * @since 4.9.74.p
30
+	 * @param $value_inputted_for_field_on_model_object
31
+	 * @return boolean
32
+	 */
33
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
34
+	{
35
+		return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN);
36
+	}
37 37
 
38
-    /**
39
-     * Make sure we're returning booleans
40
-     *
41
-     * @param string $value_inputted_for_field_on_model_object
42
-     * @return boolean
43
-     */
44
-    public function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
45
-    {
46
-        return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN);
47
-    }
38
+	/**
39
+	 * Make sure we're returning booleans
40
+	 *
41
+	 * @param string $value_inputted_for_field_on_model_object
42
+	 * @return boolean
43
+	 */
44
+	public function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
45
+	{
46
+		return filter_var($value_inputted_for_field_on_model_object, FILTER_VALIDATE_BOOLEAN);
47
+	}
48 48
 
49
-    /**
50
-     * Gets a nice Yes/No value for this field
51
-     *
52
-     * @param boolean $value_on_field_to_be_outputted
53
-     * @return string Yes or No
54
-     */
55
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted)
56
-    {
57
-        return apply_filters(
58
-            'FHEE__EE_Boolean_Field__prepare_for_pretty_echoing__return',
59
-            $value_on_field_to_be_outputted ? __('Yes', 'event_espresso') : __('No', 'event_espresso'),
60
-            $value_on_field_to_be_outputted
61
-        );
62
-    }
49
+	/**
50
+	 * Gets a nice Yes/No value for this field
51
+	 *
52
+	 * @param boolean $value_on_field_to_be_outputted
53
+	 * @return string Yes or No
54
+	 */
55
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted)
56
+	{
57
+		return apply_filters(
58
+			'FHEE__EE_Boolean_Field__prepare_for_pretty_echoing__return',
59
+			$value_on_field_to_be_outputted ? __('Yes', 'event_espresso') : __('No', 'event_espresso'),
60
+			$value_on_field_to_be_outputted
61
+		);
62
+	}
63 63
 }
Please login to merge, or discard this patch.
core/db_models/EEM_WP_User.model.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -13,132 +13,132 @@
 block discarded – undo
13 13
 class EEM_WP_User extends EEM_Base
14 14
 {
15 15
 
16
-    /**
17
-     * private instance of the EEM_WP_User object
18
-     *
19
-     * @type EEM_WP_User
20
-     */
21
-    protected static $_instance;
16
+	/**
17
+	 * private instance of the EEM_WP_User object
18
+	 *
19
+	 * @type EEM_WP_User
20
+	 */
21
+	protected static $_instance;
22 22
 
23 23
 
24
-    /**
25
-     *    constructor
26
-     *
27
-     * @param null              $timezone
28
-     * @param ModelFieldFactory $model_field_factory
29
-     * @throws EE_Error
30
-     * @throws InvalidArgumentException
31
-     */
32
-    protected function __construct($timezone = null, ModelFieldFactory $model_field_factory)
33
-    {
34
-        $this->singular_item = esc_html__('WP_User', 'event_espresso');
35
-        $this->plural_item = esc_html__('WP_Users', 'event_espresso');
36
-        global $wpdb;
37
-        $this->_tables = array(
38
-            'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true),
39
-        );
40
-        $this->_fields = array(
41
-            'WP_User' => array(
42
-                'ID'                  => $model_field_factory->createPrimaryKeyIntField(
43
-                    'ID',
44
-                    esc_html__('WP_User ID', 'event_espresso')
45
-                ),
46
-                'user_login'          => $model_field_factory->createPlainTextField(
47
-                    'user_login',
48
-                    esc_html__('User Login', 'event_espresso'),
49
-                    false
50
-                ),
51
-                'user_pass'           => $model_field_factory->createPlainTextField(
52
-                    'user_pass',
53
-                    esc_html__('User Password', 'event_espresso'),
54
-                    false
55
-                ),
56
-                'user_nicename'       => $model_field_factory->createPlainTextField(
57
-                    'user_nicename',
58
-                    esc_html__(' User Nice Name', 'event_espresso'),
59
-                    false
60
-                ),
61
-                'user_email'          => $model_field_factory->createEmailField(
62
-                    'user_email',
63
-                    esc_html__('User Email', 'event_espresso'),
64
-                    false
65
-                ),
66
-                'user_registered'     => $model_field_factory->createDatetimeField(
67
-                    'user_registered',
68
-                    esc_html__('Date User Registered', 'event_espresso'),
69
-                    $timezone
70
-                ),
71
-                'user_activation_key' => $model_field_factory->createPlainTextField(
72
-                    'user_activation_key',
73
-                    esc_html__('User Activation Key', 'event_espresso'),
74
-                    false
75
-                ),
76
-                'user_status'         => $model_field_factory->createIntegerField(
77
-                    'user_status',
78
-                    esc_html__('User Status', 'event_espresso')
79
-                ),
80
-                'display_name'        => $model_field_factory->createPlainTextField(
81
-                    'display_name',
82
-                    esc_html__('Display Name', 'event_espresso'),
83
-                    false
84
-                ),
85
-            ),
86
-        );
87
-        $this->_model_relations = array(
88
-            'Attendee'       => new EE_Has_Many_Relation(),
89
-            // all models are related to the change log
90
-            // 'Change_Log'     => new EE_Has_Many_Relation(),
91
-            'Event'          => new EE_Has_Many_Relation(),
92
-            'Message'        => new EE_Has_Many_Relation(),
93
-            'Payment_Method' => new EE_Has_Many_Relation(),
94
-            'Price'          => new EE_Has_Many_Relation(),
95
-            'Price_Type'     => new EE_Has_Many_Relation(),
96
-            'Question'       => new EE_Has_Many_Relation(),
97
-            'Question_Group' => new EE_Has_Many_Relation(),
98
-            'Ticket'         => new EE_Has_Many_Relation(),
99
-            'Venue'          => new EE_Has_Many_Relation(),
100
-        );
101
-        $this->foreign_key_aliases = [
102
-            'Event.EVT_wp_user'          => 'WP_User.ID',
103
-            'Payment_Method.PMD_wp_user' => 'WP_User.ID',
104
-            'Price.PRC_wp_user'          => 'WP_User.ID',
105
-            'Price_Type.PRT_wp_user'     => 'WP_User.ID',
106
-            'Question.QST_wp_user'       => 'WP_User.ID',
107
-            'Question_Group.QSG_wp_user' => 'WP_User.ID',
108
-            'Ticket.VNU_wp_user'         => 'WP_User.ID',
109
-            'Venue.TKT_wp_user'          => 'WP_User.ID',
110
-        ];
111
-        $this->_wp_core_model = true;
112
-        $this->_caps_slug = 'users';
113
-        $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list';
114
-        $this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list';
115
-        foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
116
-            $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User();
117
-        }
118
-        // @todo: account for create_users controls whether they can create users at all
119
-        parent::__construct($timezone);
120
-    }
24
+	/**
25
+	 *    constructor
26
+	 *
27
+	 * @param null              $timezone
28
+	 * @param ModelFieldFactory $model_field_factory
29
+	 * @throws EE_Error
30
+	 * @throws InvalidArgumentException
31
+	 */
32
+	protected function __construct($timezone = null, ModelFieldFactory $model_field_factory)
33
+	{
34
+		$this->singular_item = esc_html__('WP_User', 'event_espresso');
35
+		$this->plural_item = esc_html__('WP_Users', 'event_espresso');
36
+		global $wpdb;
37
+		$this->_tables = array(
38
+			'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true),
39
+		);
40
+		$this->_fields = array(
41
+			'WP_User' => array(
42
+				'ID'                  => $model_field_factory->createPrimaryKeyIntField(
43
+					'ID',
44
+					esc_html__('WP_User ID', 'event_espresso')
45
+				),
46
+				'user_login'          => $model_field_factory->createPlainTextField(
47
+					'user_login',
48
+					esc_html__('User Login', 'event_espresso'),
49
+					false
50
+				),
51
+				'user_pass'           => $model_field_factory->createPlainTextField(
52
+					'user_pass',
53
+					esc_html__('User Password', 'event_espresso'),
54
+					false
55
+				),
56
+				'user_nicename'       => $model_field_factory->createPlainTextField(
57
+					'user_nicename',
58
+					esc_html__(' User Nice Name', 'event_espresso'),
59
+					false
60
+				),
61
+				'user_email'          => $model_field_factory->createEmailField(
62
+					'user_email',
63
+					esc_html__('User Email', 'event_espresso'),
64
+					false
65
+				),
66
+				'user_registered'     => $model_field_factory->createDatetimeField(
67
+					'user_registered',
68
+					esc_html__('Date User Registered', 'event_espresso'),
69
+					$timezone
70
+				),
71
+				'user_activation_key' => $model_field_factory->createPlainTextField(
72
+					'user_activation_key',
73
+					esc_html__('User Activation Key', 'event_espresso'),
74
+					false
75
+				),
76
+				'user_status'         => $model_field_factory->createIntegerField(
77
+					'user_status',
78
+					esc_html__('User Status', 'event_espresso')
79
+				),
80
+				'display_name'        => $model_field_factory->createPlainTextField(
81
+					'display_name',
82
+					esc_html__('Display Name', 'event_espresso'),
83
+					false
84
+				),
85
+			),
86
+		);
87
+		$this->_model_relations = array(
88
+			'Attendee'       => new EE_Has_Many_Relation(),
89
+			// all models are related to the change log
90
+			// 'Change_Log'     => new EE_Has_Many_Relation(),
91
+			'Event'          => new EE_Has_Many_Relation(),
92
+			'Message'        => new EE_Has_Many_Relation(),
93
+			'Payment_Method' => new EE_Has_Many_Relation(),
94
+			'Price'          => new EE_Has_Many_Relation(),
95
+			'Price_Type'     => new EE_Has_Many_Relation(),
96
+			'Question'       => new EE_Has_Many_Relation(),
97
+			'Question_Group' => new EE_Has_Many_Relation(),
98
+			'Ticket'         => new EE_Has_Many_Relation(),
99
+			'Venue'          => new EE_Has_Many_Relation(),
100
+		);
101
+		$this->foreign_key_aliases = [
102
+			'Event.EVT_wp_user'          => 'WP_User.ID',
103
+			'Payment_Method.PMD_wp_user' => 'WP_User.ID',
104
+			'Price.PRC_wp_user'          => 'WP_User.ID',
105
+			'Price_Type.PRT_wp_user'     => 'WP_User.ID',
106
+			'Question.QST_wp_user'       => 'WP_User.ID',
107
+			'Question_Group.QSG_wp_user' => 'WP_User.ID',
108
+			'Ticket.VNU_wp_user'         => 'WP_User.ID',
109
+			'Venue.TKT_wp_user'          => 'WP_User.ID',
110
+		];
111
+		$this->_wp_core_model = true;
112
+		$this->_caps_slug = 'users';
113
+		$this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read ] = 'list';
114
+		$this->_cap_contexts_to_cap_action_map[ EEM_Base::caps_read_admin ] = 'list';
115
+		foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
116
+			$this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_WP_User();
117
+		}
118
+		// @todo: account for create_users controls whether they can create users at all
119
+		parent::__construct($timezone);
120
+	}
121 121
 
122 122
 
123
-    /**
124
-     * We don't need a foreign key to the WP_User model, we just need its primary key
125
-     *
126
-     * @return string
127
-     * @throws EE_Error
128
-     */
129
-    public function wp_user_field_name()
130
-    {
131
-        return $this->primary_key_name();
132
-    }
123
+	/**
124
+	 * We don't need a foreign key to the WP_User model, we just need its primary key
125
+	 *
126
+	 * @return string
127
+	 * @throws EE_Error
128
+	 */
129
+	public function wp_user_field_name()
130
+	{
131
+		return $this->primary_key_name();
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * This WP_User model IS owned, even though it doesn't have a foreign key to itself
137
-     *
138
-     * @return boolean
139
-     */
140
-    public function is_owned()
141
-    {
142
-        return true;
143
-    }
135
+	/**
136
+	 * This WP_User model IS owned, even though it doesn't have a foreign key to itself
137
+	 *
138
+	 * @return boolean
139
+	 */
140
+	public function is_owned()
141
+	{
142
+		return true;
143
+	}
144 144
 }
Please login to merge, or discard this patch.
modules/add_new_state/EED_Add_New_State.module.php 2 patches
Indentation   +819 added lines, -819 removed lines patch added patch discarded remove patch
@@ -19,823 +19,823 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * @return EED_Module|EED_Add_New_State
24
-     */
25
-    public static function instance()
26
-    {
27
-        return parent::get_instance(__CLASS__);
28
-    }
29
-
30
-
31
-    /**
32
-     * set_hooks - for hooking into EE Core, other modules, etc
33
-     *
34
-     * @return void
35
-     */
36
-    public static function set_hooks()
37
-    {
38
-        add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
39
-        add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
40
-        add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
41
-        add_filter(
42
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
43
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
44
-            1,
45
-            1
46
-        );
47
-        add_filter(
48
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
49
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
50
-            1,
51
-            1
52
-        );
53
-        add_filter(
54
-            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
55
-            array('EED_Add_New_State', 'unset_new_state_request_params'),
56
-            10,
57
-            1
58
-        );
59
-        add_filter(
60
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
61
-            array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
62
-            10,
63
-            5
64
-        );
65
-        add_filter(
66
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
67
-            array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
68
-            10,
69
-            5
70
-        );
71
-        add_filter(
72
-            'FHEE__EE_State_Select_Input____construct__state_options',
73
-            array('EED_Add_New_State', 'state_options'),
74
-            10,
75
-            1
76
-        );
77
-        add_filter(
78
-            'FHEE__EE_Country_Select_Input____construct__country_options',
79
-            array('EED_Add_New_State', 'country_options'),
80
-            10,
81
-            1
82
-        );
83
-    }
84
-
85
-
86
-    /**
87
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
88
-     *
89
-     * @return void
90
-     */
91
-    public static function set_hooks_admin()
92
-    {
93
-        add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
94
-        add_filter(
95
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
96
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
97
-            1,
98
-            1
99
-        );
100
-        add_filter(
101
-            'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
102
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'),
103
-            1,
104
-            1
105
-        );
106
-        add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
107
-        add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
108
-        add_filter(
109
-            'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
110
-            array('EED_Add_New_State', 'unset_new_state_request_params'),
111
-            10,
112
-            1
113
-        );
114
-        add_action(
115
-            'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
116
-            array('EED_Add_New_State', 'update_country_settings'),
117
-            10,
118
-            3
119
-        );
120
-        add_action(
121
-            'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
122
-            array('EED_Add_New_State', 'update_country_settings'),
123
-            10,
124
-            3
125
-        );
126
-        add_filter(
127
-            'FHEE__EE_State_Select_Input____construct__state_options',
128
-            array('EED_Add_New_State', 'state_options'),
129
-            10,
130
-            1
131
-        );
132
-        add_filter(
133
-            'FHEE__EE_Country_Select_Input____construct__country_options',
134
-            array('EED_Add_New_State', 'country_options'),
135
-            10,
136
-            1
137
-        );
138
-        add_filter(
139
-            'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
140
-            array('EED_Add_New_State', 'filter_checkout_request_params'),
141
-            10,
142
-            1
143
-        );
144
-        add_filter(
145
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
146
-            array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
147
-            10,
148
-            5
149
-        );
150
-        add_filter(
151
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
152
-            array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
153
-            10,
154
-            5
155
-        );
156
-    }
157
-
158
-
159
-    /**
160
-     * @return void
161
-     */
162
-    public static function set_definitions()
163
-    {
164
-        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
165
-        define(
166
-            'ANS_TEMPLATES_PATH',
167
-            str_replace(
168
-                '\\',
169
-                '/',
170
-                plugin_dir_path(__FILE__)
171
-            ) . 'templates/'
172
-        );
173
-    }
174
-
175
-
176
-    /**
177
-     * @param WP $WP
178
-     * @return void
179
-     */
180
-    public function run($WP)
181
-    {
182
-    }
183
-
184
-
185
-    /**
186
-     * @return void
187
-     */
188
-    public static function translate_js_strings()
189
-    {
190
-        EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__(
191
-            'In order to proceed, you need to select the Country that your State/Province belongs to.',
192
-            'event_espresso'
193
-        );
194
-        EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__(
195
-            'In order to proceed, you need to enter the name of your State/Province.',
196
-            'event_espresso'
197
-        );
198
-        EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__(
199
-            'In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
200
-            'event_espresso'
201
-        );
202
-        EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__(
203
-            'The new state was successfully saved to the database.',
204
-            'event_espresso'
205
-        );
206
-        EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__(
207
-            'An unknown error has occurred on the server while saving the new state to the database.',
208
-            'event_espresso'
209
-        );
210
-    }
211
-
212
-
213
-    /**
214
-     * @return void
215
-     */
216
-    public static function wp_enqueue_scripts()
217
-    {
218
-        if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
219
-            wp_register_script(
220
-                'add_new_state',
221
-                ANS_ASSETS_URL . 'add_new_state.js',
222
-                array('espresso_core', 'single_page_checkout'),
223
-                EVENT_ESPRESSO_VERSION,
224
-                true
225
-            );
226
-            wp_enqueue_script('add_new_state');
227
-        }
228
-    }
229
-
230
-
231
-
232
-    /**
233
-     * display_add_new_state_micro_form
234
-     *
235
-     * @param EE_Form_Section_Proper $question_group_reg_form
236
-     * @return string
237
-     * @throws EE_Error
238
-     * @throws InvalidArgumentException
239
-     * @throws InvalidDataTypeException
240
-     * @throws InvalidInterfaceException
241
-     */
242
-    public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
243
-    {
244
-        // only add the 'new_state_micro_form' when displaying reg forms,
245
-        // not during processing since we process the 'new_state_micro_form' in it's own AJAX request
246
-        $action = EE_Registry::instance()->REQ->get('action', '');
247
-        // is the "state" question in this form section?
248
-        $input = $question_group_reg_form->get_subsection('state');
249
-        if ($action === 'process_reg_step' || $action === 'update_reg_step') {
250
-            // ok then all we need to do is make sure the input's HTML name is consistent
251
-            // by forcing it to set it now, like it did while getting the form for display
252
-            if ($input instanceof EE_State_Select_Input) {
253
-                $input->html_name();
254
-            }
255
-            return $question_group_reg_form;
256
-        }
257
-        // we're only doing this for state select inputs
258
-        if (
259
-            $input instanceof EE_State_Select_Input
260
-            && ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy
261
-        ) {
262
-            // grab any set values from the request
263
-            $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
264
-            $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
265
-            $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
266
-            $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
267
-            $country_options = array();
268
-            $countries = EEM_Country::instance()->get_all_countries();
269
-            if (! empty($countries)) {
270
-                foreach ($countries as $country) {
271
-                    if ($country instanceof EE_Country) {
272
-                        $country_options[ $country->ID() ] = $country->name();
273
-                    }
274
-                }
275
-            }
276
-            $new_state_micro_form = new EE_Form_Section_Proper(
277
-                array(
278
-                    'name'            => 'new_state_micro_form',
279
-                    'html_id'         => 'new_state_micro_form',
280
-                    'layout_strategy' => new EE_Div_Per_Section_Layout(),
281
-                    'subsections'     => array(
282
-                        // add hidden input to indicate that a new state is being added
283
-                        'add_new_state'               => new EE_Hidden_Input(
284
-                            array(
285
-                                'html_name' => str_replace(
286
-                                    'state',
287
-                                    'nsmf_add_new_state',
288
-                                    $input->html_name()
289
-                                ),
290
-                                'html_id'   => str_replace(
291
-                                    'state',
292
-                                    'nsmf_add_new_state',
293
-                                    $input->html_id()
294
-                                ),
295
-                                'default'   => 0,
296
-                            )
297
-                        ),
298
-                        // add link for displaying hidden container
299
-                        'click_here_link'             => new EE_Form_Section_HTML(
300
-                            apply_filters(
301
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
302
-                                EEH_HTML::link(
303
-                                    '',
304
-                                    esc_html__('click here to add a new state/province', 'event_espresso'),
305
-                                    '',
306
-                                    'display-' . $input->html_id(),
307
-                                    'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
308
-                                    '',
309
-                                    'data-target="' . $input->html_id() . '"'
310
-                                )
311
-                            )
312
-                        ),
313
-                        // add initial html for hidden container
314
-                        'add_new_state_micro_form'    => new EE_Form_Section_HTML(
315
-                            apply_filters(
316
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
317
-                                EEH_HTML::div(
318
-                                    '',
319
-                                    $input->html_id() . '-dv',
320
-                                    'ee-form-add-new-state-dv',
321
-                                    'display: none;'
322
-                                ) .
323
-                                EEH_HTML::h6(
324
-                                    esc_html__(
325
-                                        'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
326
-                                        'event_espresso'
327
-                                    )
328
-                                ) .
329
-                                EEH_HTML::ul() .
330
-                                EEH_HTML::li(
331
-                                    esc_html__(
332
-                                        'first select the Country that your State/Province belongs to',
333
-                                        'event_espresso'
334
-                                    )
335
-                                ) .
336
-                                EEH_HTML::li(
337
-                                    esc_html__('enter the name of your State/Province', 'event_espresso')
338
-                                ) .
339
-                                EEH_HTML::li(
340
-                                    esc_html__(
341
-                                        'enter a two to six letter abbreviation for the name of your State/Province',
342
-                                        'event_espresso'
343
-                                    )
344
-                                ) .
345
-                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
346
-                                EEH_HTML::ulx()
347
-                            )
348
-                        ),
349
-                        // NEW STATE COUNTRY
350
-                        'new_state_country'           => new EE_Country_Select_Input(
351
-                            $country_options,
352
-                            array(
353
-                                'html_name'       => $country_name,
354
-                                'html_id'         => str_replace(
355
-                                    'state',
356
-                                    'nsmf_new_state_country',
357
-                                    $input->html_id()
358
-                                ),
359
-                                'html_class'      => $input->html_class() . ' new-state-country',
360
-                                'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
361
-                                'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
362
-                                'required'        => false,
363
-                            )
364
-                        ),
365
-                        // NEW STATE NAME
366
-                        'new_state_name'              => new EE_Text_Input(
367
-                            array(
368
-                                'html_name'       => $state_name,
369
-                                'html_id'         => str_replace(
370
-                                    'state',
371
-                                    'nsmf_new_state_name',
372
-                                    $input->html_id()
373
-                                ),
374
-                                'html_class'      => $input->html_class() . ' new-state-state',
375
-                                'html_label_text' => esc_html__(
376
-                                    'New State/Province Name',
377
-                                    'event_espresso'
378
-                                ),
379
-                                'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
380
-                                'required'        => false,
381
-                            )
382
-                        ),
383
-                        'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
384
-                        // NEW STATE NAME
385
-                        'new_state_abbrv'             => new EE_Text_Input(
386
-                            array(
387
-                                'html_name'             => $abbrv_name,
388
-                                'html_id'               => str_replace(
389
-                                    'state',
390
-                                    'nsmf_new_state_abbrv',
391
-                                    $input->html_id()
392
-                                ),
393
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
394
-                                'html_label_text'       => esc_html__(
395
-                                    'New State/Province Abbreviation',
396
-                                    'event_espresso'
397
-                                ) . ' *',
398
-                                'other_html_attributes' => 'size="24"',
399
-                                'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
400
-                                'required'              => false,
401
-                            )
402
-                        ),
403
-                        // "submit" button
404
-                        'add_new_state_submit_button' => new EE_Form_Section_HTML(
405
-                            apply_filters(
406
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
407
-                                EEH_HTML::nbsp(3) .
408
-                                EEH_HTML::link(
409
-                                    '',
410
-                                    esc_html__('ADD', 'event_espresso'),
411
-                                    '',
412
-                                    'submit-' . $new_state_submit_id,
413
-                                    'ee-form-add-new-state-submit button button-secondary',
414
-                                    '',
415
-                                    'data-target="' . $new_state_submit_id . '" data-value-field-name="' . $input->valueFieldName() . '"'
416
-                                )
417
-                            )
418
-                        ),
419
-                        // extra info
420
-                        'add_new_state_extra'         => new EE_Form_Section_HTML(
421
-                            apply_filters(
422
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
423
-                                EEH_HTML::br(2)
424
-                                .
425
-                                EEH_HTML::div('', '', 'small-text')
426
-                                .
427
-                                EEH_HTML::strong(
428
-                                    '* ' .
429
-                                    esc_html__(
430
-                                        'Don\'t know your State/Province Abbreviation?',
431
-                                        'event_espresso'
432
-                                    )
433
-                                )
434
-                                .
435
-                                EEH_HTML::br()
436
-                                .
437
-                                sprintf(
438
-                                    esc_html__(
439
-                                        'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
440
-                                        'event_espresso'
441
-                                    ),
442
-                                    EEH_HTML::link(
443
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2',
444
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2',
445
-                                        '',
446
-                                        '',
447
-                                        'ee-form-add-new-state-wiki-lnk',
448
-                                        '',
449
-                                        'target="_blank"'
450
-                                    )
451
-                                )
452
-                                .
453
-                                EEH_HTML::divx()
454
-                                .
455
-                                EEH_HTML::br()
456
-                                .
457
-                                EEH_HTML::link(
458
-                                    '',
459
-                                    esc_html__('cancel new State/Province', 'event_espresso'),
460
-                                    '',
461
-                                    'hide-' . $input->html_id(),
462
-                                    'ee-form-cancel-new-state-lnk smaller-text',
463
-                                    '',
464
-                                    'data-target="' . $input->html_id() . '"'
465
-                                )
466
-                                .
467
-                                EEH_HTML::divx()
468
-                                .
469
-                                EEH_HTML::br()
470
-                            )
471
-                        ),
472
-                    ),
473
-                )
474
-            );
475
-            $question_group_reg_form->add_subsections(
476
-                array('new_state_micro_form' => $new_state_micro_form),
477
-                'state',
478
-                false
479
-            );
480
-        }
481
-        return $question_group_reg_form;
482
-    }
483
-
484
-
485
-    /**
486
-     * set_new_state_input_width
487
-     *
488
-     * @return int|string
489
-     * @throws EE_Error
490
-     * @throws InvalidArgumentException
491
-     * @throws InvalidDataTypeException
492
-     * @throws InvalidInterfaceException
493
-     * @throws ReflectionException
494
-     */
495
-    public static function add_new_state()
496
-    {
497
-        $REQ = EE_Registry::instance()->load_core('Request_Handler');
498
-        if (absint($REQ->get('nsmf_add_new_state')) === 1) {
499
-            EE_Registry::instance()->load_model('State');
500
-            // grab country ISO code, new state name, and new state abbreviation
501
-            $state_country = $REQ->is_set('nsmf_new_state_country')
502
-                ? sanitize_text_field($REQ->get('nsmf_new_state_country'))
503
-                : false;
504
-            $state_name = $REQ->is_set('nsmf_new_state_name')
505
-                ? sanitize_text_field($REQ->get('nsmf_new_state_name'))
506
-                : false;
507
-            $state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
508
-                ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
509
-                : false;
510
-            if ($state_country && $state_name && $state_abbr) {
511
-                $new_state = EED_Add_New_State::save_new_state_to_db(
512
-                    array(
513
-                        'CNT_ISO'    => strtoupper($state_country),
514
-                        'STA_abbrev' => strtoupper($state_abbr),
515
-                        'STA_name'   => ucwords($state_name),
516
-                        'STA_active' => false,
517
-                    )
518
-                );
519
-                if ($new_state instanceof EE_State) {
520
-                    // clean house
521
-                    EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
522
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
523
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
524
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
525
-                    // get any existing new states
526
-                    $new_states = EE_Registry::instance()->SSN->get_session_data(
527
-                        'nsmf_new_states'
528
-                    );
529
-                    $new_states[ $new_state->ID() ] = $new_state;
530
-                    EE_Registry::instance()->SSN->set_session_data(
531
-                        array('nsmf_new_states' => $new_states)
532
-                    );
533
-                    if (EE_Registry::instance()->REQ->ajax) {
534
-                        echo wp_json_encode(
535
-                            array(
536
-                                'success'      => true,
537
-                                'id'           => $new_state->ID(),
538
-                                'name'         => $new_state->name(),
539
-                                'abbrev'       => $new_state->abbrev(),
540
-                                'country_iso'  => $new_state->country_iso(),
541
-                                'country_name' => $new_state->country()->name(),
542
-                            )
543
-                        );
544
-                        exit();
545
-                    }
546
-                    return $new_state->ID();
547
-                }
548
-            } else {
549
-                $error = esc_html__(
550
-                    'A new State/Province could not be added because invalid or missing data was received.',
551
-                    'event_espresso'
552
-                );
553
-                if (EE_Registry::instance()->REQ->ajax) {
554
-                    echo wp_json_encode(array('error' => $error));
555
-                    exit();
556
-                }
557
-                EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
558
-            }
559
-        }
560
-        return false;
561
-    }
562
-
563
-
564
-    /**
565
-     * recursively drills down through request params to remove any that were added by this module
566
-     *
567
-     * @param array $request_params
568
-     * @return array
569
-     */
570
-    public static function filter_checkout_request_params($request_params)
571
-    {
572
-        foreach ($request_params as $form_section) {
573
-            if (is_array($form_section)) {
574
-                EED_Add_New_State::unset_new_state_request_params($form_section);
575
-                EED_Add_New_State::filter_checkout_request_params($form_section);
576
-            }
577
-        }
578
-        return $request_params;
579
-    }
580
-
581
-
582
-    /**
583
-     * @param array $request_params
584
-     * @return array
585
-     */
586
-    public static function unset_new_state_request_params($request_params)
587
-    {
588
-        unset(
589
-            $request_params['new_state_micro_form'],
590
-            $request_params['new_state_micro_add_new_state'],
591
-            $request_params['new_state_micro_new_state_country'],
592
-            $request_params['new_state_micro_new_state_name'],
593
-            $request_params['new_state_micro_new_state_abbrv']
594
-        );
595
-        return $request_params;
596
-    }
597
-
598
-
599
-    /**
600
-     * @param array $props_n_values
601
-     * @return bool
602
-     * @throws EE_Error
603
-     * @throws InvalidArgumentException
604
-     * @throws InvalidDataTypeException
605
-     * @throws InvalidInterfaceException
606
-     */
607
-    public static function save_new_state_to_db($props_n_values = array())
608
-    {
609
-        $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
610
-        if (! empty($existing_state)) {
611
-            return array_pop($existing_state);
612
-        }
613
-        $new_state = EE_State::new_instance($props_n_values);
614
-        if ($new_state instanceof EE_State) {
615
-            $country_settings_url = add_query_arg(
616
-                array(
617
-                    'page'    => 'espresso_general_settings',
618
-                    'action'  => 'country_settings',
619
-                    'country' => $new_state->country_iso(),
620
-                ),
621
-                admin_url('admin.php')
622
-            );
623
-            // if not non-ajax admin
624
-            new PersistentAdminNotice(
625
-                'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
626
-                sprintf(
627
-                    esc_html__(
628
-                        'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.',
629
-                        'event_espresso'
630
-                    ),
631
-                    '<b>' . $new_state->name() . '</b>',
632
-                    '<b>' . $new_state->abbrev() . '</b>',
633
-                    '<b>' . $new_state->country()->name() . '</b>',
634
-                    '<a href="'
635
-                    . $country_settings_url
636
-                    . '">'
637
-                    . esc_html__(
638
-                        'Event Espresso - General Settings > Countries Tab',
639
-                        'event_espresso'
640
-                    )
641
-                    . '</a>',
642
-                    '<br />'
643
-                )
644
-            );
645
-            $new_state->save();
646
-            EEM_State::instance()->reset_cached_states();
647
-            return $new_state;
648
-        }
649
-        return false;
650
-    }
651
-
652
-
653
-    /**
654
-     * @param string $CNT_ISO
655
-     * @param string $STA_ID
656
-     * @param array  $cols_n_values
657
-     * @return void
658
-     * @throws DomainException
659
-     * @throws EE_Error
660
-     * @throws InvalidArgumentException
661
-     * @throws InvalidDataTypeException
662
-     * @throws InvalidInterfaceException
663
-     */
664
-    public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
665
-    {
666
-        if (! $CNT_ISO) {
667
-            EE_Error::add_error(
668
-                esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
669
-                __FILE__,
670
-                __FUNCTION__,
671
-                __LINE__
672
-            );
673
-        }
674
-        $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
675
-            : false;
676
-        if (! $STA_abbrev && ! empty($STA_ID)) {
677
-            $state = EEM_State::instance()->get_one_by_ID($STA_ID);
678
-            if ($state instanceof EE_State) {
679
-                $STA_abbrev = $state->abbrev();
680
-            }
681
-        }
682
-        if (! $STA_abbrev) {
683
-            EE_Error::add_error(
684
-                esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
685
-                __FILE__,
686
-                __FUNCTION__,
687
-                __LINE__
688
-            );
689
-        }
690
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
691
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
692
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
693
-        );
694
-        $persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
695
-    }
696
-
697
-
698
-    /**
699
-     * @param EE_State[]                            $state_options
700
-     * @param EE_SPCO_Reg_Step_Attendee_Information|StateOptions $deprecated
701
-     * @param EE_Registration                       $registration
702
-     * @param EE_Question                           $question
703
-     * @param                                       $answer
704
-     * @return array
705
-     * @throws EE_Error
706
-     * @throws InvalidArgumentException
707
-     * @throws InvalidDataTypeException
708
-     * @throws InvalidInterfaceException
709
-     */
710
-    public static function inject_new_reg_state_into_options(
711
-        $state_options = array(),
712
-        $deprecated,
713
-        EE_Registration $registration,
714
-        EE_Question $question,
715
-        $answer
716
-    ) {
717
-        if (
718
-            $answer instanceof EE_Answer && $question instanceof EE_Question
719
-            && $question->type() === EEM_Question::QST_type_state
720
-        ) {
721
-            $STA_ID = $answer->value();
722
-            if (! empty($STA_ID)) {
723
-                $state = EEM_State::instance()->get_one_by_ID($STA_ID);
724
-                if ($state instanceof EE_State) {
725
-                    $country = $state->country();
726
-                    if ($country instanceof EE_Country) {
727
-                        if (! isset($state_options[ $country->name() ])) {
728
-                            $state_options[ $country->name() ] = array();
729
-                        }
730
-                        if (! isset($state_options[ $country->name() ][ $STA_ID ])) {
731
-                            $state_options[ $country->name() ][ $STA_ID ] = $state->name();
732
-                        }
733
-                    }
734
-                }
735
-            }
736
-        }
737
-        return $state_options;
738
-    }
739
-
740
-
741
-    /**
742
-     * @param EE_Country[]                          $country_options
743
-     * @param EE_SPCO_Reg_Step_Attendee_Information|CountryOptions $deprecated
744
-     * @param EE_Registration                       $registration
745
-     * @param EE_Question                           $question
746
-     * @param                                       $answer
747
-     * @return array
748
-     * @throws EE_Error
749
-     * @throws InvalidArgumentException
750
-     * @throws InvalidDataTypeException
751
-     * @throws InvalidInterfaceException
752
-     * @throws ReflectionException
753
-     */
754
-    public static function inject_new_reg_country_into_options(
755
-        $country_options = array(),
756
-        $deprecated,
757
-        EE_Registration $registration,
758
-        EE_Question $question,
759
-        $answer
760
-    ) {
761
-        if (
762
-            $answer instanceof EE_Answer && $question instanceof EE_Question
763
-            && $question->type() === EEM_Question::QST_type_country
764
-        ) {
765
-            $CNT_ISO = $answer->value();
766
-            if (! empty($CNT_ISO)) {
767
-                $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
768
-                if ($country instanceof EE_Country) {
769
-                    if (! isset($country_options[ $CNT_ISO ])) {
770
-                        $country_options[ $CNT_ISO ] = $country->name();
771
-                    }
772
-                }
773
-            }
774
-        }
775
-        return $country_options;
776
-    }
777
-
778
-
779
-    /**
780
-     * @param EE_State[] $state_options
781
-     * @return array
782
-     * @throws EE_Error
783
-     * @throws InvalidArgumentException
784
-     * @throws InvalidDataTypeException
785
-     * @throws InvalidInterfaceException
786
-     */
787
-    public static function state_options($state_options = array())
788
-    {
789
-        $new_states = EED_Add_New_State::_get_new_states();
790
-        foreach ($new_states as $new_state) {
791
-            if (
792
-                $new_state instanceof EE_State
793
-                && $new_state->country() instanceof EE_Country
794
-            ) {
795
-                $state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name();
796
-            }
797
-        }
798
-        return $state_options;
799
-    }
800
-
801
-
802
-    /**
803
-     * @return array
804
-     * @throws InvalidArgumentException
805
-     * @throws InvalidDataTypeException
806
-     * @throws InvalidInterfaceException
807
-     */
808
-    protected static function _get_new_states()
809
-    {
810
-        $new_states = array();
811
-        if (EE_Registry::instance()->SSN instanceof EE_Session) {
812
-            $new_states = EE_Registry::instance()->SSN->get_session_data(
813
-                'nsmf_new_states'
814
-            );
815
-        }
816
-        return is_array($new_states) ? $new_states : array();
817
-    }
818
-
819
-
820
-    /**
821
-     * @param EE_Country[] $country_options
822
-     * @return array
823
-     * @throws EE_Error
824
-     * @throws InvalidArgumentException
825
-     * @throws InvalidDataTypeException
826
-     * @throws InvalidInterfaceException
827
-     */
828
-    public static function country_options($country_options = array())
829
-    {
830
-        $new_states = EED_Add_New_State::_get_new_states();
831
-        foreach ($new_states as $new_state) {
832
-            if (
833
-                $new_state instanceof EE_State
834
-                && $new_state->country() instanceof EE_Country
835
-            ) {
836
-                $country_options[ $new_state->country()->ID() ] = $new_state->country()->name();
837
-            }
838
-        }
839
-        return $country_options;
840
-    }
22
+	/**
23
+	 * @return EED_Module|EED_Add_New_State
24
+	 */
25
+	public static function instance()
26
+	{
27
+		return parent::get_instance(__CLASS__);
28
+	}
29
+
30
+
31
+	/**
32
+	 * set_hooks - for hooking into EE Core, other modules, etc
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public static function set_hooks()
37
+	{
38
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
39
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
40
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
41
+		add_filter(
42
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
43
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
44
+			1,
45
+			1
46
+		);
47
+		add_filter(
48
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
49
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
50
+			1,
51
+			1
52
+		);
53
+		add_filter(
54
+			'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
55
+			array('EED_Add_New_State', 'unset_new_state_request_params'),
56
+			10,
57
+			1
58
+		);
59
+		add_filter(
60
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
61
+			array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
62
+			10,
63
+			5
64
+		);
65
+		add_filter(
66
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
67
+			array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
68
+			10,
69
+			5
70
+		);
71
+		add_filter(
72
+			'FHEE__EE_State_Select_Input____construct__state_options',
73
+			array('EED_Add_New_State', 'state_options'),
74
+			10,
75
+			1
76
+		);
77
+		add_filter(
78
+			'FHEE__EE_Country_Select_Input____construct__country_options',
79
+			array('EED_Add_New_State', 'country_options'),
80
+			10,
81
+			1
82
+		);
83
+	}
84
+
85
+
86
+	/**
87
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
88
+	 *
89
+	 * @return void
90
+	 */
91
+	public static function set_hooks_admin()
92
+	{
93
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
94
+		add_filter(
95
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
96
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
97
+			1,
98
+			1
99
+		);
100
+		add_filter(
101
+			'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
102
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'),
103
+			1,
104
+			1
105
+		);
106
+		add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
107
+		add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
108
+		add_filter(
109
+			'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
110
+			array('EED_Add_New_State', 'unset_new_state_request_params'),
111
+			10,
112
+			1
113
+		);
114
+		add_action(
115
+			'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
116
+			array('EED_Add_New_State', 'update_country_settings'),
117
+			10,
118
+			3
119
+		);
120
+		add_action(
121
+			'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
122
+			array('EED_Add_New_State', 'update_country_settings'),
123
+			10,
124
+			3
125
+		);
126
+		add_filter(
127
+			'FHEE__EE_State_Select_Input____construct__state_options',
128
+			array('EED_Add_New_State', 'state_options'),
129
+			10,
130
+			1
131
+		);
132
+		add_filter(
133
+			'FHEE__EE_Country_Select_Input____construct__country_options',
134
+			array('EED_Add_New_State', 'country_options'),
135
+			10,
136
+			1
137
+		);
138
+		add_filter(
139
+			'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
140
+			array('EED_Add_New_State', 'filter_checkout_request_params'),
141
+			10,
142
+			1
143
+		);
144
+		add_filter(
145
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
146
+			array('EED_Add_New_State', 'inject_new_reg_state_into_options'),
147
+			10,
148
+			5
149
+		);
150
+		add_filter(
151
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
152
+			array('EED_Add_New_State', 'inject_new_reg_country_into_options'),
153
+			10,
154
+			5
155
+		);
156
+	}
157
+
158
+
159
+	/**
160
+	 * @return void
161
+	 */
162
+	public static function set_definitions()
163
+	{
164
+		define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
165
+		define(
166
+			'ANS_TEMPLATES_PATH',
167
+			str_replace(
168
+				'\\',
169
+				'/',
170
+				plugin_dir_path(__FILE__)
171
+			) . 'templates/'
172
+		);
173
+	}
174
+
175
+
176
+	/**
177
+	 * @param WP $WP
178
+	 * @return void
179
+	 */
180
+	public function run($WP)
181
+	{
182
+	}
183
+
184
+
185
+	/**
186
+	 * @return void
187
+	 */
188
+	public static function translate_js_strings()
189
+	{
190
+		EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__(
191
+			'In order to proceed, you need to select the Country that your State/Province belongs to.',
192
+			'event_espresso'
193
+		);
194
+		EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__(
195
+			'In order to proceed, you need to enter the name of your State/Province.',
196
+			'event_espresso'
197
+		);
198
+		EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__(
199
+			'In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
200
+			'event_espresso'
201
+		);
202
+		EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__(
203
+			'The new state was successfully saved to the database.',
204
+			'event_espresso'
205
+		);
206
+		EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__(
207
+			'An unknown error has occurred on the server while saving the new state to the database.',
208
+			'event_espresso'
209
+		);
210
+	}
211
+
212
+
213
+	/**
214
+	 * @return void
215
+	 */
216
+	public static function wp_enqueue_scripts()
217
+	{
218
+		if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
219
+			wp_register_script(
220
+				'add_new_state',
221
+				ANS_ASSETS_URL . 'add_new_state.js',
222
+				array('espresso_core', 'single_page_checkout'),
223
+				EVENT_ESPRESSO_VERSION,
224
+				true
225
+			);
226
+			wp_enqueue_script('add_new_state');
227
+		}
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 * display_add_new_state_micro_form
234
+	 *
235
+	 * @param EE_Form_Section_Proper $question_group_reg_form
236
+	 * @return string
237
+	 * @throws EE_Error
238
+	 * @throws InvalidArgumentException
239
+	 * @throws InvalidDataTypeException
240
+	 * @throws InvalidInterfaceException
241
+	 */
242
+	public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
243
+	{
244
+		// only add the 'new_state_micro_form' when displaying reg forms,
245
+		// not during processing since we process the 'new_state_micro_form' in it's own AJAX request
246
+		$action = EE_Registry::instance()->REQ->get('action', '');
247
+		// is the "state" question in this form section?
248
+		$input = $question_group_reg_form->get_subsection('state');
249
+		if ($action === 'process_reg_step' || $action === 'update_reg_step') {
250
+			// ok then all we need to do is make sure the input's HTML name is consistent
251
+			// by forcing it to set it now, like it did while getting the form for display
252
+			if ($input instanceof EE_State_Select_Input) {
253
+				$input->html_name();
254
+			}
255
+			return $question_group_reg_form;
256
+		}
257
+		// we're only doing this for state select inputs
258
+		if (
259
+			$input instanceof EE_State_Select_Input
260
+			&& ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy
261
+		) {
262
+			// grab any set values from the request
263
+			$country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
264
+			$state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
265
+			$abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
266
+			$new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
267
+			$country_options = array();
268
+			$countries = EEM_Country::instance()->get_all_countries();
269
+			if (! empty($countries)) {
270
+				foreach ($countries as $country) {
271
+					if ($country instanceof EE_Country) {
272
+						$country_options[ $country->ID() ] = $country->name();
273
+					}
274
+				}
275
+			}
276
+			$new_state_micro_form = new EE_Form_Section_Proper(
277
+				array(
278
+					'name'            => 'new_state_micro_form',
279
+					'html_id'         => 'new_state_micro_form',
280
+					'layout_strategy' => new EE_Div_Per_Section_Layout(),
281
+					'subsections'     => array(
282
+						// add hidden input to indicate that a new state is being added
283
+						'add_new_state'               => new EE_Hidden_Input(
284
+							array(
285
+								'html_name' => str_replace(
286
+									'state',
287
+									'nsmf_add_new_state',
288
+									$input->html_name()
289
+								),
290
+								'html_id'   => str_replace(
291
+									'state',
292
+									'nsmf_add_new_state',
293
+									$input->html_id()
294
+								),
295
+								'default'   => 0,
296
+							)
297
+						),
298
+						// add link for displaying hidden container
299
+						'click_here_link'             => new EE_Form_Section_HTML(
300
+							apply_filters(
301
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
302
+								EEH_HTML::link(
303
+									'',
304
+									esc_html__('click here to add a new state/province', 'event_espresso'),
305
+									'',
306
+									'display-' . $input->html_id(),
307
+									'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
308
+									'',
309
+									'data-target="' . $input->html_id() . '"'
310
+								)
311
+							)
312
+						),
313
+						// add initial html for hidden container
314
+						'add_new_state_micro_form'    => new EE_Form_Section_HTML(
315
+							apply_filters(
316
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
317
+								EEH_HTML::div(
318
+									'',
319
+									$input->html_id() . '-dv',
320
+									'ee-form-add-new-state-dv',
321
+									'display: none;'
322
+								) .
323
+								EEH_HTML::h6(
324
+									esc_html__(
325
+										'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
326
+										'event_espresso'
327
+									)
328
+								) .
329
+								EEH_HTML::ul() .
330
+								EEH_HTML::li(
331
+									esc_html__(
332
+										'first select the Country that your State/Province belongs to',
333
+										'event_espresso'
334
+									)
335
+								) .
336
+								EEH_HTML::li(
337
+									esc_html__('enter the name of your State/Province', 'event_espresso')
338
+								) .
339
+								EEH_HTML::li(
340
+									esc_html__(
341
+										'enter a two to six letter abbreviation for the name of your State/Province',
342
+										'event_espresso'
343
+									)
344
+								) .
345
+								EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
346
+								EEH_HTML::ulx()
347
+							)
348
+						),
349
+						// NEW STATE COUNTRY
350
+						'new_state_country'           => new EE_Country_Select_Input(
351
+							$country_options,
352
+							array(
353
+								'html_name'       => $country_name,
354
+								'html_id'         => str_replace(
355
+									'state',
356
+									'nsmf_new_state_country',
357
+									$input->html_id()
358
+								),
359
+								'html_class'      => $input->html_class() . ' new-state-country',
360
+								'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
361
+								'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
362
+								'required'        => false,
363
+							)
364
+						),
365
+						// NEW STATE NAME
366
+						'new_state_name'              => new EE_Text_Input(
367
+							array(
368
+								'html_name'       => $state_name,
369
+								'html_id'         => str_replace(
370
+									'state',
371
+									'nsmf_new_state_name',
372
+									$input->html_id()
373
+								),
374
+								'html_class'      => $input->html_class() . ' new-state-state',
375
+								'html_label_text' => esc_html__(
376
+									'New State/Province Name',
377
+									'event_espresso'
378
+								),
379
+								'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
380
+								'required'        => false,
381
+							)
382
+						),
383
+						'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
384
+						// NEW STATE NAME
385
+						'new_state_abbrv'             => new EE_Text_Input(
386
+							array(
387
+								'html_name'             => $abbrv_name,
388
+								'html_id'               => str_replace(
389
+									'state',
390
+									'nsmf_new_state_abbrv',
391
+									$input->html_id()
392
+								),
393
+								'html_class'            => $input->html_class() . ' new-state-abbrv',
394
+								'html_label_text'       => esc_html__(
395
+									'New State/Province Abbreviation',
396
+									'event_espresso'
397
+								) . ' *',
398
+								'other_html_attributes' => 'size="24"',
399
+								'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
400
+								'required'              => false,
401
+							)
402
+						),
403
+						// "submit" button
404
+						'add_new_state_submit_button' => new EE_Form_Section_HTML(
405
+							apply_filters(
406
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
407
+								EEH_HTML::nbsp(3) .
408
+								EEH_HTML::link(
409
+									'',
410
+									esc_html__('ADD', 'event_espresso'),
411
+									'',
412
+									'submit-' . $new_state_submit_id,
413
+									'ee-form-add-new-state-submit button button-secondary',
414
+									'',
415
+									'data-target="' . $new_state_submit_id . '" data-value-field-name="' . $input->valueFieldName() . '"'
416
+								)
417
+							)
418
+						),
419
+						// extra info
420
+						'add_new_state_extra'         => new EE_Form_Section_HTML(
421
+							apply_filters(
422
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
423
+								EEH_HTML::br(2)
424
+								.
425
+								EEH_HTML::div('', '', 'small-text')
426
+								.
427
+								EEH_HTML::strong(
428
+									'* ' .
429
+									esc_html__(
430
+										'Don\'t know your State/Province Abbreviation?',
431
+										'event_espresso'
432
+									)
433
+								)
434
+								.
435
+								EEH_HTML::br()
436
+								.
437
+								sprintf(
438
+									esc_html__(
439
+										'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
440
+										'event_espresso'
441
+									),
442
+									EEH_HTML::link(
443
+										'http://en.wikipedia.org/wiki/ISO_3166-2',
444
+										'http://en.wikipedia.org/wiki/ISO_3166-2',
445
+										'',
446
+										'',
447
+										'ee-form-add-new-state-wiki-lnk',
448
+										'',
449
+										'target="_blank"'
450
+									)
451
+								)
452
+								.
453
+								EEH_HTML::divx()
454
+								.
455
+								EEH_HTML::br()
456
+								.
457
+								EEH_HTML::link(
458
+									'',
459
+									esc_html__('cancel new State/Province', 'event_espresso'),
460
+									'',
461
+									'hide-' . $input->html_id(),
462
+									'ee-form-cancel-new-state-lnk smaller-text',
463
+									'',
464
+									'data-target="' . $input->html_id() . '"'
465
+								)
466
+								.
467
+								EEH_HTML::divx()
468
+								.
469
+								EEH_HTML::br()
470
+							)
471
+						),
472
+					),
473
+				)
474
+			);
475
+			$question_group_reg_form->add_subsections(
476
+				array('new_state_micro_form' => $new_state_micro_form),
477
+				'state',
478
+				false
479
+			);
480
+		}
481
+		return $question_group_reg_form;
482
+	}
483
+
484
+
485
+	/**
486
+	 * set_new_state_input_width
487
+	 *
488
+	 * @return int|string
489
+	 * @throws EE_Error
490
+	 * @throws InvalidArgumentException
491
+	 * @throws InvalidDataTypeException
492
+	 * @throws InvalidInterfaceException
493
+	 * @throws ReflectionException
494
+	 */
495
+	public static function add_new_state()
496
+	{
497
+		$REQ = EE_Registry::instance()->load_core('Request_Handler');
498
+		if (absint($REQ->get('nsmf_add_new_state')) === 1) {
499
+			EE_Registry::instance()->load_model('State');
500
+			// grab country ISO code, new state name, and new state abbreviation
501
+			$state_country = $REQ->is_set('nsmf_new_state_country')
502
+				? sanitize_text_field($REQ->get('nsmf_new_state_country'))
503
+				: false;
504
+			$state_name = $REQ->is_set('nsmf_new_state_name')
505
+				? sanitize_text_field($REQ->get('nsmf_new_state_name'))
506
+				: false;
507
+			$state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
508
+				? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
509
+				: false;
510
+			if ($state_country && $state_name && $state_abbr) {
511
+				$new_state = EED_Add_New_State::save_new_state_to_db(
512
+					array(
513
+						'CNT_ISO'    => strtoupper($state_country),
514
+						'STA_abbrev' => strtoupper($state_abbr),
515
+						'STA_name'   => ucwords($state_name),
516
+						'STA_active' => false,
517
+					)
518
+				);
519
+				if ($new_state instanceof EE_State) {
520
+					// clean house
521
+					EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
522
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
523
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
524
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
525
+					// get any existing new states
526
+					$new_states = EE_Registry::instance()->SSN->get_session_data(
527
+						'nsmf_new_states'
528
+					);
529
+					$new_states[ $new_state->ID() ] = $new_state;
530
+					EE_Registry::instance()->SSN->set_session_data(
531
+						array('nsmf_new_states' => $new_states)
532
+					);
533
+					if (EE_Registry::instance()->REQ->ajax) {
534
+						echo wp_json_encode(
535
+							array(
536
+								'success'      => true,
537
+								'id'           => $new_state->ID(),
538
+								'name'         => $new_state->name(),
539
+								'abbrev'       => $new_state->abbrev(),
540
+								'country_iso'  => $new_state->country_iso(),
541
+								'country_name' => $new_state->country()->name(),
542
+							)
543
+						);
544
+						exit();
545
+					}
546
+					return $new_state->ID();
547
+				}
548
+			} else {
549
+				$error = esc_html__(
550
+					'A new State/Province could not be added because invalid or missing data was received.',
551
+					'event_espresso'
552
+				);
553
+				if (EE_Registry::instance()->REQ->ajax) {
554
+					echo wp_json_encode(array('error' => $error));
555
+					exit();
556
+				}
557
+				EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
558
+			}
559
+		}
560
+		return false;
561
+	}
562
+
563
+
564
+	/**
565
+	 * recursively drills down through request params to remove any that were added by this module
566
+	 *
567
+	 * @param array $request_params
568
+	 * @return array
569
+	 */
570
+	public static function filter_checkout_request_params($request_params)
571
+	{
572
+		foreach ($request_params as $form_section) {
573
+			if (is_array($form_section)) {
574
+				EED_Add_New_State::unset_new_state_request_params($form_section);
575
+				EED_Add_New_State::filter_checkout_request_params($form_section);
576
+			}
577
+		}
578
+		return $request_params;
579
+	}
580
+
581
+
582
+	/**
583
+	 * @param array $request_params
584
+	 * @return array
585
+	 */
586
+	public static function unset_new_state_request_params($request_params)
587
+	{
588
+		unset(
589
+			$request_params['new_state_micro_form'],
590
+			$request_params['new_state_micro_add_new_state'],
591
+			$request_params['new_state_micro_new_state_country'],
592
+			$request_params['new_state_micro_new_state_name'],
593
+			$request_params['new_state_micro_new_state_abbrv']
594
+		);
595
+		return $request_params;
596
+	}
597
+
598
+
599
+	/**
600
+	 * @param array $props_n_values
601
+	 * @return bool
602
+	 * @throws EE_Error
603
+	 * @throws InvalidArgumentException
604
+	 * @throws InvalidDataTypeException
605
+	 * @throws InvalidInterfaceException
606
+	 */
607
+	public static function save_new_state_to_db($props_n_values = array())
608
+	{
609
+		$existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
610
+		if (! empty($existing_state)) {
611
+			return array_pop($existing_state);
612
+		}
613
+		$new_state = EE_State::new_instance($props_n_values);
614
+		if ($new_state instanceof EE_State) {
615
+			$country_settings_url = add_query_arg(
616
+				array(
617
+					'page'    => 'espresso_general_settings',
618
+					'action'  => 'country_settings',
619
+					'country' => $new_state->country_iso(),
620
+				),
621
+				admin_url('admin.php')
622
+			);
623
+			// if not non-ajax admin
624
+			new PersistentAdminNotice(
625
+				'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
626
+				sprintf(
627
+					esc_html__(
628
+						'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.',
629
+						'event_espresso'
630
+					),
631
+					'<b>' . $new_state->name() . '</b>',
632
+					'<b>' . $new_state->abbrev() . '</b>',
633
+					'<b>' . $new_state->country()->name() . '</b>',
634
+					'<a href="'
635
+					. $country_settings_url
636
+					. '">'
637
+					. esc_html__(
638
+						'Event Espresso - General Settings > Countries Tab',
639
+						'event_espresso'
640
+					)
641
+					. '</a>',
642
+					'<br />'
643
+				)
644
+			);
645
+			$new_state->save();
646
+			EEM_State::instance()->reset_cached_states();
647
+			return $new_state;
648
+		}
649
+		return false;
650
+	}
651
+
652
+
653
+	/**
654
+	 * @param string $CNT_ISO
655
+	 * @param string $STA_ID
656
+	 * @param array  $cols_n_values
657
+	 * @return void
658
+	 * @throws DomainException
659
+	 * @throws EE_Error
660
+	 * @throws InvalidArgumentException
661
+	 * @throws InvalidDataTypeException
662
+	 * @throws InvalidInterfaceException
663
+	 */
664
+	public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
665
+	{
666
+		if (! $CNT_ISO) {
667
+			EE_Error::add_error(
668
+				esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
669
+				__FILE__,
670
+				__FUNCTION__,
671
+				__LINE__
672
+			);
673
+		}
674
+		$STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
675
+			: false;
676
+		if (! $STA_abbrev && ! empty($STA_ID)) {
677
+			$state = EEM_State::instance()->get_one_by_ID($STA_ID);
678
+			if ($state instanceof EE_State) {
679
+				$STA_abbrev = $state->abbrev();
680
+			}
681
+		}
682
+		if (! $STA_abbrev) {
683
+			EE_Error::add_error(
684
+				esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
685
+				__FILE__,
686
+				__FUNCTION__,
687
+				__LINE__
688
+			);
689
+		}
690
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
691
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
692
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
693
+		);
694
+		$persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
695
+	}
696
+
697
+
698
+	/**
699
+	 * @param EE_State[]                            $state_options
700
+	 * @param EE_SPCO_Reg_Step_Attendee_Information|StateOptions $deprecated
701
+	 * @param EE_Registration                       $registration
702
+	 * @param EE_Question                           $question
703
+	 * @param                                       $answer
704
+	 * @return array
705
+	 * @throws EE_Error
706
+	 * @throws InvalidArgumentException
707
+	 * @throws InvalidDataTypeException
708
+	 * @throws InvalidInterfaceException
709
+	 */
710
+	public static function inject_new_reg_state_into_options(
711
+		$state_options = array(),
712
+		$deprecated,
713
+		EE_Registration $registration,
714
+		EE_Question $question,
715
+		$answer
716
+	) {
717
+		if (
718
+			$answer instanceof EE_Answer && $question instanceof EE_Question
719
+			&& $question->type() === EEM_Question::QST_type_state
720
+		) {
721
+			$STA_ID = $answer->value();
722
+			if (! empty($STA_ID)) {
723
+				$state = EEM_State::instance()->get_one_by_ID($STA_ID);
724
+				if ($state instanceof EE_State) {
725
+					$country = $state->country();
726
+					if ($country instanceof EE_Country) {
727
+						if (! isset($state_options[ $country->name() ])) {
728
+							$state_options[ $country->name() ] = array();
729
+						}
730
+						if (! isset($state_options[ $country->name() ][ $STA_ID ])) {
731
+							$state_options[ $country->name() ][ $STA_ID ] = $state->name();
732
+						}
733
+					}
734
+				}
735
+			}
736
+		}
737
+		return $state_options;
738
+	}
739
+
740
+
741
+	/**
742
+	 * @param EE_Country[]                          $country_options
743
+	 * @param EE_SPCO_Reg_Step_Attendee_Information|CountryOptions $deprecated
744
+	 * @param EE_Registration                       $registration
745
+	 * @param EE_Question                           $question
746
+	 * @param                                       $answer
747
+	 * @return array
748
+	 * @throws EE_Error
749
+	 * @throws InvalidArgumentException
750
+	 * @throws InvalidDataTypeException
751
+	 * @throws InvalidInterfaceException
752
+	 * @throws ReflectionException
753
+	 */
754
+	public static function inject_new_reg_country_into_options(
755
+		$country_options = array(),
756
+		$deprecated,
757
+		EE_Registration $registration,
758
+		EE_Question $question,
759
+		$answer
760
+	) {
761
+		if (
762
+			$answer instanceof EE_Answer && $question instanceof EE_Question
763
+			&& $question->type() === EEM_Question::QST_type_country
764
+		) {
765
+			$CNT_ISO = $answer->value();
766
+			if (! empty($CNT_ISO)) {
767
+				$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
768
+				if ($country instanceof EE_Country) {
769
+					if (! isset($country_options[ $CNT_ISO ])) {
770
+						$country_options[ $CNT_ISO ] = $country->name();
771
+					}
772
+				}
773
+			}
774
+		}
775
+		return $country_options;
776
+	}
777
+
778
+
779
+	/**
780
+	 * @param EE_State[] $state_options
781
+	 * @return array
782
+	 * @throws EE_Error
783
+	 * @throws InvalidArgumentException
784
+	 * @throws InvalidDataTypeException
785
+	 * @throws InvalidInterfaceException
786
+	 */
787
+	public static function state_options($state_options = array())
788
+	{
789
+		$new_states = EED_Add_New_State::_get_new_states();
790
+		foreach ($new_states as $new_state) {
791
+			if (
792
+				$new_state instanceof EE_State
793
+				&& $new_state->country() instanceof EE_Country
794
+			) {
795
+				$state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name();
796
+			}
797
+		}
798
+		return $state_options;
799
+	}
800
+
801
+
802
+	/**
803
+	 * @return array
804
+	 * @throws InvalidArgumentException
805
+	 * @throws InvalidDataTypeException
806
+	 * @throws InvalidInterfaceException
807
+	 */
808
+	protected static function _get_new_states()
809
+	{
810
+		$new_states = array();
811
+		if (EE_Registry::instance()->SSN instanceof EE_Session) {
812
+			$new_states = EE_Registry::instance()->SSN->get_session_data(
813
+				'nsmf_new_states'
814
+			);
815
+		}
816
+		return is_array($new_states) ? $new_states : array();
817
+	}
818
+
819
+
820
+	/**
821
+	 * @param EE_Country[] $country_options
822
+	 * @return array
823
+	 * @throws EE_Error
824
+	 * @throws InvalidArgumentException
825
+	 * @throws InvalidDataTypeException
826
+	 * @throws InvalidInterfaceException
827
+	 */
828
+	public static function country_options($country_options = array())
829
+	{
830
+		$new_states = EED_Add_New_State::_get_new_states();
831
+		foreach ($new_states as $new_state) {
832
+			if (
833
+				$new_state instanceof EE_State
834
+				&& $new_state->country() instanceof EE_Country
835
+			) {
836
+				$country_options[ $new_state->country()->ID() ] = $new_state->country()->name();
837
+			}
838
+		}
839
+		return $country_options;
840
+	}
841 841
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public static function set_definitions()
163 163
     {
164
-        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
164
+        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
165 165
         define(
166 166
             'ANS_TEMPLATES_PATH',
167 167
             str_replace(
168 168
                 '\\',
169 169
                 '/',
170 170
                 plugin_dir_path(__FILE__)
171
-            ) . 'templates/'
171
+            ).'templates/'
172 172
         );
173 173
     }
174 174
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
219 219
             wp_register_script(
220 220
                 'add_new_state',
221
-                ANS_ASSETS_URL . 'add_new_state.js',
221
+                ANS_ASSETS_URL.'add_new_state.js',
222 222
                 array('espresso_core', 'single_page_checkout'),
223 223
                 EVENT_ESPRESSO_VERSION,
224 224
                 true
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
             $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
267 267
             $country_options = array();
268 268
             $countries = EEM_Country::instance()->get_all_countries();
269
-            if (! empty($countries)) {
269
+            if ( ! empty($countries)) {
270 270
                 foreach ($countries as $country) {
271 271
                     if ($country instanceof EE_Country) {
272
-                        $country_options[ $country->ID() ] = $country->name();
272
+                        $country_options[$country->ID()] = $country->name();
273 273
                     }
274 274
                 }
275 275
             }
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
                                     '',
304 304
                                     esc_html__('click here to add a new state/province', 'event_espresso'),
305 305
                                     '',
306
-                                    'display-' . $input->html_id(),
306
+                                    'display-'.$input->html_id(),
307 307
                                     'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
308 308
                                     '',
309
-                                    'data-target="' . $input->html_id() . '"'
309
+                                    'data-target="'.$input->html_id().'"'
310 310
                                 )
311 311
                             )
312 312
                         ),
@@ -316,33 +316,33 @@  discard block
 block discarded – undo
316 316
                                 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
317 317
                                 EEH_HTML::div(
318 318
                                     '',
319
-                                    $input->html_id() . '-dv',
319
+                                    $input->html_id().'-dv',
320 320
                                     'ee-form-add-new-state-dv',
321 321
                                     'display: none;'
322
-                                ) .
322
+                                ).
323 323
                                 EEH_HTML::h6(
324 324
                                     esc_html__(
325 325
                                         'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
326 326
                                         'event_espresso'
327 327
                                     )
328
-                                ) .
329
-                                EEH_HTML::ul() .
328
+                                ).
329
+                                EEH_HTML::ul().
330 330
                                 EEH_HTML::li(
331 331
                                     esc_html__(
332 332
                                         'first select the Country that your State/Province belongs to',
333 333
                                         'event_espresso'
334 334
                                     )
335
-                                ) .
335
+                                ).
336 336
                                 EEH_HTML::li(
337 337
                                     esc_html__('enter the name of your State/Province', 'event_espresso')
338
-                                ) .
338
+                                ).
339 339
                                 EEH_HTML::li(
340 340
                                     esc_html__(
341 341
                                         'enter a two to six letter abbreviation for the name of your State/Province',
342 342
                                         'event_espresso'
343 343
                                     )
344
-                                ) .
345
-                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
344
+                                ).
345
+                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')).
346 346
                                 EEH_HTML::ulx()
347 347
                             )
348 348
                         ),
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
                                     'nsmf_new_state_country',
357 357
                                     $input->html_id()
358 358
                                 ),
359
-                                'html_class'      => $input->html_class() . ' new-state-country',
359
+                                'html_class'      => $input->html_class().' new-state-country',
360 360
                                 'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
361 361
                                 'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
362 362
                                 'required'        => false,
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
                                     'nsmf_new_state_name',
372 372
                                     $input->html_id()
373 373
                                 ),
374
-                                'html_class'      => $input->html_class() . ' new-state-state',
374
+                                'html_class'      => $input->html_class().' new-state-state',
375 375
                                 'html_label_text' => esc_html__(
376 376
                                     'New State/Province Name',
377 377
                                     'event_espresso'
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
                                     'nsmf_new_state_abbrv',
391 391
                                     $input->html_id()
392 392
                                 ),
393
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
393
+                                'html_class'            => $input->html_class().' new-state-abbrv',
394 394
                                 'html_label_text'       => esc_html__(
395 395
                                     'New State/Province Abbreviation',
396 396
                                     'event_espresso'
397
-                                ) . ' *',
397
+                                ).' *',
398 398
                                 'other_html_attributes' => 'size="24"',
399 399
                                 'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
400 400
                                 'required'              => false,
@@ -404,15 +404,15 @@  discard block
 block discarded – undo
404 404
                         'add_new_state_submit_button' => new EE_Form_Section_HTML(
405 405
                             apply_filters(
406 406
                                 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
407
-                                EEH_HTML::nbsp(3) .
407
+                                EEH_HTML::nbsp(3).
408 408
                                 EEH_HTML::link(
409 409
                                     '',
410 410
                                     esc_html__('ADD', 'event_espresso'),
411 411
                                     '',
412
-                                    'submit-' . $new_state_submit_id,
412
+                                    'submit-'.$new_state_submit_id,
413 413
                                     'ee-form-add-new-state-submit button button-secondary',
414 414
                                     '',
415
-                                    'data-target="' . $new_state_submit_id . '" data-value-field-name="' . $input->valueFieldName() . '"'
415
+                                    'data-target="'.$new_state_submit_id.'" data-value-field-name="'.$input->valueFieldName().'"'
416 416
                                 )
417 417
                             )
418 418
                         ),
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
                                 EEH_HTML::div('', '', 'small-text')
426 426
                                 .
427 427
                                 EEH_HTML::strong(
428
-                                    '* ' .
428
+                                    '* '.
429 429
                                     esc_html__(
430 430
                                         'Don\'t know your State/Province Abbreviation?',
431 431
                                         'event_espresso'
@@ -458,10 +458,10 @@  discard block
 block discarded – undo
458 458
                                     '',
459 459
                                     esc_html__('cancel new State/Province', 'event_espresso'),
460 460
                                     '',
461
-                                    'hide-' . $input->html_id(),
461
+                                    'hide-'.$input->html_id(),
462 462
                                     'ee-form-cancel-new-state-lnk smaller-text',
463 463
                                     '',
464
-                                    'data-target="' . $input->html_id() . '"'
464
+                                    'data-target="'.$input->html_id().'"'
465 465
                                 )
466 466
                                 .
467 467
                                 EEH_HTML::divx()
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
                     $new_states = EE_Registry::instance()->SSN->get_session_data(
527 527
                         'nsmf_new_states'
528 528
                     );
529
-                    $new_states[ $new_state->ID() ] = $new_state;
529
+                    $new_states[$new_state->ID()] = $new_state;
530 530
                     EE_Registry::instance()->SSN->set_session_data(
531 531
                         array('nsmf_new_states' => $new_states)
532 532
                     );
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
     public static function save_new_state_to_db($props_n_values = array())
608 608
     {
609 609
         $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
610
-        if (! empty($existing_state)) {
610
+        if ( ! empty($existing_state)) {
611 611
             return array_pop($existing_state);
612 612
         }
613 613
         $new_state = EE_State::new_instance($props_n_values);
@@ -622,15 +622,15 @@  discard block
 block discarded – undo
622 622
             );
623 623
             // if not non-ajax admin
624 624
             new PersistentAdminNotice(
625
-                'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(),
625
+                'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev(),
626 626
                 sprintf(
627 627
                     esc_html__(
628 628
                         'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.',
629 629
                         'event_espresso'
630 630
                     ),
631
-                    '<b>' . $new_state->name() . '</b>',
632
-                    '<b>' . $new_state->abbrev() . '</b>',
633
-                    '<b>' . $new_state->country()->name() . '</b>',
631
+                    '<b>'.$new_state->name().'</b>',
632
+                    '<b>'.$new_state->abbrev().'</b>',
633
+                    '<b>'.$new_state->country()->name().'</b>',
634 634
                     '<a href="'
635 635
                     . $country_settings_url
636 636
                     . '">'
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
      */
664 664
     public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
665 665
     {
666
-        if (! $CNT_ISO) {
666
+        if ( ! $CNT_ISO) {
667 667
             EE_Error::add_error(
668 668
                 esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
669 669
                 __FILE__,
@@ -673,13 +673,13 @@  discard block
 block discarded – undo
673 673
         }
674 674
         $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
675 675
             : false;
676
-        if (! $STA_abbrev && ! empty($STA_ID)) {
676
+        if ( ! $STA_abbrev && ! empty($STA_ID)) {
677 677
             $state = EEM_State::instance()->get_one_by_ID($STA_ID);
678 678
             if ($state instanceof EE_State) {
679 679
                 $STA_abbrev = $state->abbrev();
680 680
             }
681 681
         }
682
-        if (! $STA_abbrev) {
682
+        if ( ! $STA_abbrev) {
683 683
             EE_Error::add_error(
684 684
                 esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
685 685
                 __FILE__,
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
         $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
692 692
             'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
693 693
         );
694
-        $persistent_admin_notice_manager->dismissNotice($CNT_ISO . '-' . $STA_abbrev, true, true);
694
+        $persistent_admin_notice_manager->dismissNotice($CNT_ISO.'-'.$STA_abbrev, true, true);
695 695
     }
696 696
 
697 697
 
@@ -719,16 +719,16 @@  discard block
 block discarded – undo
719 719
             && $question->type() === EEM_Question::QST_type_state
720 720
         ) {
721 721
             $STA_ID = $answer->value();
722
-            if (! empty($STA_ID)) {
722
+            if ( ! empty($STA_ID)) {
723 723
                 $state = EEM_State::instance()->get_one_by_ID($STA_ID);
724 724
                 if ($state instanceof EE_State) {
725 725
                     $country = $state->country();
726 726
                     if ($country instanceof EE_Country) {
727
-                        if (! isset($state_options[ $country->name() ])) {
728
-                            $state_options[ $country->name() ] = array();
727
+                        if ( ! isset($state_options[$country->name()])) {
728
+                            $state_options[$country->name()] = array();
729 729
                         }
730
-                        if (! isset($state_options[ $country->name() ][ $STA_ID ])) {
731
-                            $state_options[ $country->name() ][ $STA_ID ] = $state->name();
730
+                        if ( ! isset($state_options[$country->name()][$STA_ID])) {
731
+                            $state_options[$country->name()][$STA_ID] = $state->name();
732 732
                         }
733 733
                     }
734 734
                 }
@@ -763,11 +763,11 @@  discard block
 block discarded – undo
763 763
             && $question->type() === EEM_Question::QST_type_country
764 764
         ) {
765 765
             $CNT_ISO = $answer->value();
766
-            if (! empty($CNT_ISO)) {
766
+            if ( ! empty($CNT_ISO)) {
767 767
                 $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
768 768
                 if ($country instanceof EE_Country) {
769
-                    if (! isset($country_options[ $CNT_ISO ])) {
770
-                        $country_options[ $CNT_ISO ] = $country->name();
769
+                    if ( ! isset($country_options[$CNT_ISO])) {
770
+                        $country_options[$CNT_ISO] = $country->name();
771 771
                     }
772 772
                 }
773 773
             }
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
                 $new_state instanceof EE_State
793 793
                 && $new_state->country() instanceof EE_Country
794 794
             ) {
795
-                $state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name();
795
+                $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name();
796 796
             }
797 797
         }
798 798
         return $state_options;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
                 $new_state instanceof EE_State
834 834
                 && $new_state->country() instanceof EE_Country
835 835
             ) {
836
-                $country_options[ $new_state->country()->ID() ] = $new_state->country()->name();
836
+                $country_options[$new_state->country()->ID()] = $new_state->country()->name();
837 837
             }
838 838
         }
839 839
         return $country_options;
Please login to merge, or discard this patch.
modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php 1 patch
Indentation   +636 added lines, -636 removed lines patch added patch discarded remove patch
@@ -12,640 +12,640 @@
 block discarded – undo
12 12
 abstract class EE_SPCO_Reg_Step
13 13
 {
14 14
 
15
-    /**
16
-     *    $_completed - TRUE if this step has fully completed it's duties
17
-     *
18
-     * @access protected
19
-     * @type bool $_completed
20
-     */
21
-    protected $_completed = false;
22
-
23
-    /**
24
-     *    $_is_current_step - TRUE if this is the current step
25
-     *
26
-     * @access protected
27
-     * @type bool $_is_current_step
28
-     */
29
-    protected $_is_current_step = false;
30
-
31
-    /**
32
-     *    $_order - when the reg step should be run relative to other steps
33
-     *
34
-     * @access protected
35
-     * @type int $_template
36
-     */
37
-    protected $_order = 0;
38
-
39
-    /**
40
-     *    $_slug - URL param for this step
41
-     *
42
-     * @access protected
43
-     * @type string $_slug
44
-     */
45
-    protected $_slug;
46
-
47
-    /**
48
-     *    $_name - Step Name - translatable string
49
-     *
50
-     * @access protected
51
-     * @type string $_slug
52
-     */
53
-    protected $_name;
54
-
55
-    /**
56
-     *    $_submit_button_text - translatable string that appears on this step's submit button
57
-     *
58
-     * @access protected
59
-     * @type string $_slug
60
-     */
61
-    protected $_submit_button_text;
62
-
63
-    /**
64
-     *    $_template - template name
65
-     *
66
-     * @access protected
67
-     * @type string $_template
68
-     */
69
-    protected $_template;
70
-
71
-    /**
72
-     *    $_reg_form_name - the form input name and id attribute
73
-     *
74
-     * @access protected
75
-     * @var string $_reg_form_name
76
-     */
77
-    protected $_reg_form_name;
78
-
79
-    /**
80
-     *    $_success_message - text to display upon successful form submission
81
-     *
82
-     * @access private
83
-     * @var string $_success_message
84
-     */
85
-    protected $_success_message;
86
-
87
-    /**
88
-     *    $_instructions - a brief description of how to complete the reg step.
89
-     *    Usually displayed in conjunction with the previous step's success message.
90
-     *
91
-     * @access private
92
-     * @var string $_instructions
93
-     */
94
-    protected $_instructions;
95
-
96
-    /**
97
-     *    $_valid_data - the normalized and validated data for this step
98
-     *
99
-     * @access public
100
-     * @var array $_valid_data
101
-     */
102
-    protected $_valid_data = array();
103
-
104
-    /**
105
-     *    $reg_form - the registration form for this step
106
-     *
107
-     * @access public
108
-     * @var EE_Form_Section_Proper $reg_form
109
-     */
110
-    public $reg_form;
111
-
112
-    /**
113
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
114
-     *
115
-     * @access public
116
-     * @var EE_Checkout $checkout
117
-     */
118
-    public $checkout;
119
-
120
-
121
-    /**
122
-     * @return void
123
-     */
124
-    abstract public function translate_js_strings();
125
-
126
-
127
-    /**
128
-     * @return void
129
-     */
130
-    abstract public function enqueue_styles_and_scripts();
131
-
132
-
133
-    /**
134
-     * @return boolean
135
-     */
136
-    abstract public function initialize_reg_step();
137
-
138
-
139
-    /**
140
-     * @return string
141
-     */
142
-    abstract public function generate_reg_form();
143
-
144
-
145
-    /**
146
-     * @return boolean
147
-     */
148
-    abstract public function process_reg_step();
149
-
150
-
151
-    /**
152
-     * @return boolean
153
-     */
154
-    abstract public function update_reg_step();
155
-
156
-
157
-    /**
158
-     * @return boolean
159
-     */
160
-    public function completed()
161
-    {
162
-        return $this->_completed;
163
-    }
164
-
165
-
166
-    /**
167
-     * set_completed - toggles $_completed to TRUE
168
-     */
169
-    public function set_completed()
170
-    {
171
-        // DEBUG LOG
172
-        // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
173
-        $this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this);
174
-    }
175
-
176
-
177
-    /**
178
-     * set_completed - toggles $_completed to FALSE
179
-     */
180
-    public function set_not_completed()
181
-    {
182
-        $this->_completed = false;
183
-    }
184
-
185
-
186
-    /**
187
-     * @return string
188
-     */
189
-    public function name()
190
-    {
191
-        return $this->_name;
192
-    }
193
-
194
-
195
-    /**
196
-     * @return string
197
-     */
198
-    public function slug()
199
-    {
200
-        return $this->_slug;
201
-    }
202
-
203
-
204
-    /**
205
-     * submit_button_text
206
-     * the text that appears on the reg step form submit button
207
-     *
208
-     * @return string
209
-     */
210
-    public function submit_button_text()
211
-    {
212
-        return $this->_submit_button_text;
213
-    }
214
-
215
-
216
-    /**
217
-     * set_submit_button_text
218
-     * sets the text that appears on the reg step form submit button
219
-     *
220
-     * @param string $submit_button_text
221
-     */
222
-    public function set_submit_button_text($submit_button_text = '')
223
-    {
224
-        if (! empty($submit_button_text)) {
225
-            $this->_submit_button_text = $submit_button_text;
226
-        } elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
227
-            if ($this->checkout->revisit) {
228
-                $this->_submit_button_text = sprintf(
229
-                    __('Update %s', 'event_espresso'),
230
-                    $this->checkout->current_step->name()
231
-                );
232
-            } else {
233
-                $this->_submit_button_text = sprintf(
234
-                    __('Proceed to %s', 'event_espresso'),
235
-                    $this->checkout->next_step->name()
236
-                );
237
-            }
238
-        }
239
-        // filters the submit button text
240
-        $this->_submit_button_text = apply_filters(
241
-            'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
242
-            $this->_submit_button_text,
243
-            $this->checkout
244
-        );
245
-    }
246
-
247
-
248
-    /**
249
-     * @param boolean $is_current_step
250
-     */
251
-    public function set_is_current_step($is_current_step)
252
-    {
253
-        $this->_is_current_step = $is_current_step;
254
-    }
255
-
256
-
257
-    /**
258
-     * @return boolean
259
-     */
260
-    public function is_current_step()
261
-    {
262
-        return $this->_is_current_step;
263
-    }
264
-
265
-
266
-    /**
267
-     * @return boolean
268
-     */
269
-    public function is_final_step()
270
-    {
271
-        return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration ? true : false;
272
-    }
273
-
274
-
275
-    /**
276
-     * @param int $order
277
-     */
278
-    public function set_order($order)
279
-    {
280
-        $this->_order = $order;
281
-    }
282
-
283
-
284
-    /**
285
-     * @return int
286
-     */
287
-    public function order()
288
-    {
289
-        return $this->_order;
290
-    }
291
-
292
-
293
-    /**
294
-     * @return string
295
-     */
296
-    public function template(): string
297
-    {
298
-        return $this->_template;
299
-    }
300
-
301
-
302
-    /**
303
-     * @param string $template
304
-     */
305
-    public function setTemplate(string $template): void
306
-    {
307
-        $this->_template = $template;
308
-    }
309
-
310
-
311
-    /**
312
-     * @return string
313
-     */
314
-    public function success_message()
315
-    {
316
-        return $this->_success_message;
317
-    }
318
-
319
-
320
-    /**
321
-     * _set_success_message
322
-     *
323
-     * @param string $success_message
324
-     */
325
-    protected function _set_success_message($success_message)
326
-    {
327
-        $this->_success_message = $success_message;
328
-    }
329
-
330
-
331
-    /**
332
-     * _reset_success_message
333
-     *
334
-     * @return void
335
-     */
336
-    protected function _reset_success_message()
337
-    {
338
-        $this->_success_message = '';
339
-    }
340
-
341
-
342
-    /**
343
-     * @return string
344
-     */
345
-    public function _instructions()
346
-    {
347
-        return $this->_instructions;
348
-    }
349
-
350
-
351
-    /**
352
-     * @param string $instructions
353
-     */
354
-    public function set_instructions($instructions)
355
-    {
356
-        $this->_instructions = apply_filters(
357
-            'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions',
358
-            $instructions,
359
-            $this
360
-        );
361
-    }
362
-
363
-
364
-    /**
365
-     * @param array $valid_data
366
-     */
367
-    public function set_valid_data($valid_data)
368
-    {
369
-        $this->_valid_data = $valid_data;
370
-    }
371
-
372
-
373
-    /**
374
-     * @return array
375
-     */
376
-    public function valid_data()
377
-    {
378
-        if (empty($this->_valid_data)) {
379
-            $this->_valid_data = $this->reg_form->valid_data();
380
-        }
381
-        return $this->_valid_data;
382
-    }
383
-
384
-
385
-    /**
386
-     * @return string
387
-     */
388
-    public function reg_form_name()
389
-    {
390
-        if (empty($this->_reg_form_name)) {
391
-            $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
392
-        }
393
-        return $this->_reg_form_name;
394
-    }
395
-
396
-
397
-    /**
398
-     * @param string $reg_form_name
399
-     */
400
-    protected function set_reg_form_name($reg_form_name)
401
-    {
402
-        $this->_reg_form_name = $reg_form_name;
403
-    }
404
-
405
-
406
-    /**
407
-     * reg_step_url
408
-     *
409
-     * @param string $action
410
-     * @return string
411
-     */
412
-    public function reg_step_url($action = '')
413
-    {
414
-        $query_args = array('step' => $this->slug());
415
-        if (! empty($action)) {
416
-            $query_args['action'] = $action;
417
-        }
418
-        // final step has no display
419
-        if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') {
420
-            $query_args['action'] = 'process_reg_step';
421
-        }
422
-        if ($this->checkout->revisit) {
423
-            $query_args['revisit'] = true;
424
-        }
425
-        if ($this->checkout->reg_url_link) {
426
-            $query_args['e_reg_url_link'] = $this->checkout->reg_url_link;
427
-        }
428
-        return add_query_arg($query_args, $this->checkout->reg_page_base_url);
429
-    }
430
-
431
-
432
-    /**
433
-     * creates the default hidden inputs section
434
-     *
435
-     * @return EE_Form_Section_Proper
436
-     * @throws \EE_Error
437
-     */
438
-    public function reg_step_hidden_inputs()
439
-    {
440
-        // hidden inputs for admin registrations
441
-        if ($this->checkout->admin_request) {
442
-            return new EE_Form_Section_Proper(
443
-                array(
444
-                    'layout_strategy' => new EE_Div_Per_Section_Layout(),
445
-                    'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
446
-                    'subsections'     => array(
447
-                        'next_step' => new EE_Fixed_Hidden_Input(
448
-                            array(
449
-                                'html_name' => 'next_step',
450
-                                'html_id'   => 'spco-' . $this->slug() . '-next-step',
451
-                                'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
452
-                                    ? $this->checkout->next_step->slug()
453
-                                    : '',
454
-                            )
455
-                        ),
456
-                    ),
457
-                )
458
-            );
459
-        }
460
-        // hidden inputs for frontend registrations
461
-        return new EE_Form_Section_Proper(
462
-            array(
463
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
464
-                'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
465
-                'subsections'     => array(
466
-                    'action'         => new EE_Fixed_Hidden_Input(
467
-                        array(
468
-                            'html_name' => 'action',
469
-                            'html_id'   => 'spco-' . $this->slug() . '-action',
470
-                            'default'   => apply_filters(
471
-                                'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
472
-                                empty($this->checkout->reg_url_link)
473
-                                    ? 'process_reg_step'
474
-                                    : 'update_reg_step',
475
-                                $this
476
-                            ),
477
-                        )
478
-                    ),
479
-                    'next_step'      => new EE_Fixed_Hidden_Input(
480
-                        array(
481
-                            'html_name' => 'next_step',
482
-                            'html_id'   => 'spco-' . $this->slug() . '-next-step',
483
-                            'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
484
-                                ? $this->checkout->next_step->slug()
485
-                                : '',
486
-                        )
487
-                    ),
488
-                    'e_reg_url_link' => new EE_Fixed_Hidden_Input(
489
-                        array(
490
-                            'html_name' => 'e_reg_url_link',
491
-                            'html_id'   => 'spco-reg_url_link',
492
-                            'default'   => $this->checkout->reg_url_link,
493
-                        )
494
-                    ),
495
-                    'revisit'        => new EE_Fixed_Hidden_Input(
496
-                        array(
497
-                            'html_name' => 'revisit',
498
-                            'html_id'   => 'spco-revisit',
499
-                            'default'   => $this->checkout->revisit,
500
-                        )
501
-                    ),
502
-                ),
503
-            )
504
-        );
505
-    }
506
-
507
-
508
-    /**
509
-     * generate_reg_form_for_actions
510
-     *
511
-     * @param array $actions
512
-     * @return void
513
-     */
514
-    public function generate_reg_form_for_actions($actions = array())
515
-    {
516
-        $actions = array_merge(
517
-            array(
518
-                'generate_reg_form',
519
-                'display_spco_reg_step',
520
-                'process_reg_step',
521
-                'update_reg_step',
522
-            ),
523
-            $actions
524
-        );
525
-        $this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true) ? true : false;
526
-    }
527
-
528
-
529
-    /**
530
-     * @return string
531
-     * @throws \EE_Error
532
-     */
533
-    public function display_reg_form()
534
-    {
535
-        $html = '';
536
-        if ($this->reg_form instanceof EE_Form_Section_Proper) {
537
-            do_action('AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', $this->reg_form, $this);
538
-            $html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
539
-            if (EE_Registry::instance()->REQ->ajax) {
540
-                $this->reg_form->localize_validation_rules();
541
-                $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
542
-            }
543
-            $html .= $this->reg_form->get_html();
544
-            $html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : '';
545
-            $html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : '';
546
-        }
547
-        return $html;
548
-    }
549
-
550
-
551
-    /**
552
-     * div_class - returns nothing for current step, but a css class of "hidden" for others
553
-     *
554
-     * @return string
555
-     * @throws \EE_Error
556
-     */
557
-    public function reg_step_submit_button()
558
-    {
559
-        if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
560
-            return '';
561
-        }
562
-        ob_start();
563
-        do_action(
564
-            'AHEE__before_spco_whats_next_buttons',
565
-            $this->slug(),
566
-            $this->checkout->next_step->slug(),
567
-            $this->checkout
568
-        );
569
-        $html = ob_get_clean();
570
-        // generate submit button
571
-        $sbmt_btn = new EE_Submit_Input(
572
-            array(
573
-                'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
-                'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
575
-                'html_class'            => 'spco-next-step-btn',
576
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
577
-                'default'               => $this->submit_button_text(),
578
-            )
579
-        );
580
-        $sbmt_btn->set_button_css_attributes(true, 'large');
581
-        $sbmt_btn_html = $sbmt_btn->get_html_for_input();
582
-        $html .= EEH_HTML::div(
583
-            apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this),
584
-            'spco-' . $this->slug() . '-whats-next-buttons-dv',
585
-            'spco-whats-next-buttons'
586
-        );
587
-        return $html;
588
-    }
589
-
590
-
591
-    /**
592
-     * div_class - returns nothing for current step, but a css class of "hidden" for others
593
-     *
594
-     * @return string
595
-     */
596
-    public function div_class()
597
-    {
598
-        return $this->is_current_step() ? '' : ' hidden';
599
-    }
600
-
601
-
602
-    /**
603
-     * div_class - returns  a css class of "hidden" for current step, but nothing for others
604
-     *
605
-     * @return string
606
-     */
607
-    public function edit_lnk_url()
608
-    {
609
-        return add_query_arg(array('step' => $this->slug()), $this->checkout->reg_page_base_url);
610
-    }
611
-
612
-
613
-    /**
614
-     * div_class - returns  a css class of "hidden" for current step, but nothing for others
615
-     *
616
-     * @return string
617
-     */
618
-    public function edit_link_class()
619
-    {
620
-        return $this->is_current_step() ? ' hidden' : '';
621
-    }
622
-
623
-
624
-    /**
625
-     * update_checkout with changes that have been made to the cart
626
-     *
627
-     * @return void
628
-     * @throws \EE_Error
629
-     */
630
-    public function update_checkout()
631
-    {
632
-        // grab the cart grand total and reset TXN total
633
-        $this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total());
634
-        $this->checkout->stash_transaction_and_checkout();
635
-    }
636
-
637
-
638
-    /**
639
-     *    __sleep
640
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
641
-     * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
642
-     * reg form, because if needed, it will be regenerated anyways
643
-     *
644
-     * @return array
645
-     */
646
-    public function __sleep()
647
-    {
648
-        // remove the reg form and the checkout
649
-        return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout'));
650
-    }
15
+	/**
16
+	 *    $_completed - TRUE if this step has fully completed it's duties
17
+	 *
18
+	 * @access protected
19
+	 * @type bool $_completed
20
+	 */
21
+	protected $_completed = false;
22
+
23
+	/**
24
+	 *    $_is_current_step - TRUE if this is the current step
25
+	 *
26
+	 * @access protected
27
+	 * @type bool $_is_current_step
28
+	 */
29
+	protected $_is_current_step = false;
30
+
31
+	/**
32
+	 *    $_order - when the reg step should be run relative to other steps
33
+	 *
34
+	 * @access protected
35
+	 * @type int $_template
36
+	 */
37
+	protected $_order = 0;
38
+
39
+	/**
40
+	 *    $_slug - URL param for this step
41
+	 *
42
+	 * @access protected
43
+	 * @type string $_slug
44
+	 */
45
+	protected $_slug;
46
+
47
+	/**
48
+	 *    $_name - Step Name - translatable string
49
+	 *
50
+	 * @access protected
51
+	 * @type string $_slug
52
+	 */
53
+	protected $_name;
54
+
55
+	/**
56
+	 *    $_submit_button_text - translatable string that appears on this step's submit button
57
+	 *
58
+	 * @access protected
59
+	 * @type string $_slug
60
+	 */
61
+	protected $_submit_button_text;
62
+
63
+	/**
64
+	 *    $_template - template name
65
+	 *
66
+	 * @access protected
67
+	 * @type string $_template
68
+	 */
69
+	protected $_template;
70
+
71
+	/**
72
+	 *    $_reg_form_name - the form input name and id attribute
73
+	 *
74
+	 * @access protected
75
+	 * @var string $_reg_form_name
76
+	 */
77
+	protected $_reg_form_name;
78
+
79
+	/**
80
+	 *    $_success_message - text to display upon successful form submission
81
+	 *
82
+	 * @access private
83
+	 * @var string $_success_message
84
+	 */
85
+	protected $_success_message;
86
+
87
+	/**
88
+	 *    $_instructions - a brief description of how to complete the reg step.
89
+	 *    Usually displayed in conjunction with the previous step's success message.
90
+	 *
91
+	 * @access private
92
+	 * @var string $_instructions
93
+	 */
94
+	protected $_instructions;
95
+
96
+	/**
97
+	 *    $_valid_data - the normalized and validated data for this step
98
+	 *
99
+	 * @access public
100
+	 * @var array $_valid_data
101
+	 */
102
+	protected $_valid_data = array();
103
+
104
+	/**
105
+	 *    $reg_form - the registration form for this step
106
+	 *
107
+	 * @access public
108
+	 * @var EE_Form_Section_Proper $reg_form
109
+	 */
110
+	public $reg_form;
111
+
112
+	/**
113
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
114
+	 *
115
+	 * @access public
116
+	 * @var EE_Checkout $checkout
117
+	 */
118
+	public $checkout;
119
+
120
+
121
+	/**
122
+	 * @return void
123
+	 */
124
+	abstract public function translate_js_strings();
125
+
126
+
127
+	/**
128
+	 * @return void
129
+	 */
130
+	abstract public function enqueue_styles_and_scripts();
131
+
132
+
133
+	/**
134
+	 * @return boolean
135
+	 */
136
+	abstract public function initialize_reg_step();
137
+
138
+
139
+	/**
140
+	 * @return string
141
+	 */
142
+	abstract public function generate_reg_form();
143
+
144
+
145
+	/**
146
+	 * @return boolean
147
+	 */
148
+	abstract public function process_reg_step();
149
+
150
+
151
+	/**
152
+	 * @return boolean
153
+	 */
154
+	abstract public function update_reg_step();
155
+
156
+
157
+	/**
158
+	 * @return boolean
159
+	 */
160
+	public function completed()
161
+	{
162
+		return $this->_completed;
163
+	}
164
+
165
+
166
+	/**
167
+	 * set_completed - toggles $_completed to TRUE
168
+	 */
169
+	public function set_completed()
170
+	{
171
+		// DEBUG LOG
172
+		// $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
173
+		$this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this);
174
+	}
175
+
176
+
177
+	/**
178
+	 * set_completed - toggles $_completed to FALSE
179
+	 */
180
+	public function set_not_completed()
181
+	{
182
+		$this->_completed = false;
183
+	}
184
+
185
+
186
+	/**
187
+	 * @return string
188
+	 */
189
+	public function name()
190
+	{
191
+		return $this->_name;
192
+	}
193
+
194
+
195
+	/**
196
+	 * @return string
197
+	 */
198
+	public function slug()
199
+	{
200
+		return $this->_slug;
201
+	}
202
+
203
+
204
+	/**
205
+	 * submit_button_text
206
+	 * the text that appears on the reg step form submit button
207
+	 *
208
+	 * @return string
209
+	 */
210
+	public function submit_button_text()
211
+	{
212
+		return $this->_submit_button_text;
213
+	}
214
+
215
+
216
+	/**
217
+	 * set_submit_button_text
218
+	 * sets the text that appears on the reg step form submit button
219
+	 *
220
+	 * @param string $submit_button_text
221
+	 */
222
+	public function set_submit_button_text($submit_button_text = '')
223
+	{
224
+		if (! empty($submit_button_text)) {
225
+			$this->_submit_button_text = $submit_button_text;
226
+		} elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
227
+			if ($this->checkout->revisit) {
228
+				$this->_submit_button_text = sprintf(
229
+					__('Update %s', 'event_espresso'),
230
+					$this->checkout->current_step->name()
231
+				);
232
+			} else {
233
+				$this->_submit_button_text = sprintf(
234
+					__('Proceed to %s', 'event_espresso'),
235
+					$this->checkout->next_step->name()
236
+				);
237
+			}
238
+		}
239
+		// filters the submit button text
240
+		$this->_submit_button_text = apply_filters(
241
+			'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
242
+			$this->_submit_button_text,
243
+			$this->checkout
244
+		);
245
+	}
246
+
247
+
248
+	/**
249
+	 * @param boolean $is_current_step
250
+	 */
251
+	public function set_is_current_step($is_current_step)
252
+	{
253
+		$this->_is_current_step = $is_current_step;
254
+	}
255
+
256
+
257
+	/**
258
+	 * @return boolean
259
+	 */
260
+	public function is_current_step()
261
+	{
262
+		return $this->_is_current_step;
263
+	}
264
+
265
+
266
+	/**
267
+	 * @return boolean
268
+	 */
269
+	public function is_final_step()
270
+	{
271
+		return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration ? true : false;
272
+	}
273
+
274
+
275
+	/**
276
+	 * @param int $order
277
+	 */
278
+	public function set_order($order)
279
+	{
280
+		$this->_order = $order;
281
+	}
282
+
283
+
284
+	/**
285
+	 * @return int
286
+	 */
287
+	public function order()
288
+	{
289
+		return $this->_order;
290
+	}
291
+
292
+
293
+	/**
294
+	 * @return string
295
+	 */
296
+	public function template(): string
297
+	{
298
+		return $this->_template;
299
+	}
300
+
301
+
302
+	/**
303
+	 * @param string $template
304
+	 */
305
+	public function setTemplate(string $template): void
306
+	{
307
+		$this->_template = $template;
308
+	}
309
+
310
+
311
+	/**
312
+	 * @return string
313
+	 */
314
+	public function success_message()
315
+	{
316
+		return $this->_success_message;
317
+	}
318
+
319
+
320
+	/**
321
+	 * _set_success_message
322
+	 *
323
+	 * @param string $success_message
324
+	 */
325
+	protected function _set_success_message($success_message)
326
+	{
327
+		$this->_success_message = $success_message;
328
+	}
329
+
330
+
331
+	/**
332
+	 * _reset_success_message
333
+	 *
334
+	 * @return void
335
+	 */
336
+	protected function _reset_success_message()
337
+	{
338
+		$this->_success_message = '';
339
+	}
340
+
341
+
342
+	/**
343
+	 * @return string
344
+	 */
345
+	public function _instructions()
346
+	{
347
+		return $this->_instructions;
348
+	}
349
+
350
+
351
+	/**
352
+	 * @param string $instructions
353
+	 */
354
+	public function set_instructions($instructions)
355
+	{
356
+		$this->_instructions = apply_filters(
357
+			'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions',
358
+			$instructions,
359
+			$this
360
+		);
361
+	}
362
+
363
+
364
+	/**
365
+	 * @param array $valid_data
366
+	 */
367
+	public function set_valid_data($valid_data)
368
+	{
369
+		$this->_valid_data = $valid_data;
370
+	}
371
+
372
+
373
+	/**
374
+	 * @return array
375
+	 */
376
+	public function valid_data()
377
+	{
378
+		if (empty($this->_valid_data)) {
379
+			$this->_valid_data = $this->reg_form->valid_data();
380
+		}
381
+		return $this->_valid_data;
382
+	}
383
+
384
+
385
+	/**
386
+	 * @return string
387
+	 */
388
+	public function reg_form_name()
389
+	{
390
+		if (empty($this->_reg_form_name)) {
391
+			$this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
392
+		}
393
+		return $this->_reg_form_name;
394
+	}
395
+
396
+
397
+	/**
398
+	 * @param string $reg_form_name
399
+	 */
400
+	protected function set_reg_form_name($reg_form_name)
401
+	{
402
+		$this->_reg_form_name = $reg_form_name;
403
+	}
404
+
405
+
406
+	/**
407
+	 * reg_step_url
408
+	 *
409
+	 * @param string $action
410
+	 * @return string
411
+	 */
412
+	public function reg_step_url($action = '')
413
+	{
414
+		$query_args = array('step' => $this->slug());
415
+		if (! empty($action)) {
416
+			$query_args['action'] = $action;
417
+		}
418
+		// final step has no display
419
+		if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') {
420
+			$query_args['action'] = 'process_reg_step';
421
+		}
422
+		if ($this->checkout->revisit) {
423
+			$query_args['revisit'] = true;
424
+		}
425
+		if ($this->checkout->reg_url_link) {
426
+			$query_args['e_reg_url_link'] = $this->checkout->reg_url_link;
427
+		}
428
+		return add_query_arg($query_args, $this->checkout->reg_page_base_url);
429
+	}
430
+
431
+
432
+	/**
433
+	 * creates the default hidden inputs section
434
+	 *
435
+	 * @return EE_Form_Section_Proper
436
+	 * @throws \EE_Error
437
+	 */
438
+	public function reg_step_hidden_inputs()
439
+	{
440
+		// hidden inputs for admin registrations
441
+		if ($this->checkout->admin_request) {
442
+			return new EE_Form_Section_Proper(
443
+				array(
444
+					'layout_strategy' => new EE_Div_Per_Section_Layout(),
445
+					'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
446
+					'subsections'     => array(
447
+						'next_step' => new EE_Fixed_Hidden_Input(
448
+							array(
449
+								'html_name' => 'next_step',
450
+								'html_id'   => 'spco-' . $this->slug() . '-next-step',
451
+								'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
452
+									? $this->checkout->next_step->slug()
453
+									: '',
454
+							)
455
+						),
456
+					),
457
+				)
458
+			);
459
+		}
460
+		// hidden inputs for frontend registrations
461
+		return new EE_Form_Section_Proper(
462
+			array(
463
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
464
+				'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
465
+				'subsections'     => array(
466
+					'action'         => new EE_Fixed_Hidden_Input(
467
+						array(
468
+							'html_name' => 'action',
469
+							'html_id'   => 'spco-' . $this->slug() . '-action',
470
+							'default'   => apply_filters(
471
+								'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
472
+								empty($this->checkout->reg_url_link)
473
+									? 'process_reg_step'
474
+									: 'update_reg_step',
475
+								$this
476
+							),
477
+						)
478
+					),
479
+					'next_step'      => new EE_Fixed_Hidden_Input(
480
+						array(
481
+							'html_name' => 'next_step',
482
+							'html_id'   => 'spco-' . $this->slug() . '-next-step',
483
+							'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
484
+								? $this->checkout->next_step->slug()
485
+								: '',
486
+						)
487
+					),
488
+					'e_reg_url_link' => new EE_Fixed_Hidden_Input(
489
+						array(
490
+							'html_name' => 'e_reg_url_link',
491
+							'html_id'   => 'spco-reg_url_link',
492
+							'default'   => $this->checkout->reg_url_link,
493
+						)
494
+					),
495
+					'revisit'        => new EE_Fixed_Hidden_Input(
496
+						array(
497
+							'html_name' => 'revisit',
498
+							'html_id'   => 'spco-revisit',
499
+							'default'   => $this->checkout->revisit,
500
+						)
501
+					),
502
+				),
503
+			)
504
+		);
505
+	}
506
+
507
+
508
+	/**
509
+	 * generate_reg_form_for_actions
510
+	 *
511
+	 * @param array $actions
512
+	 * @return void
513
+	 */
514
+	public function generate_reg_form_for_actions($actions = array())
515
+	{
516
+		$actions = array_merge(
517
+			array(
518
+				'generate_reg_form',
519
+				'display_spco_reg_step',
520
+				'process_reg_step',
521
+				'update_reg_step',
522
+			),
523
+			$actions
524
+		);
525
+		$this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true) ? true : false;
526
+	}
527
+
528
+
529
+	/**
530
+	 * @return string
531
+	 * @throws \EE_Error
532
+	 */
533
+	public function display_reg_form()
534
+	{
535
+		$html = '';
536
+		if ($this->reg_form instanceof EE_Form_Section_Proper) {
537
+			do_action('AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', $this->reg_form, $this);
538
+			$html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
539
+			if (EE_Registry::instance()->REQ->ajax) {
540
+				$this->reg_form->localize_validation_rules();
541
+				$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
542
+			}
543
+			$html .= $this->reg_form->get_html();
544
+			$html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : '';
545
+			$html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : '';
546
+		}
547
+		return $html;
548
+	}
549
+
550
+
551
+	/**
552
+	 * div_class - returns nothing for current step, but a css class of "hidden" for others
553
+	 *
554
+	 * @return string
555
+	 * @throws \EE_Error
556
+	 */
557
+	public function reg_step_submit_button()
558
+	{
559
+		if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
560
+			return '';
561
+		}
562
+		ob_start();
563
+		do_action(
564
+			'AHEE__before_spco_whats_next_buttons',
565
+			$this->slug(),
566
+			$this->checkout->next_step->slug(),
567
+			$this->checkout
568
+		);
569
+		$html = ob_get_clean();
570
+		// generate submit button
571
+		$sbmt_btn = new EE_Submit_Input(
572
+			array(
573
+				'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
+				'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
575
+				'html_class'            => 'spco-next-step-btn',
576
+				'other_html_attributes' => ' rel="' . $this->slug() . '"',
577
+				'default'               => $this->submit_button_text(),
578
+			)
579
+		);
580
+		$sbmt_btn->set_button_css_attributes(true, 'large');
581
+		$sbmt_btn_html = $sbmt_btn->get_html_for_input();
582
+		$html .= EEH_HTML::div(
583
+			apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $sbmt_btn_html, $this),
584
+			'spco-' . $this->slug() . '-whats-next-buttons-dv',
585
+			'spco-whats-next-buttons'
586
+		);
587
+		return $html;
588
+	}
589
+
590
+
591
+	/**
592
+	 * div_class - returns nothing for current step, but a css class of "hidden" for others
593
+	 *
594
+	 * @return string
595
+	 */
596
+	public function div_class()
597
+	{
598
+		return $this->is_current_step() ? '' : ' hidden';
599
+	}
600
+
601
+
602
+	/**
603
+	 * div_class - returns  a css class of "hidden" for current step, but nothing for others
604
+	 *
605
+	 * @return string
606
+	 */
607
+	public function edit_lnk_url()
608
+	{
609
+		return add_query_arg(array('step' => $this->slug()), $this->checkout->reg_page_base_url);
610
+	}
611
+
612
+
613
+	/**
614
+	 * div_class - returns  a css class of "hidden" for current step, but nothing for others
615
+	 *
616
+	 * @return string
617
+	 */
618
+	public function edit_link_class()
619
+	{
620
+		return $this->is_current_step() ? ' hidden' : '';
621
+	}
622
+
623
+
624
+	/**
625
+	 * update_checkout with changes that have been made to the cart
626
+	 *
627
+	 * @return void
628
+	 * @throws \EE_Error
629
+	 */
630
+	public function update_checkout()
631
+	{
632
+		// grab the cart grand total and reset TXN total
633
+		$this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total());
634
+		$this->checkout->stash_transaction_and_checkout();
635
+	}
636
+
637
+
638
+	/**
639
+	 *    __sleep
640
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
641
+	 * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
642
+	 * reg form, because if needed, it will be regenerated anyways
643
+	 *
644
+	 * @return array
645
+	 */
646
+	public function __sleep()
647
+	{
648
+		// remove the reg form and the checkout
649
+		return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout'));
650
+	}
651 651
 }
Please login to merge, or discard this patch.
core/domain/services/registration/form/v1/AutoCopyAttendeeInfoForm.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -8,21 +8,21 @@
 block discarded – undo
8 8
 class AutoCopyAttendeeInfoForm extends EE_Form_Section_HTML
9 9
 {
10 10
 
11
-    /**
12
-     * CopyAttendeeInfoForm constructor.
13
-     */
14
-    public function __construct(string $slug)
15
-    {
16
-        parent::__construct(
17
-            EEH_Template::locate_template(
18
-                SPCO_REG_STEPS_PATH . $slug . '/_auto_copy_attendee_info.template.php',
19
-                apply_filters(
20
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
21
-                    []
22
-                ),
23
-                true,
24
-                true
25
-            )
26
-        );
27
-    }
11
+	/**
12
+	 * CopyAttendeeInfoForm constructor.
13
+	 */
14
+	public function __construct(string $slug)
15
+	{
16
+		parent::__construct(
17
+			EEH_Template::locate_template(
18
+				SPCO_REG_STEPS_PATH . $slug . '/_auto_copy_attendee_info.template.php',
19
+				apply_filters(
20
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
21
+					[]
22
+				),
23
+				true,
24
+				true
25
+			)
26
+		);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     {
16 16
         parent::__construct(
17 17
             EEH_Template::locate_template(
18
-                SPCO_REG_STEPS_PATH . $slug . '/_auto_copy_attendee_info.template.php',
18
+                SPCO_REG_STEPS_PATH.$slug.'/_auto_copy_attendee_info.template.php',
19 19
                 apply_filters(
20 20
                     'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
21 21
                     []
Please login to merge, or discard this patch.
core/domain/services/registration/form/v1/CountryOptions.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -13,109 +13,109 @@
 block discarded – undo
13 13
 
14 14
 class CountryOptions
15 15
 {
16
-    /**
17
-     * the action being performed on the current step
18
-     *
19
-     * @var string
20
-     */
21
-    public $action = '';
16
+	/**
17
+	 * the action being performed on the current step
18
+	 *
19
+	 * @var string
20
+	 */
21
+	public $action = '';
22 22
 
23
-    /**
24
-     * @var EEM_Answer
25
-     */
26
-    public $answer_model;
23
+	/**
24
+	 * @var EEM_Answer
25
+	 */
26
+	public $answer_model;
27 27
 
28
-    /**
29
-     * @var EEM_Country
30
-     */
31
-    public $country_model;
28
+	/**
29
+	 * @var EEM_Country
30
+	 */
31
+	public $country_model;
32 32
 
33
-    /**
34
-     * @var [][]
35
-     */
36
-    private $country_options = [];
33
+	/**
34
+	 * @var [][]
35
+	 */
36
+	private $country_options = [];
37 37
 
38 38
 
39
-    /**
40
-     * CountryOptions constructor.
41
-     *
42
-     * @param string      $action
43
-     * @param EEM_Answer  $answer_model
44
-     * @param EEM_Country $country_model
45
-     */
46
-    public function __construct(string $action, EEM_Answer $answer_model, EEM_Country $country_model)
47
-    {
48
-        $this->action        = $action;
49
-        $this->answer_model  = $answer_model;
50
-        $this->country_model = $country_model;
51
-        add_filter(
52
-            'FHEE__EE_Question__generate_form_input__country_options',
53
-            [$this, 'forLegacyFormInput'],
54
-            10,
55
-            4
56
-        );
57
-    }
39
+	/**
40
+	 * CountryOptions constructor.
41
+	 *
42
+	 * @param string      $action
43
+	 * @param EEM_Answer  $answer_model
44
+	 * @param EEM_Country $country_model
45
+	 */
46
+	public function __construct(string $action, EEM_Answer $answer_model, EEM_Country $country_model)
47
+	{
48
+		$this->action        = $action;
49
+		$this->answer_model  = $answer_model;
50
+		$this->country_model = $country_model;
51
+		add_filter(
52
+			'FHEE__EE_Question__generate_form_input__country_options',
53
+			[$this, 'forLegacyFormInput'],
54
+			10,
55
+			4
56
+		);
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * Gets the list of countries for the form input
62
-     *
63
-     * @param array|null           $countries_list deprecated prop from an old hook
64
-     * @param EE_Question|null     $question
65
-     * @param EE_Registration|null $registration
66
-     * @param EE_Answer|null       $answer deprecated prop from an old hook
67
-     * @return array 2d keys are country IDs, values are their names
68
-     * @throws EE_Error
69
-     * @throws ReflectionException
70
-     */
71
-    public function forLegacyFormInput(
72
-        array $countries_list = null,
73
-        EE_Question $question = null,
74
-        EE_Registration $registration = null,
75
-        EE_Answer $answer = null
76
-    ): array {
77
-        if (! isset($this->country_options[ $this->action ])) {
78
-            $this->generateLegacyCountryOptions($question, $registration);
79
-        }
80
-        return $this->country_options[ $this->action ];
81
-    }
60
+	/**
61
+	 * Gets the list of countries for the form input
62
+	 *
63
+	 * @param array|null           $countries_list deprecated prop from an old hook
64
+	 * @param EE_Question|null     $question
65
+	 * @param EE_Registration|null $registration
66
+	 * @param EE_Answer|null       $answer deprecated prop from an old hook
67
+	 * @return array 2d keys are country IDs, values are their names
68
+	 * @throws EE_Error
69
+	 * @throws ReflectionException
70
+	 */
71
+	public function forLegacyFormInput(
72
+		array $countries_list = null,
73
+		EE_Question $question = null,
74
+		EE_Registration $registration = null,
75
+		EE_Answer $answer = null
76
+	): array {
77
+		if (! isset($this->country_options[ $this->action ])) {
78
+			$this->generateLegacyCountryOptions($question, $registration);
79
+		}
80
+		return $this->country_options[ $this->action ];
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     * @param EE_Question|null     $question
86
-     * @param EE_Registration|null $registration
87
-     * @throws EE_Error
88
-     * @throws ReflectionException
89
-     */
90
-    private function generateLegacyCountryOptions(EE_Question $question = null, EE_Registration $registration = null)
91
-    {
92
-        // get possibly cached list of countries
93
-        $countries = $this->action === 'process_reg_step'
94
-            ? $this->country_model->get_all_countries()
95
-            : $this->country_model->get_all_active_countries();
96
-        // start with an empty option
97
-        $country_options = ['' => ''];
98
-        if (! empty($countries)) {
99
-            foreach ($countries as $country) {
100
-                if ($country instanceof EE_Country) {
101
-                    $country_options[ $country->ID() ] = $country->name();
102
-                }
103
-            }
104
-        }
105
-        if ($question instanceof EE_Question && $registration instanceof EE_Registration) {
106
-            $answer = $this->answer_model->get_one(
107
-                [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]]
108
-            );
109
-        } else {
110
-            $answer = EE_Answer::new_instance();
111
-        }
112
-        $this->country_options[ $this->action ] = apply_filters(
113
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
114
-            $country_options,
115
-            $this,
116
-            $registration,
117
-            $question,
118
-            $answer
119
-        );
120
-    }
84
+	/**
85
+	 * @param EE_Question|null     $question
86
+	 * @param EE_Registration|null $registration
87
+	 * @throws EE_Error
88
+	 * @throws ReflectionException
89
+	 */
90
+	private function generateLegacyCountryOptions(EE_Question $question = null, EE_Registration $registration = null)
91
+	{
92
+		// get possibly cached list of countries
93
+		$countries = $this->action === 'process_reg_step'
94
+			? $this->country_model->get_all_countries()
95
+			: $this->country_model->get_all_active_countries();
96
+		// start with an empty option
97
+		$country_options = ['' => ''];
98
+		if (! empty($countries)) {
99
+			foreach ($countries as $country) {
100
+				if ($country instanceof EE_Country) {
101
+					$country_options[ $country->ID() ] = $country->name();
102
+				}
103
+			}
104
+		}
105
+		if ($question instanceof EE_Question && $registration instanceof EE_Registration) {
106
+			$answer = $this->answer_model->get_one(
107
+				[['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]]
108
+			);
109
+		} else {
110
+			$answer = EE_Answer::new_instance();
111
+		}
112
+		$this->country_options[ $this->action ] = apply_filters(
113
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
114
+			$country_options,
115
+			$this,
116
+			$registration,
117
+			$question,
118
+			$answer
119
+		);
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
         EE_Registration $registration = null,
75 75
         EE_Answer $answer = null
76 76
     ): array {
77
-        if (! isset($this->country_options[ $this->action ])) {
77
+        if ( ! isset($this->country_options[$this->action])) {
78 78
             $this->generateLegacyCountryOptions($question, $registration);
79 79
         }
80
-        return $this->country_options[ $this->action ];
80
+        return $this->country_options[$this->action];
81 81
     }
82 82
 
83 83
 
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
             : $this->country_model->get_all_active_countries();
96 96
         // start with an empty option
97 97
         $country_options = ['' => ''];
98
-        if (! empty($countries)) {
98
+        if ( ! empty($countries)) {
99 99
             foreach ($countries as $country) {
100 100
                 if ($country instanceof EE_Country) {
101
-                    $country_options[ $country->ID() ] = $country->name();
101
+                    $country_options[$country->ID()] = $country->name();
102 102
                 }
103 103
             }
104 104
         }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         } else {
110 110
             $answer = EE_Answer::new_instance();
111 111
         }
112
-        $this->country_options[ $this->action ] = apply_filters(
112
+        $this->country_options[$this->action] = apply_filters(
113 113
             'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
114 114
             $country_options,
115 115
             $this,
Please login to merge, or discard this patch.
core/domain/services/registration/form/v1/StateOptions.php 2 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -12,97 +12,97 @@
 block discarded – undo
12 12
 
13 13
 class StateOptions
14 14
 {
15
-    /**
16
-     * the action being performed on the current step
17
-     *
18
-     * @var string
19
-     */
20
-    public $action = '';
15
+	/**
16
+	 * the action being performed on the current step
17
+	 *
18
+	 * @var string
19
+	 */
20
+	public $action = '';
21 21
 
22
-    /**
23
-     * @var EEM_State
24
-     */
25
-    public $state_model;
22
+	/**
23
+	 * @var EEM_State
24
+	 */
25
+	public $state_model;
26 26
 
27
-    /**
28
-     * @var [][]
29
-     */
30
-    private $state_options = [];
27
+	/**
28
+	 * @var [][]
29
+	 */
30
+	private $state_options = [];
31 31
 
32 32
 
33
-    /**
34
-     * CountryOptions constructor.
35
-     *
36
-     * @param string    $action
37
-     * @param EEM_State $state_model
38
-     */
39
-    public function __construct(string $action, EEM_State $state_model)
40
-    {
41
-        $this->action      = $action;
42
-        $this->state_model = $state_model;
43
-        add_filter(
44
-            'FHEE__EE_Question__generate_form_input__state_options',
45
-            [$this, 'forLegacyFormInput'],
46
-            10,
47
-            4
48
-        );
49
-    }
33
+	/**
34
+	 * CountryOptions constructor.
35
+	 *
36
+	 * @param string    $action
37
+	 * @param EEM_State $state_model
38
+	 */
39
+	public function __construct(string $action, EEM_State $state_model)
40
+	{
41
+		$this->action      = $action;
42
+		$this->state_model = $state_model;
43
+		add_filter(
44
+			'FHEE__EE_Question__generate_form_input__state_options',
45
+			[$this, 'forLegacyFormInput'],
46
+			10,
47
+			4
48
+		);
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * Gets the list of states for the form input
54
-     *
55
-     * @param array|null           $states_list deprecated prop from an old hook
56
-     * @param EE_Question|null     $question
57
-     * @param EE_Registration|null $registration
58
-     * @param EE_Answer|null       $answer
59
-     * @return array 2d keys are state IDs, values are their names
60
-     * @throws EE_Error
61
-     * @throws ReflectionException
62
-     */
63
-    public function forLegacyFormInput(
64
-        array $states_list = null,
65
-        EE_Question $question = null,
66
-        EE_Registration $registration = null,
67
-        EE_Answer $answer = null
68
-    ): array {
69
-        if (! isset($this->state_options[ $this->action ])) {
70
-            $this->generateLegacyStateOptions($question, $registration, $answer);
71
-        }
72
-        return $this->state_options[ $this->action ];
73
-    }
52
+	/**
53
+	 * Gets the list of states for the form input
54
+	 *
55
+	 * @param array|null           $states_list deprecated prop from an old hook
56
+	 * @param EE_Question|null     $question
57
+	 * @param EE_Registration|null $registration
58
+	 * @param EE_Answer|null       $answer
59
+	 * @return array 2d keys are state IDs, values are their names
60
+	 * @throws EE_Error
61
+	 * @throws ReflectionException
62
+	 */
63
+	public function forLegacyFormInput(
64
+		array $states_list = null,
65
+		EE_Question $question = null,
66
+		EE_Registration $registration = null,
67
+		EE_Answer $answer = null
68
+	): array {
69
+		if (! isset($this->state_options[ $this->action ])) {
70
+			$this->generateLegacyStateOptions($question, $registration, $answer);
71
+		}
72
+		return $this->state_options[ $this->action ];
73
+	}
74 74
 
75 75
 
76
-    /**
77
-     * @param EE_Question|null     $question
78
-     * @param EE_Registration|null $registration
79
-     * @param EE_Answer|null       $answer
80
-     * @throws EE_Error
81
-     * @throws ReflectionException
82
-     */
83
-    private function generateLegacyStateOptions(
84
-        EE_Question $question = null,
85
-        EE_Registration $registration = null,
86
-        EE_Answer $answer = null
87
-    ) {
88
-        $state_options = ['' => ['' => '']];
89
-        $states        = $this->action === 'process_reg_step'
90
-            ? $this->state_model->get_all_states()
91
-            : $this->state_model->get_all_active_states();
92
-        if (! empty($states)) {
93
-            foreach ($states as $state) {
94
-                if ($state instanceof EE_State) {
95
-                    $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
96
-                }
97
-            }
98
-        }
99
-        $this->state_options[ $this->action ] = apply_filters(
100
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
101
-            $state_options,
102
-            $this,
103
-            $registration,
104
-            $question,
105
-            $answer
106
-        );
107
-    }
76
+	/**
77
+	 * @param EE_Question|null     $question
78
+	 * @param EE_Registration|null $registration
79
+	 * @param EE_Answer|null       $answer
80
+	 * @throws EE_Error
81
+	 * @throws ReflectionException
82
+	 */
83
+	private function generateLegacyStateOptions(
84
+		EE_Question $question = null,
85
+		EE_Registration $registration = null,
86
+		EE_Answer $answer = null
87
+	) {
88
+		$state_options = ['' => ['' => '']];
89
+		$states        = $this->action === 'process_reg_step'
90
+			? $this->state_model->get_all_states()
91
+			: $this->state_model->get_all_active_states();
92
+		if (! empty($states)) {
93
+			foreach ($states as $state) {
94
+				if ($state instanceof EE_State) {
95
+					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
96
+				}
97
+			}
98
+		}
99
+		$this->state_options[ $this->action ] = apply_filters(
100
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
101
+			$state_options,
102
+			$this,
103
+			$registration,
104
+			$question,
105
+			$answer
106
+		);
107
+	}
108 108
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
         EE_Registration $registration = null,
67 67
         EE_Answer $answer = null
68 68
     ): array {
69
-        if (! isset($this->state_options[ $this->action ])) {
69
+        if ( ! isset($this->state_options[$this->action])) {
70 70
             $this->generateLegacyStateOptions($question, $registration, $answer);
71 71
         }
72
-        return $this->state_options[ $this->action ];
72
+        return $this->state_options[$this->action];
73 73
     }
74 74
 
75 75
 
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
         $states        = $this->action === 'process_reg_step'
90 90
             ? $this->state_model->get_all_states()
91 91
             : $this->state_model->get_all_active_states();
92
-        if (! empty($states)) {
92
+        if ( ! empty($states)) {
93 93
             foreach ($states as $state) {
94 94
                 if ($state instanceof EE_State) {
95
-                    $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
95
+                    $state_options[$state->country()->name()][$state->ID()] = $state->name();
96 96
                 }
97 97
             }
98 98
         }
99
-        $this->state_options[ $this->action ] = apply_filters(
99
+        $this->state_options[$this->action] = apply_filters(
100 100
             'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
101 101
             $state_options,
102 102
             $this,
Please login to merge, or discard this patch.
core/services/loaders/LoaderFactory.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -71,71 +71,71 @@
 block discarded – undo
71 71
 class LoaderFactory
72 72
 {
73 73
 
74
-    /**
75
-     * @var LoaderInterface $loader ;
76
-     */
77
-    private static $loader;
74
+	/**
75
+	 * @var LoaderInterface $loader ;
76
+	 */
77
+	private static $loader;
78 78
 
79 79
 
80
-    /**
81
-     * @param EE_Registry|CoffeeShop   $generator   provided during very first instantiation in
82
-     *                                              BootstrapDependencyInjectionContainer::buildLoader()
83
-     *                                              otherwise can be left null
84
-     * @param ClassInterfaceCache|null $class_cache also provided during first instantiation
85
-     * @param ObjectIdentifier|null    $object_identifier
86
-     * @return LoaderInterface
87
-     * @throws InvalidArgumentException
88
-     * @throws InvalidDataTypeException
89
-     * @throws InvalidInterfaceException
90
-     */
91
-    public static function getLoader(
92
-        $generator = null,
93
-        ClassInterfaceCache $class_cache = null,
94
-        ObjectIdentifier $object_identifier = null
95
-    ): LoaderInterface {
96
-        if (
97
-            ! LoaderFactory::$loader instanceof LoaderInterface
98
-            && ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)
99
-            && $class_cache instanceof ClassInterfaceCache
100
-            && $object_identifier instanceof ObjectIdentifier
101
-        ) {
102
-            $core_loader = new CoreLoader($generator);
103
-            LoaderFactory::$loader = new Loader(
104
-                $core_loader,
105
-                new CachingLoader(
106
-                    $core_loader,
107
-                    new LooseCollection(''),
108
-                    $object_identifier
109
-                ),
110
-                $class_cache
111
-            );
112
-        }
113
-        return LoaderFactory::$loader;
114
-    }
80
+	/**
81
+	 * @param EE_Registry|CoffeeShop   $generator   provided during very first instantiation in
82
+	 *                                              BootstrapDependencyInjectionContainer::buildLoader()
83
+	 *                                              otherwise can be left null
84
+	 * @param ClassInterfaceCache|null $class_cache also provided during first instantiation
85
+	 * @param ObjectIdentifier|null    $object_identifier
86
+	 * @return LoaderInterface
87
+	 * @throws InvalidArgumentException
88
+	 * @throws InvalidDataTypeException
89
+	 * @throws InvalidInterfaceException
90
+	 */
91
+	public static function getLoader(
92
+		$generator = null,
93
+		ClassInterfaceCache $class_cache = null,
94
+		ObjectIdentifier $object_identifier = null
95
+	): LoaderInterface {
96
+		if (
97
+			! LoaderFactory::$loader instanceof LoaderInterface
98
+			&& ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)
99
+			&& $class_cache instanceof ClassInterfaceCache
100
+			&& $object_identifier instanceof ObjectIdentifier
101
+		) {
102
+			$core_loader = new CoreLoader($generator);
103
+			LoaderFactory::$loader = new Loader(
104
+				$core_loader,
105
+				new CachingLoader(
106
+					$core_loader,
107
+					new LooseCollection(''),
108
+					$object_identifier
109
+				),
110
+				$class_cache
111
+			);
112
+		}
113
+		return LoaderFactory::$loader;
114
+	}
115 115
 
116 116
 
117
-    /**
118
-     * Used for instantiating a new instance of a class
119
-     *
120
-     * @param FullyQualifiedName|string $fqcn
121
-     * @param array                     $arguments
122
-     * @return mixed
123
-     */
124
-    public static function getNew($fqcn, array $arguments = [])
125
-    {
126
-        return LoaderFactory::getLoader()->getNew($fqcn, $arguments);
127
-    }
117
+	/**
118
+	 * Used for instantiating a new instance of a class
119
+	 *
120
+	 * @param FullyQualifiedName|string $fqcn
121
+	 * @param array                     $arguments
122
+	 * @return mixed
123
+	 */
124
+	public static function getNew($fqcn, array $arguments = [])
125
+	{
126
+		return LoaderFactory::getLoader()->getNew($fqcn, $arguments);
127
+	}
128 128
 
129 129
 
130
-    /**
131
-     * Used for getting a shared instance of a class
132
-     *
133
-     * @param FullyQualifiedName|string $fqcn
134
-     * @param array                     $arguments
135
-     * @return mixed
136
-     */
137
-    public static function getShared($fqcn, array $arguments = [])
138
-    {
139
-        return LoaderFactory::getLoader()->getShared($fqcn, $arguments);
140
-    }
130
+	/**
131
+	 * Used for getting a shared instance of a class
132
+	 *
133
+	 * @param FullyQualifiedName|string $fqcn
134
+	 * @param array                     $arguments
135
+	 * @return mixed
136
+	 */
137
+	public static function getShared($fqcn, array $arguments = [])
138
+	{
139
+		return LoaderFactory::getLoader()->getShared($fqcn, $arguments);
140
+	}
141 141
 }
Please login to merge, or discard this patch.
caffeinated/modules/event_single_caff/EED_Event_Single_Caff.module.php 2 patches
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -26,228 +26,228 @@
 block discarded – undo
26 26
 {
27 27
 
28 28
 
29
-    /**
30
-     * @return EED_Event_Single_Caff
31
-     */
32
-    public static function instance()
33
-    {
34
-        return parent::get_instance(__CLASS__);
35
-    }
36
-
37
-
38
-    /**
39
-     *    set_hooks - for hooking into EE Core, other modules, etc
40
-     *
41
-     * @access    public
42
-     * @return    void
43
-     */
44
-    public static function set_hooks()
45
-    {
46
-    }
47
-
48
-    /**
49
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
50
-     *
51
-     * @access    public
52
-     * @return    void
53
-     */
54
-    public static function set_hooks_admin()
55
-    {
56
-        self::setDefinitions();
57
-        add_action(
58
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings',
59
-            array('EED_Event_Single_Caff', 'load_scripts_styles'),
60
-            10
61
-        );
62
-        add_action(
63
-            'AHEE__template_settings__template__before_settings_form',
64
-            array('EED_Event_Single_Caff', 'template_settings_form'),
65
-            10
66
-        );
67
-        add_filter(
68
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
69
-            array('EED_Event_Single_Caff', 'update_template_settings'),
70
-            10,
71
-            2
72
-        );
73
-        // AJAX
74
-        add_action(
75
-            'wp_ajax_espresso_update_event_single_order',
76
-            array('EED_Event_Single_Caff', 'update_event_single_order')
77
-        );
78
-        add_action(
79
-            'wp_ajax_nopriv_espresso_update_event_single_order',
80
-            array('EED_Event_Single_Caff', 'update_event_single_order')
81
-        );
82
-    }
83
-
84
-
85
-    public static function load_scripts_styles()
86
-    {
87
-        add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10);
88
-    }
89
-
90
-
91
-    public static function enqueue_scripts_styles()
92
-    {
93
-        wp_register_style(
94
-            'eed-event-single-sortable',
95
-            EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css',
96
-            array(),
97
-            EVENT_ESPRESSO_VERSION
98
-        );
99
-        wp_enqueue_style('eed-event-single-sortable');
100
-        wp_register_script(
101
-            'eed-event-single-sortable',
102
-            EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js',
103
-            array('espresso_core', 'jquery-ui-sortable'),
104
-            EVENT_ESPRESSO_VERSION,
105
-            true
106
-        );
107
-        wp_enqueue_script('eed-event-single-sortable');
108
-    }
109
-
110
-
111
-    /**
112
-     * Set constants only if they haven't been set yet.
113
-     */
114
-    public static function setDefinitions()
115
-    {
116
-        if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) {
117
-            define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
118
-            define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
119
-        }
120
-    }
121
-
122
-
123
-    /**
124
-     *    template_settings_form
125
-     *
126
-     * @access    public
127
-     * @static
128
-     * @return    void
129
-     */
130
-    public static function template_settings_form()
131
-    {
132
-        $config = EE_Registry::instance()->CFG->template_settings;
133
-        $config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config
134
-            ? $config->EED_Event_Single : new EE_Event_Single_Config();
135
-        $config->use_sortable_display_order = isset($config->use_sortable_display_order)
136
-            ? $config->use_sortable_display_order : false;
137
-        $config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config);
138
-
139
-        $event_single_order_array = array();
140
-        $event_single_order_array[ $config->display_order_tickets ] = 'tickets';
141
-        $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes';
142
-        $event_single_order_array[ $config->display_order_event ] = 'event';
143
-        $event_single_order_array[ $config->display_order_venue ] = 'venue';
144
-        // get template parts
145
-        $template_parts = EED_Event_Single::instance()->initialize_template_parts($config);
146
-        // convert to array so that we can add more properties
147
-        $config = get_object_vars($config);
148
-        $config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts(
149
-            'event-single-sortable-js',
150
-            '',
151
-            'single-sortable-li single-sortable-js'
152
-        );
153
-        EEH_Template::display_template(
154
-            EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php',
155
-            $config
156
-        );
157
-    }
158
-
159
-
160
-    /**
161
-     * update_template_settings
162
-     *
163
-     * @param EE_Template_Config $CFG
164
-     * @param array              $REQ
165
-     * @return EE_Template_Config
166
-     */
167
-    public static function update_template_settings(EE_Template_Config $CFG, $REQ)
168
-    {
169
-        if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) {
170
-            $CFG->EED_Event_Single = new EE_Event_Single_Config();
171
-        }
172
-        $display_order_event = $CFG->EED_Event_Single->display_order_event !== null
173
-            ? $CFG->EED_Event_Single->display_order_event
174
-            : EED_Event_Single::EVENT_DETAILS_PRIORITY;
175
-        $display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null
176
-            ? $CFG->EED_Event_Single->display_order_datetimes
177
-            : EED_Event_Single::EVENT_DATETIMES_PRIORITY;
178
-        $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null
179
-            ? $CFG->EED_Event_Single->display_order_tickets
180
-            : EED_Event_Single::EVENT_TICKETS_PRIORITY;
181
-        $display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null
182
-            ? $CFG->EED_Event_Single->display_order_venue
183
-            : EED_Event_Single::EVENT_VENUES_PRIORITY;
184
-        $CFG->EED_Event_Single = new EE_Event_Single_Config();
185
-        $CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single'])
186
-                                                               && $REQ['display_status_banner_single'];
187
-        $CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue'];
188
-        $CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order'])
189
-            ? absint($REQ['EED_Events_Single_use_sortable_display_order'])
190
-            : 0;
191
-        $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order
192
-            ? $display_order_event
193
-            : EED_Event_Single::EVENT_DETAILS_PRIORITY;
194
-        $CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order
195
-            ? $display_order_datetimes
196
-            : EED_Event_Single::EVENT_DATETIMES_PRIORITY;
197
-        $CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order
198
-            ? $display_order_tickets
199
-            : EED_Event_Single::EVENT_TICKETS_PRIORITY;
200
-        $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order
201
-            ? $display_order_venue
202
-            : EED_Event_Single::EVENT_VENUES_PRIORITY;
203
-        do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ);
204
-        return $CFG;
205
-    }
206
-
207
-
208
-    /**
209
-     * update_event_single_order
210
-     *
211
-     * @access    public
212
-     * @return    void
213
-     */
214
-    public static function update_event_single_order()
215
-    {
216
-        $config_saved = false;
217
-        $template_parts = sanitize_text_field($_POST['elements']);
218
-        if (! empty($template_parts)) {
219
-            $template_parts = explode(',', trim($template_parts, ','));
220
-            foreach ($template_parts as $key => $template_part) {
221
-                $template_part = "display_order_$template_part";
222
-                $priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY;
223
-                EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority;
224
-                do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority);
225
-            }
226
-            $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false);
227
-        }
228
-        if ($config_saved) {
229
-            EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso'));
230
-        } else {
231
-            EE_Error::add_error(
232
-                __('Display Order was not updated.', 'event_espresso'),
233
-                __FILE__,
234
-                __FUNCTION__,
235
-                __LINE__
236
-            );
237
-        }
238
-        echo wp_json_encode(EE_Error::get_notices(false));
239
-        exit();
240
-    }
241
-
242
-
243
-    /**
244
-     *    run - initial module setup
245
-     *
246
-     * @access    public
247
-     * @param WP $WP
248
-     * @return    void
249
-     */
250
-    public function run($WP)
251
-    {
252
-    }
29
+	/**
30
+	 * @return EED_Event_Single_Caff
31
+	 */
32
+	public static function instance()
33
+	{
34
+		return parent::get_instance(__CLASS__);
35
+	}
36
+
37
+
38
+	/**
39
+	 *    set_hooks - for hooking into EE Core, other modules, etc
40
+	 *
41
+	 * @access    public
42
+	 * @return    void
43
+	 */
44
+	public static function set_hooks()
45
+	{
46
+	}
47
+
48
+	/**
49
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
50
+	 *
51
+	 * @access    public
52
+	 * @return    void
53
+	 */
54
+	public static function set_hooks_admin()
55
+	{
56
+		self::setDefinitions();
57
+		add_action(
58
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings',
59
+			array('EED_Event_Single_Caff', 'load_scripts_styles'),
60
+			10
61
+		);
62
+		add_action(
63
+			'AHEE__template_settings__template__before_settings_form',
64
+			array('EED_Event_Single_Caff', 'template_settings_form'),
65
+			10
66
+		);
67
+		add_filter(
68
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
69
+			array('EED_Event_Single_Caff', 'update_template_settings'),
70
+			10,
71
+			2
72
+		);
73
+		// AJAX
74
+		add_action(
75
+			'wp_ajax_espresso_update_event_single_order',
76
+			array('EED_Event_Single_Caff', 'update_event_single_order')
77
+		);
78
+		add_action(
79
+			'wp_ajax_nopriv_espresso_update_event_single_order',
80
+			array('EED_Event_Single_Caff', 'update_event_single_order')
81
+		);
82
+	}
83
+
84
+
85
+	public static function load_scripts_styles()
86
+	{
87
+		add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10);
88
+	}
89
+
90
+
91
+	public static function enqueue_scripts_styles()
92
+	{
93
+		wp_register_style(
94
+			'eed-event-single-sortable',
95
+			EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css',
96
+			array(),
97
+			EVENT_ESPRESSO_VERSION
98
+		);
99
+		wp_enqueue_style('eed-event-single-sortable');
100
+		wp_register_script(
101
+			'eed-event-single-sortable',
102
+			EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js',
103
+			array('espresso_core', 'jquery-ui-sortable'),
104
+			EVENT_ESPRESSO_VERSION,
105
+			true
106
+		);
107
+		wp_enqueue_script('eed-event-single-sortable');
108
+	}
109
+
110
+
111
+	/**
112
+	 * Set constants only if they haven't been set yet.
113
+	 */
114
+	public static function setDefinitions()
115
+	{
116
+		if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) {
117
+			define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
118
+			define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
119
+		}
120
+	}
121
+
122
+
123
+	/**
124
+	 *    template_settings_form
125
+	 *
126
+	 * @access    public
127
+	 * @static
128
+	 * @return    void
129
+	 */
130
+	public static function template_settings_form()
131
+	{
132
+		$config = EE_Registry::instance()->CFG->template_settings;
133
+		$config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config
134
+			? $config->EED_Event_Single : new EE_Event_Single_Config();
135
+		$config->use_sortable_display_order = isset($config->use_sortable_display_order)
136
+			? $config->use_sortable_display_order : false;
137
+		$config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config);
138
+
139
+		$event_single_order_array = array();
140
+		$event_single_order_array[ $config->display_order_tickets ] = 'tickets';
141
+		$event_single_order_array[ $config->display_order_datetimes ] = 'datetimes';
142
+		$event_single_order_array[ $config->display_order_event ] = 'event';
143
+		$event_single_order_array[ $config->display_order_venue ] = 'venue';
144
+		// get template parts
145
+		$template_parts = EED_Event_Single::instance()->initialize_template_parts($config);
146
+		// convert to array so that we can add more properties
147
+		$config = get_object_vars($config);
148
+		$config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts(
149
+			'event-single-sortable-js',
150
+			'',
151
+			'single-sortable-li single-sortable-js'
152
+		);
153
+		EEH_Template::display_template(
154
+			EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php',
155
+			$config
156
+		);
157
+	}
158
+
159
+
160
+	/**
161
+	 * update_template_settings
162
+	 *
163
+	 * @param EE_Template_Config $CFG
164
+	 * @param array              $REQ
165
+	 * @return EE_Template_Config
166
+	 */
167
+	public static function update_template_settings(EE_Template_Config $CFG, $REQ)
168
+	{
169
+		if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) {
170
+			$CFG->EED_Event_Single = new EE_Event_Single_Config();
171
+		}
172
+		$display_order_event = $CFG->EED_Event_Single->display_order_event !== null
173
+			? $CFG->EED_Event_Single->display_order_event
174
+			: EED_Event_Single::EVENT_DETAILS_PRIORITY;
175
+		$display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null
176
+			? $CFG->EED_Event_Single->display_order_datetimes
177
+			: EED_Event_Single::EVENT_DATETIMES_PRIORITY;
178
+		$display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null
179
+			? $CFG->EED_Event_Single->display_order_tickets
180
+			: EED_Event_Single::EVENT_TICKETS_PRIORITY;
181
+		$display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null
182
+			? $CFG->EED_Event_Single->display_order_venue
183
+			: EED_Event_Single::EVENT_VENUES_PRIORITY;
184
+		$CFG->EED_Event_Single = new EE_Event_Single_Config();
185
+		$CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single'])
186
+															   && $REQ['display_status_banner_single'];
187
+		$CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue'];
188
+		$CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order'])
189
+			? absint($REQ['EED_Events_Single_use_sortable_display_order'])
190
+			: 0;
191
+		$CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order
192
+			? $display_order_event
193
+			: EED_Event_Single::EVENT_DETAILS_PRIORITY;
194
+		$CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order
195
+			? $display_order_datetimes
196
+			: EED_Event_Single::EVENT_DATETIMES_PRIORITY;
197
+		$CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order
198
+			? $display_order_tickets
199
+			: EED_Event_Single::EVENT_TICKETS_PRIORITY;
200
+		$CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order
201
+			? $display_order_venue
202
+			: EED_Event_Single::EVENT_VENUES_PRIORITY;
203
+		do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ);
204
+		return $CFG;
205
+	}
206
+
207
+
208
+	/**
209
+	 * update_event_single_order
210
+	 *
211
+	 * @access    public
212
+	 * @return    void
213
+	 */
214
+	public static function update_event_single_order()
215
+	{
216
+		$config_saved = false;
217
+		$template_parts = sanitize_text_field($_POST['elements']);
218
+		if (! empty($template_parts)) {
219
+			$template_parts = explode(',', trim($template_parts, ','));
220
+			foreach ($template_parts as $key => $template_part) {
221
+				$template_part = "display_order_$template_part";
222
+				$priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY;
223
+				EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority;
224
+				do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority);
225
+			}
226
+			$config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false);
227
+		}
228
+		if ($config_saved) {
229
+			EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso'));
230
+		} else {
231
+			EE_Error::add_error(
232
+				__('Display Order was not updated.', 'event_espresso'),
233
+				__FILE__,
234
+				__FUNCTION__,
235
+				__LINE__
236
+			);
237
+		}
238
+		echo wp_json_encode(EE_Error::get_notices(false));
239
+		exit();
240
+	}
241
+
242
+
243
+	/**
244
+	 *    run - initial module setup
245
+	 *
246
+	 * @access    public
247
+	 * @param WP $WP
248
+	 * @return    void
249
+	 */
250
+	public function run($WP)
251
+	{
252
+	}
253 253
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
     {
93 93
         wp_register_style(
94 94
             'eed-event-single-sortable',
95
-            EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css',
95
+            EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.css',
96 96
             array(),
97 97
             EVENT_ESPRESSO_VERSION
98 98
         );
99 99
         wp_enqueue_style('eed-event-single-sortable');
100 100
         wp_register_script(
101 101
             'eed-event-single-sortable',
102
-            EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js',
102
+            EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.js',
103 103
             array('espresso_core', 'jquery-ui-sortable'),
104 104
             EVENT_ESPRESSO_VERSION,
105 105
             true
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public static function setDefinitions()
115 115
     {
116
-        if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) {
117
-            define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/');
118
-            define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
116
+        if ( ! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) {
117
+            define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates/');
118
+            define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
119 119
         }
120 120
     }
121 121
 
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
         $config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config);
138 138
 
139 139
         $event_single_order_array = array();
140
-        $event_single_order_array[ $config->display_order_tickets ] = 'tickets';
141
-        $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes';
142
-        $event_single_order_array[ $config->display_order_event ] = 'event';
143
-        $event_single_order_array[ $config->display_order_venue ] = 'venue';
140
+        $event_single_order_array[$config->display_order_tickets] = 'tickets';
141
+        $event_single_order_array[$config->display_order_datetimes] = 'datetimes';
142
+        $event_single_order_array[$config->display_order_event] = 'event';
143
+        $event_single_order_array[$config->display_order_venue] = 'venue';
144 144
         // get template parts
145 145
         $template_parts = EED_Event_Single::instance()->initialize_template_parts($config);
146 146
         // convert to array so that we can add more properties
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             'single-sortable-li single-sortable-js'
152 152
         );
153 153
         EEH_Template::display_template(
154
-            EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php',
154
+            EVENT_SINGLE_CAFF_TEMPLATES_PATH.'admin-event-single-settings.template.php',
155 155
             $config
156 156
         );
157 157
     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public static function update_template_settings(EE_Template_Config $CFG, $REQ)
168 168
     {
169
-        if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) {
169
+        if ( ! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) {
170 170
             $CFG->EED_Event_Single = new EE_Event_Single_Config();
171 171
         }
172 172
         $display_order_event = $CFG->EED_Event_Single->display_order_event !== null
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     {
216 216
         $config_saved = false;
217 217
         $template_parts = sanitize_text_field($_POST['elements']);
218
-        if (! empty($template_parts)) {
218
+        if ( ! empty($template_parts)) {
219 219
             $template_parts = explode(',', trim($template_parts, ','));
220 220
             foreach ($template_parts as $key => $template_part) {
221 221
                 $template_part = "display_order_$template_part";
Please login to merge, or discard this patch.