Completed
Branch FET/reg-form-builder/main (ce6323)
by
unknown
18:53 queued 08:52
created
core/db_models/EEM_Form_Input.model.php 2 patches
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -35,233 +35,233 @@
 block discarded – undo
35 35
 class EEM_Form_Input extends EEM_Form_Element
36 36
 {
37 37
 
38
-    /**
39
-     * @var EEM_Form_Input
40
-     */
41
-    protected static $_instance;
38
+	/**
39
+	 * @var EEM_Form_Input
40
+	 */
41
+	protected static $_instance;
42 42
 
43
-    /**
44
-     * @var RequestInterface
45
-     */
46
-    private $request;
43
+	/**
44
+	 * @var RequestInterface
45
+	 */
46
+	private $request;
47 47
 
48
-    /**
49
-     * @var array
50
-     */
51
-    private $input_types;
48
+	/**
49
+	 * @var array
50
+	 */
51
+	private $input_types;
52 52
 
53 53
 
54
-    protected function __construct(Element $element, InputTypes $input_types, $timezone = null)
55
-    {
56
-        $this->input_types = $input_types;
57
-        $this->singular_item = esc_html__('Form Input', 'event_espresso');
58
-        $this->plural_item   = esc_html__('Form Inputs', 'event_espresso');
54
+	protected function __construct(Element $element, InputTypes $input_types, $timezone = null)
55
+	{
56
+		$this->input_types = $input_types;
57
+		$this->singular_item = esc_html__('Form Input', 'event_espresso');
58
+		$this->plural_item   = esc_html__('Form Inputs', 'event_espresso');
59 59
 
60
-        $this->_tables          = [
61
-            'Form_Input' => new EE_Primary_Table('esp_form_input', 'FIN_ID'),
62
-        ];
63
-        $this->_fields          = [
64
-            'Form_Input' => [
65
-                'FIN_ID'        => new EE_Integer_Field(
66
-                    'FIN_ID',
67
-                    esc_html__('Form Input ID (autoincrement db id)', 'event_espresso'),
68
-                    false
69
-                ),
70
-                'FIN_UUID'      => new EE_Primary_Key_String_Field(
71
-                    'FIN_UUID',
72
-                    esc_html__('Form Input UUID (universally unique identifier)', 'event_espresso')
73
-                ),
74
-                'FIN_adminLabel' => new EE_Plain_Text_Field(
75
-                    'FIN_adminLabel',
76
-                    esc_html__(
77
-                        'Input label displayed in the admin to help differentiate input from others.',
78
-                        'event_espresso'
79
-                    ),
80
-                    true,
81
-                    null
82
-                ),
83
-                'FIN_adminOnly' => new EE_Boolean_Field(
84
-                    'FIN_adminOnly',
85
-                    esc_html__(
86
-                        'Whether or not input is only displayed in the admin. If false, input will appear in public forms',
87
-                        'event_espresso'
88
-                    ),
89
-                    false,
90
-                    false
91
-                ),
92
-                'FIN_belongsTo' => new EE_Foreign_Key_String_Field(
93
-                    'FIN_belongsTo',
94
-                    esc_html__('UUID of parent form section this form input belongs to.', 'event_espresso'),
95
-                    true,
96
-                    null,
97
-                    ['Form_Section']
98
-                ),
99
-                'FIN_helpClass' => new EE_Plain_Text_Field(
100
-                    'FIN_helpClass',
101
-                    esc_html__('Custom HTML classes to be applied to this form input\'s help text.', 'event_espresso'),
102
-                    true,
103
-                    null
104
-                ),
105
-                'FIN_helpText' => new EE_Plain_Text_Field(
106
-                    'FIN_helpText',
107
-                    esc_html__(
108
-                        'Additional text displayed alongside a form input to assist users with completing the form.',
109
-                        'event_espresso'
110
-                    ),
111
-                    true,
112
-                    null
113
-                ),
114
-                'FIN_htmlClass' => new EE_Plain_Text_Field(
115
-                    'FIN_htmlClass',
116
-                    esc_html__('HTML classes to be applied to this form input\'s container.', 'event_espresso'),
117
-                    true,
118
-                    null
119
-                ),
120
-                'FIN_max'     => new EE_Integer_Field(
121
-                    'FIN_max',
122
-                    esc_html__(
123
-                        'Maximum numeric value or maximum characters allowed for form input answer.',
124
-                        'event_espresso'
125
-                    ),
126
-                    false,
127
-                    EE_INF
128
-                ),
129
-                'FIN_min'     => new EE_Integer_Field(
130
-                    'FIN_min',
131
-                    esc_html__(
132
-                        'Minimum numeric value or minimum characters allowed for form input answer.',
133
-                        'event_espresso'
134
-                    ),
135
-                    true,
136
-                    null
137
-                ),
138
-                'FIN_order'     => new EE_Integer_Field(
139
-                    'FIN_order',
140
-                    esc_html__('Order in which form input appears in a form.', 'event_espresso'),
141
-                    false,
142
-                    0
143
-                ),
144
-                'FIN_placeholder' => new EE_Plain_Text_Field(
145
-                    'FIN_placeholder',
146
-                    esc_html__(
147
-                        'Example text displayed within an input to assist users with completing the form.',
148
-                        'event_espresso'
149
-                    ),
150
-                    true,
151
-                    null
152
-                ),
153
-                'FIN_publicLabel' => new EE_Plain_Text_Field(
154
-                    'FIN_publicLabel',
155
-                    esc_html__('Input label displayed on public forms, ie: the actual question text.', 'event_espresso'),
156
-                    true,
157
-                    null
158
-                ),
159
-                'FIN_required' => new EE_Boolean_Field(
160
-                    'FIN_required',
161
-                    esc_html__(
162
-                        'Whether or not the input must be supplied with a value in order to complete the form.',
163
-                        'event_espresso'
164
-                    ),
165
-                    false,
166
-                    false
167
-                ),
168
-                'FIN_requiredText' => new EE_Plain_Text_Field(
169
-                    'FIN_requiredText',
170
-                    esc_html__(
171
-                        'Custom validation text displayed alongside a required form input to assist users with completing the form.',
172
-                        'event_espresso'
173
-                    ),
174
-                    true,
175
-                    null
176
-                ),
177
-                'FIN_status'    => new EE_Enum_Text_Field(
178
-                    'FIN_status',
179
-                    esc_html__(
180
-                        'Whether form input is active, archived, trashed, or used as a default on new forms. Values correspond to the EEM_Form_Input::STATUS_* constants.',
181
-                        'event_espresso'
182
-                    ),
183
-                    false,
184
-                    Element::STATUS_ACTIVE,
185
-                    $element->validStatusOptions()
186
-                ),
187
-                'FIN_type'    => new EE_Enum_Text_Field(
188
-                    'FIN_type',
189
-                    esc_html__(
190
-                        'Form input type. Values correspond to the EventEspresso\core\domain\entities\form\Input::TYPE_* constants.',
191
-                        'event_espresso'
192
-                    ),
193
-                    false,
194
-                    Text::TYPE_TEXT,
195
-                    $this->validTypeOptions()
196
-                ),
197
-                'FIN_wpUser'    => new EE_WP_User_Field(
198
-                    'FIN_wpUser',
199
-                    esc_html__('ID of the WP User that created this form input.', 'event_espresso'),
200
-                    false
201
-                ),
202
-            ],
203
-        ];
204
-        $this->_model_relations = [];
205
-        $this->_model_relations['Form_Section'] = new EE_Belongs_To_Any_Relation();
206
-        // this model is generally available for reading
207
-        $restrictions                              = [];
208
-        $restrictions[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
209
-        $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
210
-        $restrictions[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
211
-        $restrictions[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
212
-        $this->_cap_restriction_generators         = $restrictions;
213
-        parent::__construct($element, $timezone);
214
-        $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
215
-    }
60
+		$this->_tables          = [
61
+			'Form_Input' => new EE_Primary_Table('esp_form_input', 'FIN_ID'),
62
+		];
63
+		$this->_fields          = [
64
+			'Form_Input' => [
65
+				'FIN_ID'        => new EE_Integer_Field(
66
+					'FIN_ID',
67
+					esc_html__('Form Input ID (autoincrement db id)', 'event_espresso'),
68
+					false
69
+				),
70
+				'FIN_UUID'      => new EE_Primary_Key_String_Field(
71
+					'FIN_UUID',
72
+					esc_html__('Form Input UUID (universally unique identifier)', 'event_espresso')
73
+				),
74
+				'FIN_adminLabel' => new EE_Plain_Text_Field(
75
+					'FIN_adminLabel',
76
+					esc_html__(
77
+						'Input label displayed in the admin to help differentiate input from others.',
78
+						'event_espresso'
79
+					),
80
+					true,
81
+					null
82
+				),
83
+				'FIN_adminOnly' => new EE_Boolean_Field(
84
+					'FIN_adminOnly',
85
+					esc_html__(
86
+						'Whether or not input is only displayed in the admin. If false, input will appear in public forms',
87
+						'event_espresso'
88
+					),
89
+					false,
90
+					false
91
+				),
92
+				'FIN_belongsTo' => new EE_Foreign_Key_String_Field(
93
+					'FIN_belongsTo',
94
+					esc_html__('UUID of parent form section this form input belongs to.', 'event_espresso'),
95
+					true,
96
+					null,
97
+					['Form_Section']
98
+				),
99
+				'FIN_helpClass' => new EE_Plain_Text_Field(
100
+					'FIN_helpClass',
101
+					esc_html__('Custom HTML classes to be applied to this form input\'s help text.', 'event_espresso'),
102
+					true,
103
+					null
104
+				),
105
+				'FIN_helpText' => new EE_Plain_Text_Field(
106
+					'FIN_helpText',
107
+					esc_html__(
108
+						'Additional text displayed alongside a form input to assist users with completing the form.',
109
+						'event_espresso'
110
+					),
111
+					true,
112
+					null
113
+				),
114
+				'FIN_htmlClass' => new EE_Plain_Text_Field(
115
+					'FIN_htmlClass',
116
+					esc_html__('HTML classes to be applied to this form input\'s container.', 'event_espresso'),
117
+					true,
118
+					null
119
+				),
120
+				'FIN_max'     => new EE_Integer_Field(
121
+					'FIN_max',
122
+					esc_html__(
123
+						'Maximum numeric value or maximum characters allowed for form input answer.',
124
+						'event_espresso'
125
+					),
126
+					false,
127
+					EE_INF
128
+				),
129
+				'FIN_min'     => new EE_Integer_Field(
130
+					'FIN_min',
131
+					esc_html__(
132
+						'Minimum numeric value or minimum characters allowed for form input answer.',
133
+						'event_espresso'
134
+					),
135
+					true,
136
+					null
137
+				),
138
+				'FIN_order'     => new EE_Integer_Field(
139
+					'FIN_order',
140
+					esc_html__('Order in which form input appears in a form.', 'event_espresso'),
141
+					false,
142
+					0
143
+				),
144
+				'FIN_placeholder' => new EE_Plain_Text_Field(
145
+					'FIN_placeholder',
146
+					esc_html__(
147
+						'Example text displayed within an input to assist users with completing the form.',
148
+						'event_espresso'
149
+					),
150
+					true,
151
+					null
152
+				),
153
+				'FIN_publicLabel' => new EE_Plain_Text_Field(
154
+					'FIN_publicLabel',
155
+					esc_html__('Input label displayed on public forms, ie: the actual question text.', 'event_espresso'),
156
+					true,
157
+					null
158
+				),
159
+				'FIN_required' => new EE_Boolean_Field(
160
+					'FIN_required',
161
+					esc_html__(
162
+						'Whether or not the input must be supplied with a value in order to complete the form.',
163
+						'event_espresso'
164
+					),
165
+					false,
166
+					false
167
+				),
168
+				'FIN_requiredText' => new EE_Plain_Text_Field(
169
+					'FIN_requiredText',
170
+					esc_html__(
171
+						'Custom validation text displayed alongside a required form input to assist users with completing the form.',
172
+						'event_espresso'
173
+					),
174
+					true,
175
+					null
176
+				),
177
+				'FIN_status'    => new EE_Enum_Text_Field(
178
+					'FIN_status',
179
+					esc_html__(
180
+						'Whether form input is active, archived, trashed, or used as a default on new forms. Values correspond to the EEM_Form_Input::STATUS_* constants.',
181
+						'event_espresso'
182
+					),
183
+					false,
184
+					Element::STATUS_ACTIVE,
185
+					$element->validStatusOptions()
186
+				),
187
+				'FIN_type'    => new EE_Enum_Text_Field(
188
+					'FIN_type',
189
+					esc_html__(
190
+						'Form input type. Values correspond to the EventEspresso\core\domain\entities\form\Input::TYPE_* constants.',
191
+						'event_espresso'
192
+					),
193
+					false,
194
+					Text::TYPE_TEXT,
195
+					$this->validTypeOptions()
196
+				),
197
+				'FIN_wpUser'    => new EE_WP_User_Field(
198
+					'FIN_wpUser',
199
+					esc_html__('ID of the WP User that created this form input.', 'event_espresso'),
200
+					false
201
+				),
202
+			],
203
+		];
204
+		$this->_model_relations = [];
205
+		$this->_model_relations['Form_Section'] = new EE_Belongs_To_Any_Relation();
206
+		// this model is generally available for reading
207
+		$restrictions                              = [];
208
+		$restrictions[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
209
+		$restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
210
+		$restrictions[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
211
+		$restrictions[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
212
+		$this->_cap_restriction_generators         = $restrictions;
213
+		parent::__construct($element, $timezone);
214
+		$this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
215
+	}
216 216
 
217 217
 
218
-    /**
219
-     * @param bool $constants_only
220
-     * @return array
221
-     */
222
-    public function validTypeOptions(bool $constants_only = false): array
223
-    {
224
-        return $this->input_types->validTypeOptions($constants_only);
225
-    }
218
+	/**
219
+	 * @param bool $constants_only
220
+	 * @return array
221
+	 */
222
+	public function validTypeOptions(bool $constants_only = false): array
223
+	{
224
+		return $this->input_types->validTypeOptions($constants_only);
225
+	}
226 226
 
227 227
 
228
-    /**
229
-     * @return EE_Form_Input[]
230
-     * @throws EE_Error
231
-     */
232
-    public function getFormInputsForSection(string $relation, string $related_UUID): array
233
-    {
234
-        $where_params = [$relation => $related_UUID];
235
-        $query_params = $this->addDefaultWhereConditions([$where_params]);
236
-        $query_params = $this->addOrderByQueryParams($query_params);
237
-        return $this->get_all($query_params);
238
-    }
228
+	/**
229
+	 * @return EE_Form_Input[]
230
+	 * @throws EE_Error
231
+	 */
232
+	public function getFormInputsForSection(string $relation, string $related_UUID): array
233
+	{
234
+		$where_params = [$relation => $related_UUID];
235
+		$query_params = $this->addDefaultWhereConditions([$where_params]);
236
+		$query_params = $this->addOrderByQueryParams($query_params);
237
+		return $this->get_all($query_params);
238
+	}
239 239
 
240 240
 
241
-    /**
242
-     * @param array $query_params
243
-     * @return array
244
-     */
245
-    private function addDefaultWhereConditions(array $query_params): array
246
-    {
247
-        // might need to add a way to identify GQL requests for admin domains
248
-        $admin_request                            = $this->request->isAdmin() || $this->request->isAdminAjax();
249
-        $query_params['default_where_conditions'] = $admin_request
250
-            ? EEM_Base::default_where_conditions_none
251
-            : EEM_Base::default_where_conditions_all;
252
-        return $query_params;
253
-    }
241
+	/**
242
+	 * @param array $query_params
243
+	 * @return array
244
+	 */
245
+	private function addDefaultWhereConditions(array $query_params): array
246
+	{
247
+		// might need to add a way to identify GQL requests for admin domains
248
+		$admin_request                            = $this->request->isAdmin() || $this->request->isAdminAjax();
249
+		$query_params['default_where_conditions'] = $admin_request
250
+			? EEM_Base::default_where_conditions_none
251
+			: EEM_Base::default_where_conditions_all;
252
+		return $query_params;
253
+	}
254 254
 
255 255
 
256
-    /**
257
-     * form inputs should always be sorted in ascending order via the FIN_order field
258
-     *
259
-     * @param array $query_params
260
-     * @return array
261
-     */
262
-    private function addOrderByQueryParams(array $query_params): array
263
-    {
264
-        $query_params['order_by'] = ['FIN_order' => 'ASC'];
265
-        return $query_params;
266
-    }
256
+	/**
257
+	 * form inputs should always be sorted in ascending order via the FIN_order field
258
+	 *
259
+	 * @param array $query_params
260
+	 * @return array
261
+	 */
262
+	private function addOrderByQueryParams(array $query_params): array
263
+	{
264
+		$query_params['order_by'] = ['FIN_order' => 'ASC'];
265
+		return $query_params;
266
+	}
267 267
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -205,10 +205,10 @@
 block discarded – undo
205 205
         $this->_model_relations['Form_Section'] = new EE_Belongs_To_Any_Relation();
206 206
         // this model is generally available for reading
207 207
         $restrictions                              = [];
208
-        $restrictions[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
209
-        $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
210
-        $restrictions[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
211
-        $restrictions[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
208
+        $restrictions[EEM_Base::caps_read]       = new EE_Restriction_Generator_Public();
209
+        $restrictions[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
210
+        $restrictions[EEM_Base::caps_edit]       = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
211
+        $restrictions[EEM_Base::caps_delete]     = new EE_Restriction_Generator_Reg_Form('FIN_applies_to');
212 212
         $this->_cap_restriction_generators         = $restrictions;
213 213
         parent::__construct($element, $timezone);
214 214
         $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
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.
core/db_classes/EE_Form_Input.class.php 1 patch
Indentation   +445 added lines, -445 removed lines patch added patch discarded remove patch
@@ -28,449 +28,449 @@
 block discarded – undo
28 28
 class EE_Form_Input extends EE_Base_Class
29 29
 {
30 30
 
31
-    /**
32
-     * @param array $props_n_values
33
-     * @return EE_Form_Input
34
-     * @throws EE_Error
35
-     * @throws ReflectionException
36
-     */
37
-    public static function new_instance(array $props_n_values = []): EE_Form_Input
38
-    {
39
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
40
-        return $has_object
41
-            ?: new self($props_n_values);
42
-    }
43
-
44
-
45
-    /**
46
-     * @param array $props_n_values
47
-     * @return EE_Form_Input
48
-     * @throws EE_Error
49
-     * @throws ReflectionException
50
-     */
51
-    public static function new_instance_from_db(array $props_n_values = []): EE_Form_Input
52
-    {
53
-        return new self($props_n_values);
54
-    }
55
-
56
-
57
-    /**
58
-     * Form Input UUID (universally unique identifier)
59
-     *
60
-     * @return string
61
-     * @throws EE_Error
62
-     * @throws ReflectionException
63
-     */
64
-    public function UUID(): string
65
-    {
66
-        return $this->get('FIN_UUID');
67
-    }
68
-
69
-
70
-    /**
71
-     * @param string $UUID
72
-     * @throws EE_Error
73
-     * @throws ReflectionException
74
-     */
75
-    public function setUUID(string $UUID)
76
-    {
77
-        $this->set('FIN_UUID', $UUID);
78
-    }
79
-
80
-
81
-    /**
82
-     * Input label displayed in the admin to help differentiate input from others
83
-     *
84
-     * @return string
85
-     * @throws EE_Error
86
-     * @throws ReflectionException
87
-     */
88
-    public function adminLabel(): string
89
-    {
90
-        return $this->get('FIN_adminLabel');
91
-    }
92
-
93
-
94
-    /**
95
-     * @param string $admin_label
96
-     * @throws EE_Error
97
-     * @throws ReflectionException
98
-     */
99
-    public function setAdminLabel(string $admin_label)
100
-    {
101
-        $this->set('FIN_adminLabel', $admin_label);
102
-    }
103
-
104
-
105
-    /**
106
-     * Whether or not input is only displayed in the admin. If false, input will appear in public forms
107
-     *
108
-     * @return bool
109
-     * @throws EE_Error
110
-     * @throws ReflectionException
111
-     */
112
-    public function adminOnly(): bool
113
-    {
114
-        return $this->get('FIN_adminOnly');
115
-    }
116
-
117
-
118
-    /**
119
-     * @param bool $admin_only
120
-     * @throws EE_Error
121
-     * @throws ReflectionException
122
-     */
123
-    public function setAdminOnly(bool $admin_only)
124
-    {
125
-        $this->set('FIN_adminOnly', $admin_only);
126
-    }
127
-
128
-
129
-    /**
130
-     * UUID of parent form section this form input belongs to.
131
-     *
132
-     * @return string
133
-     * @throws EE_Error
134
-     * @throws ReflectionException
135
-     */
136
-    public function belongsTo(): string
137
-    {
138
-        return $this->get('FIN_belongsTo');
139
-    }
140
-
141
-
142
-    /**
143
-     * @param string $relation_UUID
144
-     * @throws EE_Error
145
-     * @throws ReflectionException
146
-     */
147
-    public function setBelongsTo(string $relation_UUID)
148
-    {
149
-        $this->set('FIN_belongsTo', $relation_UUID);
150
-    }
151
-
152
-
153
-    /**
154
-     * Custom HTML classes to be applied to this form input's help text.
155
-     *
156
-     * @return string
157
-     * @throws EE_Error
158
-     * @throws ReflectionException
159
-     */
160
-    public function helpClass(): string
161
-    {
162
-        return $this->get('FIN_helpClass');
163
-    }
164
-
165
-
166
-    /**
167
-     * @param string $help_class
168
-     * @throws EE_Error
169
-     * @throws ReflectionException
170
-     */
171
-    public function setHelpClass(string $help_class)
172
-    {
173
-        $this->set('FIN_helpClass', $help_class);
174
-    }
175
-
176
-
177
-    /**
178
-     * Additional text displayed alongside a form input to assist users with completing the form.
179
-     *
180
-     * @return string
181
-     * @throws EE_Error
182
-     * @throws ReflectionException
183
-     */
184
-    public function helpText(): string
185
-    {
186
-        return $this->get('FIN_helpText');
187
-    }
188
-
189
-
190
-    /**
191
-     * @param string $help_text
192
-     * @throws EE_Error
193
-     * @throws ReflectionException
194
-     */
195
-    public function setHelpText(string $help_text)
196
-    {
197
-        $this->set('FIN_helpText', $help_text);
198
-    }
199
-
200
-
201
-    /**
202
-     * HTML classes to be applied to this form input's container.
203
-     *
204
-     * @return string
205
-     * @throws EE_Error
206
-     * @throws ReflectionException
207
-     */
208
-    public function htmlClass(): string
209
-    {
210
-        return $this->get('FIN_htmlClass');
211
-    }
212
-
213
-
214
-    /**
215
-     * HTML classes to be applied to this form input's container.
216
-     *
217
-     * @param string $html_class
218
-     * @throws EE_Error
219
-     * @throws ReflectionException
220
-     */
221
-    public function setHtmlClass(string $html_class)
222
-    {
223
-        $this->set('FIN_htmlClass', $html_class);
224
-    }
225
-
226
-
227
-    /**
228
-     * Maximum numeric value or maximum characters allowed for form input answer.
229
-     *
230
-     * @return int
231
-     * @throws EE_Error
232
-     * @throws ReflectionException
233
-     */
234
-    public function max(): int
235
-    {
236
-        return $this->get('FIN_max');
237
-    }
238
-
239
-
240
-    /**
241
-     * @param int $max
242
-     * @throws EE_Error
243
-     * @throws ReflectionException
244
-     */
245
-    public function setMax(int $max)
246
-    {
247
-        $this->set('FIN_max', $max);
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * Minimum numeric value or minimum characters allowed for form input answer.
254
-     *
255
-     * @return int
256
-     * @throws EE_Error
257
-     * @throws ReflectionException
258
-     */
259
-    public function min(): int
260
-    {
261
-        return $this->get('FIN_min');
262
-    }
263
-
264
-
265
-    /**
266
-     * @param int $min
267
-     * @throws EE_Error
268
-     * @throws ReflectionException
269
-     */
270
-    public function setMin(int $min)
271
-    {
272
-        $this->set('FIN_min', $min);
273
-    }
274
-
275
-
276
-
277
-    /**
278
-     * Order in which form input appears in a form.
279
-     *
280
-     * @return int
281
-     * @throws EE_Error
282
-     * @throws ReflectionException
283
-     */
284
-    public function order(): int
285
-    {
286
-        return $this->get('FIN_order');
287
-    }
288
-
289
-
290
-    /**
291
-     * Order in which form input appears in a form.
292
-     *
293
-     * @param int $order
294
-     * @throws EE_Error
295
-     * @throws ReflectionException
296
-     */
297
-    public function setOrder(int $order)
298
-    {
299
-        $this->set('FIN_order', $order);
300
-    }
301
-
302
-
303
-    /**
304
-     * Example text displayed within an input to assist users with completing the form.
305
-     *
306
-     * @return string
307
-     * @throws EE_Error
308
-     * @throws ReflectionException
309
-     */
310
-    public function placeholder(): string
311
-    {
312
-        return $this->get('FIN_placeholder');
313
-    }
314
-
315
-
316
-    /**
317
-     * @param string $placeholder
318
-     * @throws EE_Error
319
-     * @throws ReflectionException
320
-     */
321
-    public function setPlaceholder(string $placeholder)
322
-    {
323
-        $this->set('FIN_placeholder', $placeholder);
324
-    }
325
-
326
-
327
-    /**
328
-     * Input label displayed on public forms, ie: the actual question text.
329
-     *
330
-     * @return string
331
-     * @throws EE_Error
332
-     * @throws ReflectionException
333
-     */
334
-    public function publicLabel(): string
335
-    {
336
-        return $this->get('FIN_publicLabel');
337
-    }
338
-
339
-
340
-    /**
341
-     * @param string $publicLabel
342
-     * @throws EE_Error
343
-     * @throws ReflectionException
344
-     */
345
-    public function setPublicLabel(string $publicLabel)
346
-    {
347
-        $this->set('FIN_publicLabel', $publicLabel);
348
-    }
349
-
350
-
351
-    /**
352
-     * Whether or not the input must be supplied with a value in order to complete the form.
353
-     *
354
-     * @return bool
355
-     * @throws EE_Error
356
-     * @throws ReflectionException
357
-     */
358
-    public function required(): bool
359
-    {
360
-        return $this->get('FIN_required');
361
-    }
362
-
363
-
364
-    /**
365
-     * @param bool $required
366
-     * @throws EE_Error
367
-     * @throws ReflectionException
368
-     */
369
-    public function setRequired(bool $required)
370
-    {
371
-        $this->set('FIN_required', $required);
372
-    }
373
-
374
-
375
-    /**
376
-     * Custom validation text displayed alongside a required form input to assist users with completing the form.
377
-     *
378
-     * @return string
379
-     * @throws EE_Error
380
-     * @throws ReflectionException
381
-     */
382
-    public function requiredText(): string
383
-    {
384
-        return $this->get('FIN_requiredText');
385
-    }
386
-
387
-
388
-    /**
389
-     * @param string $requiredText
390
-     * @throws EE_Error
391
-     * @throws ReflectionException
392
-     */
393
-    public function setRequiredText(string $requiredText)
394
-    {
395
-        $this->set('FIN_requiredText', $requiredText);
396
-    }
397
-
398
-
399
-    /**
400
-     * Whether form input is active, archived, trashed, or used as a default on new forms.
401
-     * Values correspond to the EEM_Form_Input::STATUS_* constants.
402
-     *
403
-     * @return string
404
-     * @throws EE_Error
405
-     * @throws ReflectionException
406
-     */
407
-    public function status(): string
408
-    {
409
-        return $this->get('FIN_status');
410
-    }
411
-
412
-
413
-    /**
414
-     * Whether form input is active, archived, trashed, or used as a default on new forms.
415
-     * Values correspond to the EEM_Form_Input::STATUS_* constants.
416
-     *
417
-     * @param string $status
418
-     * @throws EE_Error
419
-     * @throws ReflectionException
420
-     */
421
-    public function setStatus(string $status)
422
-    {
423
-        $this->set('FIN_status', $status);
424
-    }
425
-
426
-
427
-    /**
428
-     * Form input type.
429
-     * Values correspond to the EventEspresso\core\domain\entities\form\Input::TYPE_* constants.
430
-     *
431
-     * @return string
432
-     * @throws EE_Error
433
-     * @throws ReflectionException
434
-     */
435
-    public function type(): string
436
-    {
437
-        return $this->get('FIN_type');
438
-    }
439
-
440
-
441
-    /**
442
-     * @param string $type
443
-     * @throws EE_Error
444
-     * @throws ReflectionException
445
-     */
446
-    public function setType(string $type)
447
-    {
448
-        $this->set('FIN_type', $type);
449
-    }
450
-
451
-
452
-    /**
453
-     * ID of the WP User that created this form input.
454
-     *
455
-     * @return int
456
-     * @throws EE_Error
457
-     * @throws ReflectionException
458
-     */
459
-    public function wpUser(): int
460
-    {
461
-        return $this->get('FIN_wpUser');
462
-    }
463
-
464
-
465
-    /**
466
-     * returns the id the wordpress user who created this question
467
-     *
468
-     * @param int $wp_user
469
-     * @throws EE_Error
470
-     * @throws ReflectionException
471
-     */
472
-    public function setWpUser(int $wp_user)
473
-    {
474
-        $this->set('FIN_wpUser', $wp_user);
475
-    }
31
+	/**
32
+	 * @param array $props_n_values
33
+	 * @return EE_Form_Input
34
+	 * @throws EE_Error
35
+	 * @throws ReflectionException
36
+	 */
37
+	public static function new_instance(array $props_n_values = []): EE_Form_Input
38
+	{
39
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
40
+		return $has_object
41
+			?: new self($props_n_values);
42
+	}
43
+
44
+
45
+	/**
46
+	 * @param array $props_n_values
47
+	 * @return EE_Form_Input
48
+	 * @throws EE_Error
49
+	 * @throws ReflectionException
50
+	 */
51
+	public static function new_instance_from_db(array $props_n_values = []): EE_Form_Input
52
+	{
53
+		return new self($props_n_values);
54
+	}
55
+
56
+
57
+	/**
58
+	 * Form Input UUID (universally unique identifier)
59
+	 *
60
+	 * @return string
61
+	 * @throws EE_Error
62
+	 * @throws ReflectionException
63
+	 */
64
+	public function UUID(): string
65
+	{
66
+		return $this->get('FIN_UUID');
67
+	}
68
+
69
+
70
+	/**
71
+	 * @param string $UUID
72
+	 * @throws EE_Error
73
+	 * @throws ReflectionException
74
+	 */
75
+	public function setUUID(string $UUID)
76
+	{
77
+		$this->set('FIN_UUID', $UUID);
78
+	}
79
+
80
+
81
+	/**
82
+	 * Input label displayed in the admin to help differentiate input from others
83
+	 *
84
+	 * @return string
85
+	 * @throws EE_Error
86
+	 * @throws ReflectionException
87
+	 */
88
+	public function adminLabel(): string
89
+	{
90
+		return $this->get('FIN_adminLabel');
91
+	}
92
+
93
+
94
+	/**
95
+	 * @param string $admin_label
96
+	 * @throws EE_Error
97
+	 * @throws ReflectionException
98
+	 */
99
+	public function setAdminLabel(string $admin_label)
100
+	{
101
+		$this->set('FIN_adminLabel', $admin_label);
102
+	}
103
+
104
+
105
+	/**
106
+	 * Whether or not input is only displayed in the admin. If false, input will appear in public forms
107
+	 *
108
+	 * @return bool
109
+	 * @throws EE_Error
110
+	 * @throws ReflectionException
111
+	 */
112
+	public function adminOnly(): bool
113
+	{
114
+		return $this->get('FIN_adminOnly');
115
+	}
116
+
117
+
118
+	/**
119
+	 * @param bool $admin_only
120
+	 * @throws EE_Error
121
+	 * @throws ReflectionException
122
+	 */
123
+	public function setAdminOnly(bool $admin_only)
124
+	{
125
+		$this->set('FIN_adminOnly', $admin_only);
126
+	}
127
+
128
+
129
+	/**
130
+	 * UUID of parent form section this form input belongs to.
131
+	 *
132
+	 * @return string
133
+	 * @throws EE_Error
134
+	 * @throws ReflectionException
135
+	 */
136
+	public function belongsTo(): string
137
+	{
138
+		return $this->get('FIN_belongsTo');
139
+	}
140
+
141
+
142
+	/**
143
+	 * @param string $relation_UUID
144
+	 * @throws EE_Error
145
+	 * @throws ReflectionException
146
+	 */
147
+	public function setBelongsTo(string $relation_UUID)
148
+	{
149
+		$this->set('FIN_belongsTo', $relation_UUID);
150
+	}
151
+
152
+
153
+	/**
154
+	 * Custom HTML classes to be applied to this form input's help text.
155
+	 *
156
+	 * @return string
157
+	 * @throws EE_Error
158
+	 * @throws ReflectionException
159
+	 */
160
+	public function helpClass(): string
161
+	{
162
+		return $this->get('FIN_helpClass');
163
+	}
164
+
165
+
166
+	/**
167
+	 * @param string $help_class
168
+	 * @throws EE_Error
169
+	 * @throws ReflectionException
170
+	 */
171
+	public function setHelpClass(string $help_class)
172
+	{
173
+		$this->set('FIN_helpClass', $help_class);
174
+	}
175
+
176
+
177
+	/**
178
+	 * Additional text displayed alongside a form input to assist users with completing the form.
179
+	 *
180
+	 * @return string
181
+	 * @throws EE_Error
182
+	 * @throws ReflectionException
183
+	 */
184
+	public function helpText(): string
185
+	{
186
+		return $this->get('FIN_helpText');
187
+	}
188
+
189
+
190
+	/**
191
+	 * @param string $help_text
192
+	 * @throws EE_Error
193
+	 * @throws ReflectionException
194
+	 */
195
+	public function setHelpText(string $help_text)
196
+	{
197
+		$this->set('FIN_helpText', $help_text);
198
+	}
199
+
200
+
201
+	/**
202
+	 * HTML classes to be applied to this form input's container.
203
+	 *
204
+	 * @return string
205
+	 * @throws EE_Error
206
+	 * @throws ReflectionException
207
+	 */
208
+	public function htmlClass(): string
209
+	{
210
+		return $this->get('FIN_htmlClass');
211
+	}
212
+
213
+
214
+	/**
215
+	 * HTML classes to be applied to this form input's container.
216
+	 *
217
+	 * @param string $html_class
218
+	 * @throws EE_Error
219
+	 * @throws ReflectionException
220
+	 */
221
+	public function setHtmlClass(string $html_class)
222
+	{
223
+		$this->set('FIN_htmlClass', $html_class);
224
+	}
225
+
226
+
227
+	/**
228
+	 * Maximum numeric value or maximum characters allowed for form input answer.
229
+	 *
230
+	 * @return int
231
+	 * @throws EE_Error
232
+	 * @throws ReflectionException
233
+	 */
234
+	public function max(): int
235
+	{
236
+		return $this->get('FIN_max');
237
+	}
238
+
239
+
240
+	/**
241
+	 * @param int $max
242
+	 * @throws EE_Error
243
+	 * @throws ReflectionException
244
+	 */
245
+	public function setMax(int $max)
246
+	{
247
+		$this->set('FIN_max', $max);
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * Minimum numeric value or minimum characters allowed for form input answer.
254
+	 *
255
+	 * @return int
256
+	 * @throws EE_Error
257
+	 * @throws ReflectionException
258
+	 */
259
+	public function min(): int
260
+	{
261
+		return $this->get('FIN_min');
262
+	}
263
+
264
+
265
+	/**
266
+	 * @param int $min
267
+	 * @throws EE_Error
268
+	 * @throws ReflectionException
269
+	 */
270
+	public function setMin(int $min)
271
+	{
272
+		$this->set('FIN_min', $min);
273
+	}
274
+
275
+
276
+
277
+	/**
278
+	 * Order in which form input appears in a form.
279
+	 *
280
+	 * @return int
281
+	 * @throws EE_Error
282
+	 * @throws ReflectionException
283
+	 */
284
+	public function order(): int
285
+	{
286
+		return $this->get('FIN_order');
287
+	}
288
+
289
+
290
+	/**
291
+	 * Order in which form input appears in a form.
292
+	 *
293
+	 * @param int $order
294
+	 * @throws EE_Error
295
+	 * @throws ReflectionException
296
+	 */
297
+	public function setOrder(int $order)
298
+	{
299
+		$this->set('FIN_order', $order);
300
+	}
301
+
302
+
303
+	/**
304
+	 * Example text displayed within an input to assist users with completing the form.
305
+	 *
306
+	 * @return string
307
+	 * @throws EE_Error
308
+	 * @throws ReflectionException
309
+	 */
310
+	public function placeholder(): string
311
+	{
312
+		return $this->get('FIN_placeholder');
313
+	}
314
+
315
+
316
+	/**
317
+	 * @param string $placeholder
318
+	 * @throws EE_Error
319
+	 * @throws ReflectionException
320
+	 */
321
+	public function setPlaceholder(string $placeholder)
322
+	{
323
+		$this->set('FIN_placeholder', $placeholder);
324
+	}
325
+
326
+
327
+	/**
328
+	 * Input label displayed on public forms, ie: the actual question text.
329
+	 *
330
+	 * @return string
331
+	 * @throws EE_Error
332
+	 * @throws ReflectionException
333
+	 */
334
+	public function publicLabel(): string
335
+	{
336
+		return $this->get('FIN_publicLabel');
337
+	}
338
+
339
+
340
+	/**
341
+	 * @param string $publicLabel
342
+	 * @throws EE_Error
343
+	 * @throws ReflectionException
344
+	 */
345
+	public function setPublicLabel(string $publicLabel)
346
+	{
347
+		$this->set('FIN_publicLabel', $publicLabel);
348
+	}
349
+
350
+
351
+	/**
352
+	 * Whether or not the input must be supplied with a value in order to complete the form.
353
+	 *
354
+	 * @return bool
355
+	 * @throws EE_Error
356
+	 * @throws ReflectionException
357
+	 */
358
+	public function required(): bool
359
+	{
360
+		return $this->get('FIN_required');
361
+	}
362
+
363
+
364
+	/**
365
+	 * @param bool $required
366
+	 * @throws EE_Error
367
+	 * @throws ReflectionException
368
+	 */
369
+	public function setRequired(bool $required)
370
+	{
371
+		$this->set('FIN_required', $required);
372
+	}
373
+
374
+
375
+	/**
376
+	 * Custom validation text displayed alongside a required form input to assist users with completing the form.
377
+	 *
378
+	 * @return string
379
+	 * @throws EE_Error
380
+	 * @throws ReflectionException
381
+	 */
382
+	public function requiredText(): string
383
+	{
384
+		return $this->get('FIN_requiredText');
385
+	}
386
+
387
+
388
+	/**
389
+	 * @param string $requiredText
390
+	 * @throws EE_Error
391
+	 * @throws ReflectionException
392
+	 */
393
+	public function setRequiredText(string $requiredText)
394
+	{
395
+		$this->set('FIN_requiredText', $requiredText);
396
+	}
397
+
398
+
399
+	/**
400
+	 * Whether form input is active, archived, trashed, or used as a default on new forms.
401
+	 * Values correspond to the EEM_Form_Input::STATUS_* constants.
402
+	 *
403
+	 * @return string
404
+	 * @throws EE_Error
405
+	 * @throws ReflectionException
406
+	 */
407
+	public function status(): string
408
+	{
409
+		return $this->get('FIN_status');
410
+	}
411
+
412
+
413
+	/**
414
+	 * Whether form input is active, archived, trashed, or used as a default on new forms.
415
+	 * Values correspond to the EEM_Form_Input::STATUS_* constants.
416
+	 *
417
+	 * @param string $status
418
+	 * @throws EE_Error
419
+	 * @throws ReflectionException
420
+	 */
421
+	public function setStatus(string $status)
422
+	{
423
+		$this->set('FIN_status', $status);
424
+	}
425
+
426
+
427
+	/**
428
+	 * Form input type.
429
+	 * Values correspond to the EventEspresso\core\domain\entities\form\Input::TYPE_* constants.
430
+	 *
431
+	 * @return string
432
+	 * @throws EE_Error
433
+	 * @throws ReflectionException
434
+	 */
435
+	public function type(): string
436
+	{
437
+		return $this->get('FIN_type');
438
+	}
439
+
440
+
441
+	/**
442
+	 * @param string $type
443
+	 * @throws EE_Error
444
+	 * @throws ReflectionException
445
+	 */
446
+	public function setType(string $type)
447
+	{
448
+		$this->set('FIN_type', $type);
449
+	}
450
+
451
+
452
+	/**
453
+	 * ID of the WP User that created this form input.
454
+	 *
455
+	 * @return int
456
+	 * @throws EE_Error
457
+	 * @throws ReflectionException
458
+	 */
459
+	public function wpUser(): int
460
+	{
461
+		return $this->get('FIN_wpUser');
462
+	}
463
+
464
+
465
+	/**
466
+	 * returns the id the wordpress user who created this question
467
+	 *
468
+	 * @param int $wp_user
469
+	 * @throws EE_Error
470
+	 * @throws ReflectionException
471
+	 */
472
+	public function setWpUser(int $wp_user)
473
+	{
474
+		$this->set('FIN_wpUser', $wp_user);
475
+	}
476 476
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Form_Section.class.php 1 patch
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -19,225 +19,225 @@
 block discarded – undo
19 19
 class EE_Form_Section extends EE_Base_Class
20 20
 {
21 21
 
22
-    /**
23
-     * @param array $props_n_values
24
-     * @return EE_Form_Section
25
-     * @throws EE_Error
26
-     * @throws ReflectionException
27
-     */
28
-    public static function new_instance(array $props_n_values = []): EE_Form_Section
29
-    {
30
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
31
-        return $has_object
32
-            ?: new self($props_n_values);
33
-    }
34
-
35
-
36
-    /**
37
-     * @param array $props_n_values
38
-     * @return EE_Form_Section
39
-     * @throws EE_Error
40
-     * @throws ReflectionException
41
-     */
42
-    public static function new_instance_from_db(array $props_n_values = []): EE_Form_Section
43
-    {
44
-        return new self($props_n_values);
45
-    }
46
-
47
-
48
-    /**
49
-     * Form Section UUID (universally unique identifier)
50
-     *
51
-     * @return string
52
-     * @throws EE_Error
53
-     * @throws ReflectionException
54
-     */
55
-    public function UUID(): string
56
-    {
57
-        return $this->get('FSC_UUID');
58
-    }
59
-
60
-
61
-    /**
62
-     * @param string $UUID
63
-     * @throws EE_Error
64
-     * @throws ReflectionException
65
-     */
66
-    public function setUUID(string $UUID)
67
-    {
68
-        $this->set('FSC_UUID', $UUID);
69
-    }
70
-
71
-
72
-    /**
73
-     * Form user types that this form section should be presented to.
74
-     * Values correspond to the EEM_Form_Section::APPLIES_TO_* constants.
75
-     *
76
-     * @return string
77
-     * @throws EE_Error
78
-     * @throws ReflectionException
79
-     */
80
-    public function appliesTo(): string
81
-    {
82
-        return $this->get('FSC_appliesTo');
83
-    }
84
-
85
-
86
-    /**
87
-     * @param string $user_type
88
-     * @throws EE_Error
89
-     * @throws ReflectionException
90
-     */
91
-    public function setAppliesTo(string $user_type)
92
-    {
93
-        $this->set('FSC_appliesTo', $user_type);
94
-    }
95
-
96
-
97
-    /**
98
-     * UUID or ID of related entity this form section belongs to.
99
-     *
100
-     * @return string
101
-     * @throws EE_Error
102
-     * @throws ReflectionException
103
-     */
104
-    public function belongsTo(): string
105
-    {
106
-        return $this->get('FSC_belongsTo');
107
-    }
108
-
109
-
110
-    /**
111
-     * @param string $relation_UUID
112
-     * @throws EE_Error
113
-     * @throws ReflectionException
114
-     */
115
-    public function setBelongsTo(string $relation_UUID)
116
-    {
117
-        $this->set('FSC_belongsTo', $relation_UUID);
118
-    }
119
-
120
-
121
-    /**
122
-     * HTML classes to be applied to this form section's container.
123
-     *
124
-     * @return string
125
-     * @throws EE_Error
126
-     * @throws ReflectionException
127
-     */
128
-    public function htmlClass(): string
129
-    {
130
-        return $this->get('FSC_htmlClass');
131
-    }
132
-
133
-
134
-    /**
135
-     * @param string $html_class
136
-     * @throws EE_Error
137
-     * @throws ReflectionException
138
-     */
139
-    public function setHtmlClass(string $html_class)
140
-    {
141
-        $this->set('FSC_htmlClass', $html_class);
142
-    }
143
-
144
-
145
-    /**
146
-     * Order in which form section appears in a form.
147
-     *
148
-     * @return int
149
-     * @throws EE_Error
150
-     * @throws ReflectionException
151
-     */
152
-    public function order(): int
153
-    {
154
-        return $this->get('FSC_order');
155
-    }
156
-
157
-
158
-    /**
159
-     * @param int $order
160
-     * @throws EE_Error
161
-     * @throws ReflectionException
162
-     */
163
-    public function setOrder(int $order)
164
-    {
165
-        $this->set('FSC_order', $order);
166
-    }
167
-
168
-
169
-    /**
170
-     * Related model type.
171
-     *
172
-     * @return string
173
-     * @throws EE_Error
174
-     * @throws ReflectionException
175
-     */
176
-    public function relation(): string
177
-    {
178
-        return $this->get('FSC_relation');
179
-    }
180
-
181
-
182
-    /**
183
-     * @param string $relation
184
-     * @throws EE_Error
185
-     * @throws ReflectionException
186
-     */
187
-    public function setRelation(string $relation)
188
-    {
189
-        $this->set('FSC_relation', $relation);
190
-    }
191
-
192
-
193
-    /**
194
-     * Whether form section is active, archived, trashed, or used as a default on new forms.
195
-     * Values correspond to the EEM_Form_Section::STATUS_* constants.
196
-     *
197
-     * @return string
198
-     * @throws EE_Error
199
-     * @throws ReflectionException
200
-     */
201
-    public function status(): string
202
-    {
203
-        return $this->get('FSC_status');
204
-    }
205
-
206
-
207
-    /**
208
-     * Whether form section is active, archived, trashed, or used as a default on new forms.
209
-     * Values correspond to the EEM_Form_Section::STATUS_* constants.
210
-     *
211
-     * @param string $status
212
-     * @throws EE_Error
213
-     * @throws ReflectionException
214
-     */
215
-    public function setStatus(string $status)
216
-    {
217
-        $this->set('FSC_status', $status);
218
-    }
219
-
220
-
221
-    /**
222
-     * returns the id the wordpress user who created this question
223
-     *
224
-     * @return int
225
-     * @throws EE_Error
226
-     * @throws ReflectionException
227
-     */
228
-    public function wpUser(): int
229
-    {
230
-        return $this->get('FSC_wpUser');
231
-    }
232
-
233
-
234
-    /**
235
-     * @param int $wp_user
236
-     * @throws EE_Error
237
-     * @throws ReflectionException
238
-     */
239
-    public function setWpUser(int $wp_user)
240
-    {
241
-        $this->set('FSC_wpUser', $wp_user);
242
-    }
22
+	/**
23
+	 * @param array $props_n_values
24
+	 * @return EE_Form_Section
25
+	 * @throws EE_Error
26
+	 * @throws ReflectionException
27
+	 */
28
+	public static function new_instance(array $props_n_values = []): EE_Form_Section
29
+	{
30
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
31
+		return $has_object
32
+			?: new self($props_n_values);
33
+	}
34
+
35
+
36
+	/**
37
+	 * @param array $props_n_values
38
+	 * @return EE_Form_Section
39
+	 * @throws EE_Error
40
+	 * @throws ReflectionException
41
+	 */
42
+	public static function new_instance_from_db(array $props_n_values = []): EE_Form_Section
43
+	{
44
+		return new self($props_n_values);
45
+	}
46
+
47
+
48
+	/**
49
+	 * Form Section UUID (universally unique identifier)
50
+	 *
51
+	 * @return string
52
+	 * @throws EE_Error
53
+	 * @throws ReflectionException
54
+	 */
55
+	public function UUID(): string
56
+	{
57
+		return $this->get('FSC_UUID');
58
+	}
59
+
60
+
61
+	/**
62
+	 * @param string $UUID
63
+	 * @throws EE_Error
64
+	 * @throws ReflectionException
65
+	 */
66
+	public function setUUID(string $UUID)
67
+	{
68
+		$this->set('FSC_UUID', $UUID);
69
+	}
70
+
71
+
72
+	/**
73
+	 * Form user types that this form section should be presented to.
74
+	 * Values correspond to the EEM_Form_Section::APPLIES_TO_* constants.
75
+	 *
76
+	 * @return string
77
+	 * @throws EE_Error
78
+	 * @throws ReflectionException
79
+	 */
80
+	public function appliesTo(): string
81
+	{
82
+		return $this->get('FSC_appliesTo');
83
+	}
84
+
85
+
86
+	/**
87
+	 * @param string $user_type
88
+	 * @throws EE_Error
89
+	 * @throws ReflectionException
90
+	 */
91
+	public function setAppliesTo(string $user_type)
92
+	{
93
+		$this->set('FSC_appliesTo', $user_type);
94
+	}
95
+
96
+
97
+	/**
98
+	 * UUID or ID of related entity this form section belongs to.
99
+	 *
100
+	 * @return string
101
+	 * @throws EE_Error
102
+	 * @throws ReflectionException
103
+	 */
104
+	public function belongsTo(): string
105
+	{
106
+		return $this->get('FSC_belongsTo');
107
+	}
108
+
109
+
110
+	/**
111
+	 * @param string $relation_UUID
112
+	 * @throws EE_Error
113
+	 * @throws ReflectionException
114
+	 */
115
+	public function setBelongsTo(string $relation_UUID)
116
+	{
117
+		$this->set('FSC_belongsTo', $relation_UUID);
118
+	}
119
+
120
+
121
+	/**
122
+	 * HTML classes to be applied to this form section's container.
123
+	 *
124
+	 * @return string
125
+	 * @throws EE_Error
126
+	 * @throws ReflectionException
127
+	 */
128
+	public function htmlClass(): string
129
+	{
130
+		return $this->get('FSC_htmlClass');
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param string $html_class
136
+	 * @throws EE_Error
137
+	 * @throws ReflectionException
138
+	 */
139
+	public function setHtmlClass(string $html_class)
140
+	{
141
+		$this->set('FSC_htmlClass', $html_class);
142
+	}
143
+
144
+
145
+	/**
146
+	 * Order in which form section appears in a form.
147
+	 *
148
+	 * @return int
149
+	 * @throws EE_Error
150
+	 * @throws ReflectionException
151
+	 */
152
+	public function order(): int
153
+	{
154
+		return $this->get('FSC_order');
155
+	}
156
+
157
+
158
+	/**
159
+	 * @param int $order
160
+	 * @throws EE_Error
161
+	 * @throws ReflectionException
162
+	 */
163
+	public function setOrder(int $order)
164
+	{
165
+		$this->set('FSC_order', $order);
166
+	}
167
+
168
+
169
+	/**
170
+	 * Related model type.
171
+	 *
172
+	 * @return string
173
+	 * @throws EE_Error
174
+	 * @throws ReflectionException
175
+	 */
176
+	public function relation(): string
177
+	{
178
+		return $this->get('FSC_relation');
179
+	}
180
+
181
+
182
+	/**
183
+	 * @param string $relation
184
+	 * @throws EE_Error
185
+	 * @throws ReflectionException
186
+	 */
187
+	public function setRelation(string $relation)
188
+	{
189
+		$this->set('FSC_relation', $relation);
190
+	}
191
+
192
+
193
+	/**
194
+	 * Whether form section is active, archived, trashed, or used as a default on new forms.
195
+	 * Values correspond to the EEM_Form_Section::STATUS_* constants.
196
+	 *
197
+	 * @return string
198
+	 * @throws EE_Error
199
+	 * @throws ReflectionException
200
+	 */
201
+	public function status(): string
202
+	{
203
+		return $this->get('FSC_status');
204
+	}
205
+
206
+
207
+	/**
208
+	 * Whether form section is active, archived, trashed, or used as a default on new forms.
209
+	 * Values correspond to the EEM_Form_Section::STATUS_* constants.
210
+	 *
211
+	 * @param string $status
212
+	 * @throws EE_Error
213
+	 * @throws ReflectionException
214
+	 */
215
+	public function setStatus(string $status)
216
+	{
217
+		$this->set('FSC_status', $status);
218
+	}
219
+
220
+
221
+	/**
222
+	 * returns the id the wordpress user who created this question
223
+	 *
224
+	 * @return int
225
+	 * @throws EE_Error
226
+	 * @throws ReflectionException
227
+	 */
228
+	public function wpUser(): int
229
+	{
230
+		return $this->get('FSC_wpUser');
231
+	}
232
+
233
+
234
+	/**
235
+	 * @param int $wp_user
236
+	 * @throws EE_Error
237
+	 * @throws ReflectionException
238
+	 */
239
+	public function setWpUser(int $wp_user)
240
+	{
241
+		$this->set('FSC_wpUser', $wp_user);
242
+	}
243 243
 }
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/CopyAttendeeInfoForm.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 
42 42
 
43 43
     /**
44
-     * @param array $registrations
44
+     * @param EE_Registration[] $registrations
45 45
      * @return array
46 46
      * @throws EE_Error
47 47
      * @throws ReflectionException
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -12,76 +12,76 @@
 block discarded – undo
12 12
 
13 13
 class CopyAttendeeInfoForm extends EE_Form_Section_Proper
14 14
 {
15
-    /**
16
-     * CopyAttendeeInfoForm constructor.
17
-     *
18
-     * @param EE_Registration[] $registrations
19
-     * @param string            $slug
20
-     * @throws EE_Error
21
-     * @throws ReflectionException
22
-     */
23
-    public function __construct(array $registrations, string $slug)
24
-    {
25
-        parent::__construct(
26
-            [
27
-                'subsections'     => $this->copyAttendeeInfoInputs($registrations),
28
-                'layout_strategy' => new EE_Template_Layout(
29
-                    [
30
-                        'layout_template_file'     => SPCO_REG_STEPS_PATH
31
-                                                      . $slug
32
-                                                      . '/copy_attendee_info.template.php',
33
-                        'begin_template_file'      => null,
34
-                        'input_template_file'      => null,
35
-                        'subsection_template_file' => null,
36
-                        'end_template_file'        => null,
37
-                    ]
38
-                ),
39
-            ]);
40
-    }
15
+	/**
16
+	 * CopyAttendeeInfoForm constructor.
17
+	 *
18
+	 * @param EE_Registration[] $registrations
19
+	 * @param string            $slug
20
+	 * @throws EE_Error
21
+	 * @throws ReflectionException
22
+	 */
23
+	public function __construct(array $registrations, string $slug)
24
+	{
25
+		parent::__construct(
26
+			[
27
+				'subsections'     => $this->copyAttendeeInfoInputs($registrations),
28
+				'layout_strategy' => new EE_Template_Layout(
29
+					[
30
+						'layout_template_file'     => SPCO_REG_STEPS_PATH
31
+													  . $slug
32
+													  . '/copy_attendee_info.template.php',
33
+						'begin_template_file'      => null,
34
+						'input_template_file'      => null,
35
+						'subsection_template_file' => null,
36
+						'end_template_file'        => null,
37
+					]
38
+				),
39
+			]);
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * @param array $registrations
45
-     * @return array
46
-     * @throws EE_Error
47
-     * @throws ReflectionException
48
-     */
49
-    private function copyAttendeeInfoInputs(array $registrations): array
50
-    {
51
-        $copy_attendee_info_inputs = [];
52
-        $prev_ticket               = null;
53
-        foreach ($registrations as $registration) {
54
-            // for all  attendees other than the primary attendee
55
-            if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
56
-                // if this is a new ticket OR if this is the very first additional attendee after the primary attendee
57
-                if ($registration->ticket()->ID() !== $prev_ticket) {
58
-                    $item_name   = $registration->ticket()->name();
59
-                    $item_name   .= $registration->ticket()->description() !== ''
60
-                        ? ' - ' . $registration->ticket()->description()
61
-                        : '';
62
-                    $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ]
63
-                                 = new EE_Form_Section_HTML(
64
-                        '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
65
-                    );
66
-                    $prev_ticket = $registration->ticket()->ID();
67
-                }
43
+	/**
44
+	 * @param array $registrations
45
+	 * @return array
46
+	 * @throws EE_Error
47
+	 * @throws ReflectionException
48
+	 */
49
+	private function copyAttendeeInfoInputs(array $registrations): array
50
+	{
51
+		$copy_attendee_info_inputs = [];
52
+		$prev_ticket               = null;
53
+		foreach ($registrations as $registration) {
54
+			// for all  attendees other than the primary attendee
55
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
56
+				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
57
+				if ($registration->ticket()->ID() !== $prev_ticket) {
58
+					$item_name   = $registration->ticket()->name();
59
+					$item_name   .= $registration->ticket()->description() !== ''
60
+						? ' - ' . $registration->ticket()->description()
61
+						: '';
62
+					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ]
63
+								 = new EE_Form_Section_HTML(
64
+						'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
65
+					);
66
+					$prev_ticket = $registration->ticket()->ID();
67
+				}
68 68
 
69
-                $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ]
70
-                    = new EE_Checkbox_Multi_Input(
71
-                    [
72
-                        $registration->ID() => sprintf(
73
-                            esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'),
74
-                            $registration->count()
75
-                        ),
76
-                    ],
77
-                    [
78
-                        'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
79
-                        'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
80
-                        'display_html_label_text' => false,
81
-                    ]
82
-                );
83
-            }
84
-        }
85
-        return $copy_attendee_info_inputs;
86
-    }
69
+				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ]
70
+					= new EE_Checkbox_Multi_Input(
71
+					[
72
+						$registration->ID() => sprintf(
73
+							esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'),
74
+							$registration->count()
75
+						),
76
+					],
77
+					[
78
+						'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
79
+						'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
80
+						'display_html_label_text' => false,
81
+					]
82
+				);
83
+			}
84
+		}
85
+		return $copy_attendee_info_inputs;
86
+	}
87 87
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
             if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
56 56
                 // if this is a new ticket OR if this is the very first additional attendee after the primary attendee
57 57
                 if ($registration->ticket()->ID() !== $prev_ticket) {
58
-                    $item_name   = $registration->ticket()->name();
59
-                    $item_name   .= $registration->ticket()->description() !== ''
60
-                        ? ' - ' . $registration->ticket()->description()
58
+                    $item_name = $registration->ticket()->name();
59
+                    $item_name .= $registration->ticket()->description() !== ''
60
+                        ? ' - '.$registration->ticket()->description()
61 61
                         : '';
62
-                    $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ]
62
+                    $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']']
63 63
                                  = new EE_Form_Section_HTML(
64
-                        '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
64
+                        '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
65 65
                     );
66 66
                     $prev_ticket = $registration->ticket()->ID();
67 67
                 }
68 68
 
69
-                $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ]
69
+                $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']']
70 70
                     = new EE_Checkbox_Multi_Input(
71 71
                     [
72 72
                         $registration->ID() => sprintf(
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                         ),
76 76
                     ],
77 77
                     [
78
-                        'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
78
+                        'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
79 79
                         'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
80 80
                         'display_html_label_text' => false,
81 81
                     ]
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.