Completed
Branch BUG-10626-dst-unit-test (cc62a6)
by
unknown
37:15 queued 23:58
created
core/services/loaders/LoaderInterface.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -9,39 +9,39 @@
 block discarded – undo
9 9
 interface LoaderInterface
10 10
 {
11 11
 
12
-    /**
13
-     * Can be for instantiating a new instance of a class,
14
-     * or for getting a shared instance of a class (default)
15
-     *
16
-     * @param string $fqcn
17
-     * @param array  $arguments
18
-     * @param bool   $shared
19
-     * @return mixed
20
-     */
21
-    public function load($fqcn, $arguments = array(), $shared = true);
22
-
23
-    /**
24
-     * Used for instantiating a new instance of a class
25
-     *
26
-     * @param string $fqcn
27
-     * @param array  $arguments
28
-     * @return mixed
29
-     */
30
-    public function getNew($fqcn, $arguments = array());
31
-
32
-    /**
33
-     * Used for getting a shared instance of a class
34
-     *
35
-     * @param string $fqcn
36
-     * @param array  $arguments
37
-     * @return mixed
38
-     */
39
-    public function getShared($fqcn, $arguments = array());
40
-
41
-    /**
42
-     * calls reset() on loader if method exists
43
-     */
44
-    public function reset();
12
+	/**
13
+	 * Can be for instantiating a new instance of a class,
14
+	 * or for getting a shared instance of a class (default)
15
+	 *
16
+	 * @param string $fqcn
17
+	 * @param array  $arguments
18
+	 * @param bool   $shared
19
+	 * @return mixed
20
+	 */
21
+	public function load($fqcn, $arguments = array(), $shared = true);
22
+
23
+	/**
24
+	 * Used for instantiating a new instance of a class
25
+	 *
26
+	 * @param string $fqcn
27
+	 * @param array  $arguments
28
+	 * @return mixed
29
+	 */
30
+	public function getNew($fqcn, $arguments = array());
31
+
32
+	/**
33
+	 * Used for getting a shared instance of a class
34
+	 *
35
+	 * @param string $fqcn
36
+	 * @param array  $arguments
37
+	 * @return mixed
38
+	 */
39
+	public function getShared($fqcn, $arguments = array());
40
+
41
+	/**
42
+	 * calls reset() on loader if method exists
43
+	 */
44
+	public function reset();
45 45
 
46 46
 }
47 47
 // End of file LoaderInterface.php
Please login to merge, or discard this patch.
core/services/loaders/LoaderDecorator.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,22 +19,22 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * @var LoaderDecoratorInterface $loader
24
-     */
25
-    protected $loader;
26
-
27
-
28
-
29
-    /**
30
-     * LoaderDecorator constructor.
31
-     *
32
-     * @param LoaderDecoratorInterface $loader
33
-     */
34
-    public function __construct(LoaderDecoratorInterface $loader)
35
-    {
36
-        $this->loader = $loader;
37
-    }
22
+	/**
23
+	 * @var LoaderDecoratorInterface $loader
24
+	 */
25
+	protected $loader;
26
+
27
+
28
+
29
+	/**
30
+	 * LoaderDecorator constructor.
31
+	 *
32
+	 * @param LoaderDecoratorInterface $loader
33
+	 */
34
+	public function __construct(LoaderDecoratorInterface $loader)
35
+	{
36
+		$this->loader = $loader;
37
+	}
38 38
 
39 39
 
40 40
 
Please login to merge, or discard this patch.
modules/add_new_state/EED_Add_New_State.module.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -577,7 +577,7 @@
 block discarded – undo
577 577
 
578 578
     /**
579 579
      * @param EE_State[] $state_options
580
-     * @return array
580
+     * @return EE_State[]
581 581
      * @throws EE_Error
582 582
      */
583 583
     public static function state_options($state_options = array())
Please login to merge, or discard this patch.
Indentation   +693 added lines, -693 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -16,698 +16,698 @@  discard block
 block discarded – undo
16 16
 
17 17
 
18 18
 
19
-    /**
20
-     * @return EED_Module|EED_Add_New_State
21
-     */
22
-    public static function instance()
23
-    {
24
-        return parent::get_instance(__CLASS__);
25
-    }
26
-
27
-
28
-
29
-    /**
30
-     * set_hooks - for hooking into EE Core, other modules, etc
31
-     *
32
-     * @return void
33
-     */
34
-    public static function set_hooks()
35
-    {
36
-        add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
37
-        add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
38
-        add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
39
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
40
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
41
-        add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
42
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
43
-        add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
44
-            array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1);
45
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
46
-            array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5);
47
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
48
-            array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5);
49
-        add_filter('FHEE__EE_State_Select_Input____construct__state_options',
50
-            array('EED_Add_New_State', 'state_options'), 10, 1);
51
-        add_filter('FHEE__EE_Country_Select_Input____construct__country_options',
52
-            array('EED_Add_New_State', 'country_options'), 10, 1);
53
-    }
54
-
55
-
56
-
57
-    /**
58
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
59
-     *
60
-     * @return void
61
-     */
62
-    public static function set_hooks_admin()
63
-    {
64
-        add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
65
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
66
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
67
-        add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
68
-            array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
69
-        add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
70
-        add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
71
-        add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
72
-            array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1);
73
-        add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
74
-            array('EED_Add_New_State', 'update_country_settings'), 10, 3);
75
-        add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
76
-            array('EED_Add_New_State', 'update_country_settings'), 10, 3);
77
-        add_filter('FHEE__EE_State_Select_Input____construct__state_options',
78
-            array('EED_Add_New_State', 'state_options'), 10, 1);
79
-        add_filter('FHEE__EE_Country_Select_Input____construct__country_options',
80
-            array('EED_Add_New_State', 'country_options'), 10, 1);
81
-        add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
82
-            array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1);
83
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
84
-            array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5);
85
-        add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
86
-            array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5);
87
-    }
88
-
89
-
90
-
91
-    /**
92
-     * @return void
93
-     */
94
-    public static function set_definitions()
95
-    {
96
-        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
97
-        define('ANS_TEMPLATES_PATH', str_replace(
98
-            '\\',
99
-            DS, plugin_dir_path(__FILE__)) . 'templates' . DS
100
-        );
101
-    }
102
-
103
-
104
-
105
-    /**
106
-     * @param WP $WP
107
-     * @return void
108
-     */
109
-    public function run($WP)
110
-    {
111
-    }
112
-
113
-
114
-
115
-    /**
116
-     * @return void
117
-     */
118
-    public static function translate_js_strings()
119
-    {
120
-        EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__(
121
-            'In order to proceed, you need to select the Country that your State/Province belongs to.',
122
-            'event_espresso'
123
-        );
124
-        EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__(
125
-            'In order to proceed, you need to enter the name of your State/Province.',
126
-            'event_espresso'
127
-        );
128
-        EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__(
129
-            'In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
130
-            'event_espresso'
131
-        );
132
-        EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__(
133
-            'The new state was successfully saved to the database.',
134
-            'event_espresso'
135
-        );
136
-        EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__(
137
-            'An unknown error has occurred on the server while saving the new state to the database.',
138
-            'event_espresso'
139
-        );
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     * @return void
146
-     */
147
-    public static function wp_enqueue_scripts()
148
-    {
149
-        if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
150
-            wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js',
151
-                array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true);
152
-            wp_enqueue_script('add_new_state');
153
-        }
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     * display_add_new_state_micro_form
160
-     *
161
-     * @param EE_Form_Section_Proper $question_group_reg_form
162
-     * @return string
163
-     * @throws EE_Error
164
-     */
165
-    //	public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){
166
-    public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
167
-    {
168
-        // only add the 'new_state_micro_form' when displaying reg forms,
169
-        // not during processing since we process the 'new_state_micro_form' in it's own AJAX request
170
-        $action = EE_Registry::instance()->REQ->get('action', '');
171
-        // is the "state" question in this form section?
172
-        $input = $question_group_reg_form->get_subsection('state');
173
-        if ($action === 'process_reg_step' || $action === 'update_reg_step') {
174
-            //ok then all we need to do is make sure the input's HTML name is consistent
175
-            //by forcing it to set it now, like it did while getting the form for display
176
-            if ($input instanceof EE_State_Select_Input) {
177
-                $input->html_name();
178
-            }
179
-            return $question_group_reg_form;
180
-        }
181
-        // we're only doing this for state select inputs
182
-        if ($input instanceof EE_State_Select_Input) {
183
-            // grab any set values from the request
184
-            $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
185
-            $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
186
-            $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
187
-            $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
188
-            $country_options = array();
189
-            $countries = EEM_Country::instance()->get_all_countries();
190
-            if (! empty($countries)) {
191
-                foreach ($countries as $country) {
192
-                    if ($country instanceof EE_Country) {
193
-                        $country_options[$country->ID()] = $country->name();
194
-                    }
195
-                }
196
-            }
197
-            $new_state_micro_form = new EE_Form_Section_Proper(
198
-                array(
199
-                    'name'            => 'new_state_micro_form',
200
-                    'html_id'         => 'new_state_micro_form',
201
-                    'layout_strategy' => new EE_Div_Per_Section_Layout(),
202
-                    'subsections'     => array(
203
-                        // add hidden input to indicate that a new state is being added
204
-                        'add_new_state'               => new EE_Hidden_Input(
205
-                            array(
206
-                                'html_name' => str_replace(
207
-                                    'state',
208
-                                    'nsmf_add_new_state', $input->html_name()
209
-                                ),
210
-                                'html_id'   => str_replace(
211
-                                    'state',
212
-                                    'nsmf_add_new_state', $input->html_id()
213
-                                ),
214
-                                'default'   => 0,
215
-                            )
216
-                        ),
217
-                        // add link for displaying hidden container
218
-                        'click_here_link'             => new EE_Form_Section_HTML(
219
-                            apply_filters(
220
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
221
-                                EEH_HTML::link(
222
-                                    '',
223
-                                    esc_html__('click here to add a new state/province', 'event_espresso'),
224
-                                    '',
225
-                                    'display-' . $input->html_id(),
226
-                                    'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
227
-                                    '',
228
-                                    'data-target="' . $input->html_id() . '"'
229
-                                )
230
-                            )
231
-                        ),
232
-                        // add initial html for hidden container
233
-                        'add_new_state_micro_form'    => new EE_Form_Section_HTML(
234
-                            apply_filters(
235
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
236
-                                EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv',
237
-                                    'display: none;') .
238
-                                EEH_HTML::h6(
239
-                                    esc_html__(
240
-                                        'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
241
-                                        'event_espresso'
242
-                                    )
243
-                                ) .
244
-                                EEH_HTML::ul() .
245
-                                EEH_HTML::li(
246
-                                    esc_html__(
247
-                                        'first select the Country that your State/Province belongs to',
248
-                                        'event_espresso'
249
-                                    )
250
-                                ) .
251
-                                EEH_HTML::li(
252
-                                    esc_html__('enter the name of your State/Province', 'event_espresso')
253
-                                ) .
254
-                                EEH_HTML::li(
255
-                                    esc_html__(
256
-                                        'enter a two to six letter abbreviation for the name of your State/Province',
257
-                                        'event_espresso'
258
-                                    )
259
-                                ) .
260
-                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
261
-                                EEH_HTML::ulx()
262
-                            )
263
-                        ),
264
-                        // NEW STATE COUNTRY
265
-                        'new_state_country'           => new EE_Country_Select_Input(
266
-                            $country_options,
267
-                            array(
268
-                                'html_name'       => $country_name,
269
-                                'html_id'         => str_replace(
270
-                                    'state',
271
-                                    'nsmf_new_state_country', $input->html_id()
272
-                                ),
273
-                                'html_class'      => $input->html_class() . ' new-state-country',
274
-                                'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
275
-                                'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
276
-                                'required'        => false,
277
-                            )
278
-                        ),
279
-                        // NEW STATE NAME
280
-                        'new_state_name'              => new EE_Text_Input(
281
-                            array(
282
-                                'html_name'       => $state_name,
283
-                                'html_id'         => str_replace(
284
-                                    'state',
285
-                                    'nsmf_new_state_name', $input->html_id()
286
-                                ),
287
-                                'html_class'      => $input->html_class() . ' new-state-state',
288
-                                'html_label_text' => esc_html__('New State/Province Name',
289
-                                    'event_espresso'),
290
-                                'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
291
-                                'required'        => false,
292
-                            )
293
-                        ),
294
-                        'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
295
-                        // NEW STATE NAME
296
-                        'new_state_abbrv'             => new EE_Text_Input(
297
-                            array(
298
-                                'html_name'             => $abbrv_name,
299
-                                'html_id'               => str_replace('state', 'nsmf_new_state_abbrv',
300
-                                    $input->html_id()),
301
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
302
-                                'html_label_text'       => esc_html__(
303
-                                    'New State/Province Abbreviation',
304
-                                    'event_espresso'
305
-                                ) . ' *',
306
-                                'html_other_attributes' => 'size="24"',
307
-                                'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
308
-                                'required'              => false,
309
-                            )
310
-                        ),
311
-                        // "submit" button
312
-                        'add_new_state_submit_button' => new EE_Form_Section_HTML(
313
-                            apply_filters(
314
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
315
-                                EEH_HTML::nbsp(3) .
316
-                                EEH_HTML::link(
317
-                                    '',
318
-                                    esc_html__('ADD', 'event_espresso'),
319
-                                    '',
320
-                                    'submit-' . $new_state_submit_id,
321
-                                    'ee-form-add-new-state-submit button button-secondary',
322
-                                    '',
323
-                                    'data-target="' . $new_state_submit_id . '"'
324
-                                )
325
-                            )
326
-                        ),
327
-                        // extra info
328
-                        'add_new_state_extra'         => new EE_Form_Section_HTML(
329
-                            apply_filters(
330
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
331
-                                EEH_HTML::br(2)
332
-                                .
333
-                                EEH_HTML::div('', '', 'small-text')
334
-                                .
335
-                                EEH_HTML::strong(
336
-                                    '* ' .
337
-                                    esc_html__(
338
-                                        'Don\'t know your State/Province Abbreviation?',
339
-                                        'event_espresso'
340
-                                    )
341
-                                )
342
-                                .
343
-                                EEH_HTML::br()
344
-                                .
345
-                                sprintf(
346
-                                    esc_html__(
347
-                                        'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
348
-                                        'event_espresso'
349
-                                    ),
350
-                                    EEH_HTML::link(
351
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2',
352
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2',
353
-                                        '',
354
-                                        '',
355
-                                        'ee-form-add-new-state-wiki-lnk',
356
-                                        '',
357
-                                        'target="_blank"'
358
-                                    )
359
-                                )
360
-                                .
361
-                                EEH_HTML::divx()
362
-                                .
363
-                                EEH_HTML::br()
364
-                                .
365
-                                EEH_HTML::link(
366
-                                    '',
367
-                                    esc_html__('cancel new State/Province', 'event_espresso'),
368
-                                    '',
369
-                                    'hide-' . $input->html_id(),
370
-                                    'ee-form-cancel-new-state-lnk smaller-text',
371
-                                    '',
372
-                                    'data-target="' . $input->html_id() . '"'
373
-                                )
374
-                                .
375
-                                EEH_HTML::divx()
376
-                                .
377
-                                EEH_HTML::br()
378
-                            )
379
-                        ),
380
-                    ),
381
-                )
382
-            );
383
-            $question_group_reg_form->add_subsections(
384
-                array('new_state_micro_form' => $new_state_micro_form),
385
-                'state',
386
-                false
387
-            );
388
-        }
389
-        return $question_group_reg_form;
390
-    }
391
-
392
-
393
-
394
-    /**
395
-     * set_new_state_input_width
396
-     *
397
-     * @return int|string
398
-     * @throws EE_Error
399
-     */
400
-    public static function add_new_state()
401
-    {
402
-        $REQ = EE_Registry::instance()->load_core('Request_Handler');
403
-        if (absint($REQ->get('nsmf_add_new_state')) === 1) {
404
-            EE_Registry::instance()->load_model('State');
405
-            // grab country ISO code, new state name, and new state abbreviation
406
-            $state_country = $REQ->is_set('nsmf_new_state_country')
407
-                ? sanitize_text_field($REQ->get('nsmf_new_state_country'))
408
-                : false;
409
-            $state_name = $REQ->is_set('nsmf_new_state_name')
410
-                ? sanitize_text_field($REQ->get('nsmf_new_state_name'))
411
-                : false;
412
-            $state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
413
-                ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
414
-                : false;
415
-            if ($state_country && $state_name && $state_abbr) {
416
-                $new_state = EED_Add_New_State::save_new_state_to_db(array(
417
-                    'CNT_ISO'    => strtoupper($state_country),
418
-                    'STA_abbrev' => strtoupper($state_abbr),
419
-                    'STA_name'   => ucwords($state_name),
420
-                    'STA_active' => false,
421
-                ));
422
-                if ($new_state instanceof EE_State) {
423
-                    // clean house
424
-                    EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
425
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
426
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
427
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
428
-                    // get any existing new states
429
-                    $new_states = EE_Registry::instance()->SSN->get_session_data(
430
-                        'nsmf_new_states'
431
-                    );
432
-                    $new_states[$new_state->ID()] = $new_state;
433
-                    EE_Registry::instance()->SSN->set_session_data(
434
-                        array('nsmf_new_states' => $new_states)
435
-                    );
436
-                    if (EE_Registry::instance()->REQ->ajax) {
437
-                        echo wp_json_encode(array(
438
-                            'success'      => true,
439
-                            'id'           => $new_state->ID(),
440
-                            'name'         => $new_state->name(),
441
-                            'abbrev'       => $new_state->abbrev(),
442
-                            'country_iso'  => $new_state->country_iso(),
443
-                            'country_name' => $new_state->country()->name(),
444
-                        ));
445
-                        exit();
446
-                    }
447
-                    return $new_state->ID();
448
-                }
449
-            } else {
450
-                $error = esc_html__(
451
-                    'A new State/Province could not be added because invalid or missing data was received.',
452
-                    'event_espresso'
453
-                );
454
-                if (EE_Registry::instance()->REQ->ajax) {
455
-                    echo wp_json_encode(array('error' => $error));
456
-                    exit();
457
-                }
458
-                EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
459
-            }
460
-        }
461
-        return false;
462
-    }
463
-
464
-
465
-
466
-    /**
467
-     * recursively drills down through request params to remove any that were added by this module
468
-     *
469
-     * @param array $request_params
470
-     * @return array
471
-     */
472
-    public static function filter_checkout_request_params($request_params)
473
-    {
474
-        foreach ($request_params as $form_section) {
475
-            if (is_array($form_section)) {
476
-                EED_Add_New_State::unset_new_state_request_params($form_section);
477
-                EED_Add_New_State::filter_checkout_request_params($form_section);
478
-            }
479
-        }
480
-        return $request_params;
481
-    }
482
-
483
-
484
-
485
-    /**
486
-     * @param array $request_params
487
-     * @return array
488
-     */
489
-    public static function unset_new_state_request_params($request_params)
490
-    {
491
-        unset(
492
-            $request_params['new_state_micro_form'],
493
-            $request_params['new_state_micro_add_new_state'],
494
-            $request_params['new_state_micro_new_state_country'],
495
-            $request_params['new_state_micro_new_state_name'],
496
-            $request_params['new_state_micro_new_state_abbrv']
497
-        );
498
-        return $request_params;
499
-    }
500
-
501
-
502
-
503
-    /**
504
-     * @param array $props_n_values
505
-     * @return bool
506
-     * @throws EE_Error
507
-     */
508
-    public static function save_new_state_to_db($props_n_values = array())
509
-    {
510
-        $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
511
-        if (! empty($existing_state)) {
512
-            return array_pop($existing_state);
513
-        }
514
-        $new_state = EE_State::new_instance($props_n_values);
515
-        if ($new_state instanceof EE_State) {
516
-            // if not non-ajax admin
517
-            $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev();
518
-            $new_state_notice = sprintf(
519
-                esc_html__(
520
-                    '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.',
521
-                    'event_espresso'
522
-                ),
523
-                '<b>' . $new_state->name() . '</b>',
524
-                '<b>' . $new_state->abbrev() . '</b>',
525
-                '<b>' . $new_state->country()->name() . '</b>',
526
-                '<a href="' . add_query_arg(array(
527
-                    'page'    => 'espresso_general_settings',
528
-                    'action'  => 'country_settings',
529
-                    'country' => $new_state->country_iso(),
530
-                ), admin_url('admin.php')) . '">' . esc_html__('Event Espresso - General Settings > Countries Tab',
531
-                    'event_espresso') . '</a>',
532
-                '<br />'
533
-            );
534
-            EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice);
535
-            $new_state->save();
536
-            EEM_State::instance()->reset_cached_states();
537
-            return $new_state;
538
-        }
539
-        return false;
540
-    }
541
-
542
-
543
-
544
-    /**
545
-     * @param string $CNT_ISO
546
-     * @param string $STA_ID
547
-     * @param array  $cols_n_values
548
-     * @return void
549
-     */
550
-    public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
551
-    {
552
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false;
553
-        if (! $CNT_ISO) {
554
-            EE_Error::add_error(
555
-                esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
556
-                __FILE__,
557
-                __FUNCTION__,
558
-                __LINE__
559
-            );
560
-        }
561
-        $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
562
-            : false;
563
-        if (! $STA_abbrev && ! empty($STA_ID)) {
564
-            $state = EEM_State::instance()->get_one_by_ID($STA_ID);
565
-            if ($state instanceof EE_State) {
566
-                $STA_abbrev = $state->abbrev();
567
-            }
568
-        }
569
-        if (! $STA_abbrev) {
570
-            EE_Error::add_error(
571
-                esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
572
-                __FILE__,
573
-                __FUNCTION__,
574
-                __LINE__
575
-            );
576
-        }
577
-        EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true);
578
-    }
579
-
580
-
581
-
582
-    /**
583
-     * @param EE_State[]                             $state_options
584
-     * @param EE_SPCO_Reg_Step_Attendee_Information  $reg_step
585
-     * @param EE_Registration                        $registration
586
-     * @param EE_Question                            $question
587
-     * @param                                        $answer
588
-     * @return array
589
-     */
590
-    public static function inject_new_reg_state_into_options(
591
-        $state_options = array(),
592
-        EE_SPCO_Reg_Step_Attendee_Information $reg_step,
593
-        EE_Registration $registration,
594
-        EE_Question $question,
595
-        $answer
596
-    ) {
597
-        if ($answer instanceof EE_Answer && $question instanceof EE_Question
598
-            && $question->type()
599
-               === EEM_Question::QST_type_state
600
-        ) {
601
-            $STA_ID = $answer->value();
602
-            if (! empty($STA_ID)) {
603
-                $state = EEM_State::instance()->get_one_by_ID($STA_ID);
604
-                if ($state instanceof EE_State) {
605
-                    $country = $state->country();
606
-                    if ($country instanceof EE_Country) {
607
-                        if (! isset($state_options[$country->name()])) {
608
-                            $state_options[$country->name()] = array();
609
-                        }
610
-                        if (! isset($state_options[$country->name()][$STA_ID])) {
611
-                            $state_options[$country->name()][$STA_ID] = $state->name();
612
-                        }
613
-                    }
614
-                }
615
-            }
616
-        }
617
-        return $state_options;
618
-    }
619
-
620
-
621
-
622
-    /**
623
-     * @param EE_Country[]                           $country_options
624
-     * @param EE_SPCO_Reg_Step_Attendee_Information  $reg_step
625
-     * @param EE_Registration                        $registration
626
-     * @param EE_Question                            $question
627
-     * @param                                        $answer
628
-     * @return array
629
-     */
630
-    public static function inject_new_reg_country_into_options(
631
-        $country_options = array(),
632
-        EE_SPCO_Reg_Step_Attendee_Information $reg_step,
633
-        EE_Registration $registration,
634
-        EE_Question $question,
635
-        $answer
636
-    ) {
637
-        if ($answer instanceof EE_Answer && $question instanceof EE_Question
638
-            && $question->type()
639
-               === EEM_Question::QST_type_country
640
-        ) {
641
-            $CNT_ISO = $answer->value();
642
-            if (! empty($CNT_ISO)) {
643
-                $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
644
-                if ($country instanceof EE_Country) {
645
-                    if (! isset($country_options[$CNT_ISO])) {
646
-                        $country_options[$CNT_ISO] = $country->name();
647
-                    }
648
-                }
649
-            }
650
-        }
651
-        return $country_options;
652
-    }
653
-
654
-
655
-
656
-    /**
657
-     * @param EE_State[] $state_options
658
-     * @return array
659
-     * @throws EE_Error
660
-     */
661
-    public static function state_options($state_options = array())
662
-    {
663
-        $new_states = EED_Add_New_State::_get_new_states();
664
-        foreach ($new_states as $new_state) {
665
-            if (
666
-                $new_state instanceof EE_State
667
-                && $new_state->country() instanceof EE_Country
668
-            ) {
669
-                $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name();
670
-            }
671
-        }
672
-        return $state_options;
673
-    }
674
-
675
-
676
-
677
-    /**
678
-     * @return array
679
-     */
680
-    protected static function _get_new_states()
681
-    {
682
-        $new_states = array();
683
-        if (EE_Registry::instance()->SSN instanceof EE_Session) {
684
-            $new_states = EE_Registry::instance()->SSN->get_session_data(
685
-                'nsmf_new_states'
686
-            );
687
-        }
688
-        return is_array($new_states) ? $new_states : array();
689
-    }
690
-
691
-
692
-
693
-    /**
694
-     * @param EE_Country[] $country_options
695
-     * @return array
696
-     * @throws EE_Error
697
-     */
698
-    public static function country_options($country_options = array())
699
-    {
700
-        $new_states = EED_Add_New_State::_get_new_states();
701
-        foreach ($new_states as $new_state) {
702
-            if (
703
-                $new_state instanceof EE_State
704
-                && $new_state->country() instanceof EE_Country
705
-            ) {
706
-                $country_options[$new_state->country()->ID()] = $new_state->country()->name();
707
-            }
708
-        }
709
-        return $country_options;
710
-    }
19
+	/**
20
+	 * @return EED_Module|EED_Add_New_State
21
+	 */
22
+	public static function instance()
23
+	{
24
+		return parent::get_instance(__CLASS__);
25
+	}
26
+
27
+
28
+
29
+	/**
30
+	 * set_hooks - for hooking into EE Core, other modules, etc
31
+	 *
32
+	 * @return void
33
+	 */
34
+	public static function set_hooks()
35
+	{
36
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
37
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
38
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
39
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
40
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
41
+		add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
42
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
43
+		add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
44
+			array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1);
45
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
46
+			array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5);
47
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
48
+			array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5);
49
+		add_filter('FHEE__EE_State_Select_Input____construct__state_options',
50
+			array('EED_Add_New_State', 'state_options'), 10, 1);
51
+		add_filter('FHEE__EE_Country_Select_Input____construct__country_options',
52
+			array('EED_Add_New_State', 'country_options'), 10, 1);
53
+	}
54
+
55
+
56
+
57
+	/**
58
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
59
+	 *
60
+	 * @return void
61
+	 */
62
+	public static function set_hooks_admin()
63
+	{
64
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
65
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
66
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
67
+		add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
68
+			array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
69
+		add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
70
+		add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
71
+		add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
72
+			array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1);
73
+		add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
74
+			array('EED_Add_New_State', 'update_country_settings'), 10, 3);
75
+		add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
76
+			array('EED_Add_New_State', 'update_country_settings'), 10, 3);
77
+		add_filter('FHEE__EE_State_Select_Input____construct__state_options',
78
+			array('EED_Add_New_State', 'state_options'), 10, 1);
79
+		add_filter('FHEE__EE_Country_Select_Input____construct__country_options',
80
+			array('EED_Add_New_State', 'country_options'), 10, 1);
81
+		add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
82
+			array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1);
83
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options',
84
+			array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5);
85
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options',
86
+			array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5);
87
+	}
88
+
89
+
90
+
91
+	/**
92
+	 * @return void
93
+	 */
94
+	public static function set_definitions()
95
+	{
96
+		define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
97
+		define('ANS_TEMPLATES_PATH', str_replace(
98
+			'\\',
99
+			DS, plugin_dir_path(__FILE__)) . 'templates' . DS
100
+		);
101
+	}
102
+
103
+
104
+
105
+	/**
106
+	 * @param WP $WP
107
+	 * @return void
108
+	 */
109
+	public function run($WP)
110
+	{
111
+	}
112
+
113
+
114
+
115
+	/**
116
+	 * @return void
117
+	 */
118
+	public static function translate_js_strings()
119
+	{
120
+		EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__(
121
+			'In order to proceed, you need to select the Country that your State/Province belongs to.',
122
+			'event_espresso'
123
+		);
124
+		EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__(
125
+			'In order to proceed, you need to enter the name of your State/Province.',
126
+			'event_espresso'
127
+		);
128
+		EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__(
129
+			'In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
130
+			'event_espresso'
131
+		);
132
+		EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__(
133
+			'The new state was successfully saved to the database.',
134
+			'event_espresso'
135
+		);
136
+		EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__(
137
+			'An unknown error has occurred on the server while saving the new state to the database.',
138
+			'event_espresso'
139
+		);
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 * @return void
146
+	 */
147
+	public static function wp_enqueue_scripts()
148
+	{
149
+		if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
150
+			wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js',
151
+				array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true);
152
+			wp_enqueue_script('add_new_state');
153
+		}
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 * display_add_new_state_micro_form
160
+	 *
161
+	 * @param EE_Form_Section_Proper $question_group_reg_form
162
+	 * @return string
163
+	 * @throws EE_Error
164
+	 */
165
+	//	public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){
166
+	public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
167
+	{
168
+		// only add the 'new_state_micro_form' when displaying reg forms,
169
+		// not during processing since we process the 'new_state_micro_form' in it's own AJAX request
170
+		$action = EE_Registry::instance()->REQ->get('action', '');
171
+		// is the "state" question in this form section?
172
+		$input = $question_group_reg_form->get_subsection('state');
173
+		if ($action === 'process_reg_step' || $action === 'update_reg_step') {
174
+			//ok then all we need to do is make sure the input's HTML name is consistent
175
+			//by forcing it to set it now, like it did while getting the form for display
176
+			if ($input instanceof EE_State_Select_Input) {
177
+				$input->html_name();
178
+			}
179
+			return $question_group_reg_form;
180
+		}
181
+		// we're only doing this for state select inputs
182
+		if ($input instanceof EE_State_Select_Input) {
183
+			// grab any set values from the request
184
+			$country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
185
+			$state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
186
+			$abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
187
+			$new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
188
+			$country_options = array();
189
+			$countries = EEM_Country::instance()->get_all_countries();
190
+			if (! empty($countries)) {
191
+				foreach ($countries as $country) {
192
+					if ($country instanceof EE_Country) {
193
+						$country_options[$country->ID()] = $country->name();
194
+					}
195
+				}
196
+			}
197
+			$new_state_micro_form = new EE_Form_Section_Proper(
198
+				array(
199
+					'name'            => 'new_state_micro_form',
200
+					'html_id'         => 'new_state_micro_form',
201
+					'layout_strategy' => new EE_Div_Per_Section_Layout(),
202
+					'subsections'     => array(
203
+						// add hidden input to indicate that a new state is being added
204
+						'add_new_state'               => new EE_Hidden_Input(
205
+							array(
206
+								'html_name' => str_replace(
207
+									'state',
208
+									'nsmf_add_new_state', $input->html_name()
209
+								),
210
+								'html_id'   => str_replace(
211
+									'state',
212
+									'nsmf_add_new_state', $input->html_id()
213
+								),
214
+								'default'   => 0,
215
+							)
216
+						),
217
+						// add link for displaying hidden container
218
+						'click_here_link'             => new EE_Form_Section_HTML(
219
+							apply_filters(
220
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
221
+								EEH_HTML::link(
222
+									'',
223
+									esc_html__('click here to add a new state/province', 'event_espresso'),
224
+									'',
225
+									'display-' . $input->html_id(),
226
+									'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
227
+									'',
228
+									'data-target="' . $input->html_id() . '"'
229
+								)
230
+							)
231
+						),
232
+						// add initial html for hidden container
233
+						'add_new_state_micro_form'    => new EE_Form_Section_HTML(
234
+							apply_filters(
235
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
236
+								EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv',
237
+									'display: none;') .
238
+								EEH_HTML::h6(
239
+									esc_html__(
240
+										'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
241
+										'event_espresso'
242
+									)
243
+								) .
244
+								EEH_HTML::ul() .
245
+								EEH_HTML::li(
246
+									esc_html__(
247
+										'first select the Country that your State/Province belongs to',
248
+										'event_espresso'
249
+									)
250
+								) .
251
+								EEH_HTML::li(
252
+									esc_html__('enter the name of your State/Province', 'event_espresso')
253
+								) .
254
+								EEH_HTML::li(
255
+									esc_html__(
256
+										'enter a two to six letter abbreviation for the name of your State/Province',
257
+										'event_espresso'
258
+									)
259
+								) .
260
+								EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
261
+								EEH_HTML::ulx()
262
+							)
263
+						),
264
+						// NEW STATE COUNTRY
265
+						'new_state_country'           => new EE_Country_Select_Input(
266
+							$country_options,
267
+							array(
268
+								'html_name'       => $country_name,
269
+								'html_id'         => str_replace(
270
+									'state',
271
+									'nsmf_new_state_country', $input->html_id()
272
+								),
273
+								'html_class'      => $input->html_class() . ' new-state-country',
274
+								'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
275
+								'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
276
+								'required'        => false,
277
+							)
278
+						),
279
+						// NEW STATE NAME
280
+						'new_state_name'              => new EE_Text_Input(
281
+							array(
282
+								'html_name'       => $state_name,
283
+								'html_id'         => str_replace(
284
+									'state',
285
+									'nsmf_new_state_name', $input->html_id()
286
+								),
287
+								'html_class'      => $input->html_class() . ' new-state-state',
288
+								'html_label_text' => esc_html__('New State/Province Name',
289
+									'event_espresso'),
290
+								'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
291
+								'required'        => false,
292
+							)
293
+						),
294
+						'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
295
+						// NEW STATE NAME
296
+						'new_state_abbrv'             => new EE_Text_Input(
297
+							array(
298
+								'html_name'             => $abbrv_name,
299
+								'html_id'               => str_replace('state', 'nsmf_new_state_abbrv',
300
+									$input->html_id()),
301
+								'html_class'            => $input->html_class() . ' new-state-abbrv',
302
+								'html_label_text'       => esc_html__(
303
+									'New State/Province Abbreviation',
304
+									'event_espresso'
305
+								) . ' *',
306
+								'html_other_attributes' => 'size="24"',
307
+								'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
308
+								'required'              => false,
309
+							)
310
+						),
311
+						// "submit" button
312
+						'add_new_state_submit_button' => new EE_Form_Section_HTML(
313
+							apply_filters(
314
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
315
+								EEH_HTML::nbsp(3) .
316
+								EEH_HTML::link(
317
+									'',
318
+									esc_html__('ADD', 'event_espresso'),
319
+									'',
320
+									'submit-' . $new_state_submit_id,
321
+									'ee-form-add-new-state-submit button button-secondary',
322
+									'',
323
+									'data-target="' . $new_state_submit_id . '"'
324
+								)
325
+							)
326
+						),
327
+						// extra info
328
+						'add_new_state_extra'         => new EE_Form_Section_HTML(
329
+							apply_filters(
330
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
331
+								EEH_HTML::br(2)
332
+								.
333
+								EEH_HTML::div('', '', 'small-text')
334
+								.
335
+								EEH_HTML::strong(
336
+									'* ' .
337
+									esc_html__(
338
+										'Don\'t know your State/Province Abbreviation?',
339
+										'event_espresso'
340
+									)
341
+								)
342
+								.
343
+								EEH_HTML::br()
344
+								.
345
+								sprintf(
346
+									esc_html__(
347
+										'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
348
+										'event_espresso'
349
+									),
350
+									EEH_HTML::link(
351
+										'http://en.wikipedia.org/wiki/ISO_3166-2',
352
+										'http://en.wikipedia.org/wiki/ISO_3166-2',
353
+										'',
354
+										'',
355
+										'ee-form-add-new-state-wiki-lnk',
356
+										'',
357
+										'target="_blank"'
358
+									)
359
+								)
360
+								.
361
+								EEH_HTML::divx()
362
+								.
363
+								EEH_HTML::br()
364
+								.
365
+								EEH_HTML::link(
366
+									'',
367
+									esc_html__('cancel new State/Province', 'event_espresso'),
368
+									'',
369
+									'hide-' . $input->html_id(),
370
+									'ee-form-cancel-new-state-lnk smaller-text',
371
+									'',
372
+									'data-target="' . $input->html_id() . '"'
373
+								)
374
+								.
375
+								EEH_HTML::divx()
376
+								.
377
+								EEH_HTML::br()
378
+							)
379
+						),
380
+					),
381
+				)
382
+			);
383
+			$question_group_reg_form->add_subsections(
384
+				array('new_state_micro_form' => $new_state_micro_form),
385
+				'state',
386
+				false
387
+			);
388
+		}
389
+		return $question_group_reg_form;
390
+	}
391
+
392
+
393
+
394
+	/**
395
+	 * set_new_state_input_width
396
+	 *
397
+	 * @return int|string
398
+	 * @throws EE_Error
399
+	 */
400
+	public static function add_new_state()
401
+	{
402
+		$REQ = EE_Registry::instance()->load_core('Request_Handler');
403
+		if (absint($REQ->get('nsmf_add_new_state')) === 1) {
404
+			EE_Registry::instance()->load_model('State');
405
+			// grab country ISO code, new state name, and new state abbreviation
406
+			$state_country = $REQ->is_set('nsmf_new_state_country')
407
+				? sanitize_text_field($REQ->get('nsmf_new_state_country'))
408
+				: false;
409
+			$state_name = $REQ->is_set('nsmf_new_state_name')
410
+				? sanitize_text_field($REQ->get('nsmf_new_state_name'))
411
+				: false;
412
+			$state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
413
+				? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
414
+				: false;
415
+			if ($state_country && $state_name && $state_abbr) {
416
+				$new_state = EED_Add_New_State::save_new_state_to_db(array(
417
+					'CNT_ISO'    => strtoupper($state_country),
418
+					'STA_abbrev' => strtoupper($state_abbr),
419
+					'STA_name'   => ucwords($state_name),
420
+					'STA_active' => false,
421
+				));
422
+				if ($new_state instanceof EE_State) {
423
+					// clean house
424
+					EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
425
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
426
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
427
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
428
+					// get any existing new states
429
+					$new_states = EE_Registry::instance()->SSN->get_session_data(
430
+						'nsmf_new_states'
431
+					);
432
+					$new_states[$new_state->ID()] = $new_state;
433
+					EE_Registry::instance()->SSN->set_session_data(
434
+						array('nsmf_new_states' => $new_states)
435
+					);
436
+					if (EE_Registry::instance()->REQ->ajax) {
437
+						echo wp_json_encode(array(
438
+							'success'      => true,
439
+							'id'           => $new_state->ID(),
440
+							'name'         => $new_state->name(),
441
+							'abbrev'       => $new_state->abbrev(),
442
+							'country_iso'  => $new_state->country_iso(),
443
+							'country_name' => $new_state->country()->name(),
444
+						));
445
+						exit();
446
+					}
447
+					return $new_state->ID();
448
+				}
449
+			} else {
450
+				$error = esc_html__(
451
+					'A new State/Province could not be added because invalid or missing data was received.',
452
+					'event_espresso'
453
+				);
454
+				if (EE_Registry::instance()->REQ->ajax) {
455
+					echo wp_json_encode(array('error' => $error));
456
+					exit();
457
+				}
458
+				EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
459
+			}
460
+		}
461
+		return false;
462
+	}
463
+
464
+
465
+
466
+	/**
467
+	 * recursively drills down through request params to remove any that were added by this module
468
+	 *
469
+	 * @param array $request_params
470
+	 * @return array
471
+	 */
472
+	public static function filter_checkout_request_params($request_params)
473
+	{
474
+		foreach ($request_params as $form_section) {
475
+			if (is_array($form_section)) {
476
+				EED_Add_New_State::unset_new_state_request_params($form_section);
477
+				EED_Add_New_State::filter_checkout_request_params($form_section);
478
+			}
479
+		}
480
+		return $request_params;
481
+	}
482
+
483
+
484
+
485
+	/**
486
+	 * @param array $request_params
487
+	 * @return array
488
+	 */
489
+	public static function unset_new_state_request_params($request_params)
490
+	{
491
+		unset(
492
+			$request_params['new_state_micro_form'],
493
+			$request_params['new_state_micro_add_new_state'],
494
+			$request_params['new_state_micro_new_state_country'],
495
+			$request_params['new_state_micro_new_state_name'],
496
+			$request_params['new_state_micro_new_state_abbrv']
497
+		);
498
+		return $request_params;
499
+	}
500
+
501
+
502
+
503
+	/**
504
+	 * @param array $props_n_values
505
+	 * @return bool
506
+	 * @throws EE_Error
507
+	 */
508
+	public static function save_new_state_to_db($props_n_values = array())
509
+	{
510
+		$existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
511
+		if (! empty($existing_state)) {
512
+			return array_pop($existing_state);
513
+		}
514
+		$new_state = EE_State::new_instance($props_n_values);
515
+		if ($new_state instanceof EE_State) {
516
+			// if not non-ajax admin
517
+			$new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev();
518
+			$new_state_notice = sprintf(
519
+				esc_html__(
520
+					'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.',
521
+					'event_espresso'
522
+				),
523
+				'<b>' . $new_state->name() . '</b>',
524
+				'<b>' . $new_state->abbrev() . '</b>',
525
+				'<b>' . $new_state->country()->name() . '</b>',
526
+				'<a href="' . add_query_arg(array(
527
+					'page'    => 'espresso_general_settings',
528
+					'action'  => 'country_settings',
529
+					'country' => $new_state->country_iso(),
530
+				), admin_url('admin.php')) . '">' . esc_html__('Event Espresso - General Settings > Countries Tab',
531
+					'event_espresso') . '</a>',
532
+				'<br />'
533
+			);
534
+			EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice);
535
+			$new_state->save();
536
+			EEM_State::instance()->reset_cached_states();
537
+			return $new_state;
538
+		}
539
+		return false;
540
+	}
541
+
542
+
543
+
544
+	/**
545
+	 * @param string $CNT_ISO
546
+	 * @param string $STA_ID
547
+	 * @param array  $cols_n_values
548
+	 * @return void
549
+	 */
550
+	public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
551
+	{
552
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false;
553
+		if (! $CNT_ISO) {
554
+			EE_Error::add_error(
555
+				esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
556
+				__FILE__,
557
+				__FUNCTION__,
558
+				__LINE__
559
+			);
560
+		}
561
+		$STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
562
+			: false;
563
+		if (! $STA_abbrev && ! empty($STA_ID)) {
564
+			$state = EEM_State::instance()->get_one_by_ID($STA_ID);
565
+			if ($state instanceof EE_State) {
566
+				$STA_abbrev = $state->abbrev();
567
+			}
568
+		}
569
+		if (! $STA_abbrev) {
570
+			EE_Error::add_error(
571
+				esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
572
+				__FILE__,
573
+				__FUNCTION__,
574
+				__LINE__
575
+			);
576
+		}
577
+		EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true);
578
+	}
579
+
580
+
581
+
582
+	/**
583
+	 * @param EE_State[]                             $state_options
584
+	 * @param EE_SPCO_Reg_Step_Attendee_Information  $reg_step
585
+	 * @param EE_Registration                        $registration
586
+	 * @param EE_Question                            $question
587
+	 * @param                                        $answer
588
+	 * @return array
589
+	 */
590
+	public static function inject_new_reg_state_into_options(
591
+		$state_options = array(),
592
+		EE_SPCO_Reg_Step_Attendee_Information $reg_step,
593
+		EE_Registration $registration,
594
+		EE_Question $question,
595
+		$answer
596
+	) {
597
+		if ($answer instanceof EE_Answer && $question instanceof EE_Question
598
+			&& $question->type()
599
+			   === EEM_Question::QST_type_state
600
+		) {
601
+			$STA_ID = $answer->value();
602
+			if (! empty($STA_ID)) {
603
+				$state = EEM_State::instance()->get_one_by_ID($STA_ID);
604
+				if ($state instanceof EE_State) {
605
+					$country = $state->country();
606
+					if ($country instanceof EE_Country) {
607
+						if (! isset($state_options[$country->name()])) {
608
+							$state_options[$country->name()] = array();
609
+						}
610
+						if (! isset($state_options[$country->name()][$STA_ID])) {
611
+							$state_options[$country->name()][$STA_ID] = $state->name();
612
+						}
613
+					}
614
+				}
615
+			}
616
+		}
617
+		return $state_options;
618
+	}
619
+
620
+
621
+
622
+	/**
623
+	 * @param EE_Country[]                           $country_options
624
+	 * @param EE_SPCO_Reg_Step_Attendee_Information  $reg_step
625
+	 * @param EE_Registration                        $registration
626
+	 * @param EE_Question                            $question
627
+	 * @param                                        $answer
628
+	 * @return array
629
+	 */
630
+	public static function inject_new_reg_country_into_options(
631
+		$country_options = array(),
632
+		EE_SPCO_Reg_Step_Attendee_Information $reg_step,
633
+		EE_Registration $registration,
634
+		EE_Question $question,
635
+		$answer
636
+	) {
637
+		if ($answer instanceof EE_Answer && $question instanceof EE_Question
638
+			&& $question->type()
639
+			   === EEM_Question::QST_type_country
640
+		) {
641
+			$CNT_ISO = $answer->value();
642
+			if (! empty($CNT_ISO)) {
643
+				$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
644
+				if ($country instanceof EE_Country) {
645
+					if (! isset($country_options[$CNT_ISO])) {
646
+						$country_options[$CNT_ISO] = $country->name();
647
+					}
648
+				}
649
+			}
650
+		}
651
+		return $country_options;
652
+	}
653
+
654
+
655
+
656
+	/**
657
+	 * @param EE_State[] $state_options
658
+	 * @return array
659
+	 * @throws EE_Error
660
+	 */
661
+	public static function state_options($state_options = array())
662
+	{
663
+		$new_states = EED_Add_New_State::_get_new_states();
664
+		foreach ($new_states as $new_state) {
665
+			if (
666
+				$new_state instanceof EE_State
667
+				&& $new_state->country() instanceof EE_Country
668
+			) {
669
+				$state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name();
670
+			}
671
+		}
672
+		return $state_options;
673
+	}
674
+
675
+
676
+
677
+	/**
678
+	 * @return array
679
+	 */
680
+	protected static function _get_new_states()
681
+	{
682
+		$new_states = array();
683
+		if (EE_Registry::instance()->SSN instanceof EE_Session) {
684
+			$new_states = EE_Registry::instance()->SSN->get_session_data(
685
+				'nsmf_new_states'
686
+			);
687
+		}
688
+		return is_array($new_states) ? $new_states : array();
689
+	}
690
+
691
+
692
+
693
+	/**
694
+	 * @param EE_Country[] $country_options
695
+	 * @return array
696
+	 * @throws EE_Error
697
+	 */
698
+	public static function country_options($country_options = array())
699
+	{
700
+		$new_states = EED_Add_New_State::_get_new_states();
701
+		foreach ($new_states as $new_state) {
702
+			if (
703
+				$new_state instanceof EE_State
704
+				&& $new_state->country() instanceof EE_Country
705
+			) {
706
+				$country_options[$new_state->country()->ID()] = $new_state->country()->name();
707
+			}
708
+		}
709
+		return $country_options;
710
+	}
711 711
 
712 712
 
713 713
 
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public static function set_definitions()
95 95
     {
96
-        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
96
+        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
97 97
         define('ANS_TEMPLATES_PATH', str_replace(
98 98
             '\\',
99
-            DS, plugin_dir_path(__FILE__)) . 'templates' . DS
99
+            DS, plugin_dir_path(__FILE__)).'templates'.DS
100 100
         );
101 101
     }
102 102
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     public static function wp_enqueue_scripts()
148 148
     {
149 149
         if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
150
-            wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js',
150
+            wp_register_script('add_new_state', ANS_ASSETS_URL.'add_new_state.js',
151 151
                 array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true);
152 152
             wp_enqueue_script('add_new_state');
153 153
         }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
             $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
188 188
             $country_options = array();
189 189
             $countries = EEM_Country::instance()->get_all_countries();
190
-            if (! empty($countries)) {
190
+            if ( ! empty($countries)) {
191 191
                 foreach ($countries as $country) {
192 192
                     if ($country instanceof EE_Country) {
193 193
                         $country_options[$country->ID()] = $country->name();
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
                                     '',
223 223
                                     esc_html__('click here to add a new state/province', 'event_espresso'),
224 224
                                     '',
225
-                                    'display-' . $input->html_id(),
225
+                                    'display-'.$input->html_id(),
226 226
                                     'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
227 227
                                     '',
228
-                                    'data-target="' . $input->html_id() . '"'
228
+                                    'data-target="'.$input->html_id().'"'
229 229
                                 )
230 230
                             )
231 231
                         ),
@@ -233,31 +233,31 @@  discard block
 block discarded – undo
233 233
                         'add_new_state_micro_form'    => new EE_Form_Section_HTML(
234 234
                             apply_filters(
235 235
                                 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
236
-                                EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv',
237
-                                    'display: none;') .
236
+                                EEH_HTML::div('', $input->html_id().'-dv', 'ee-form-add-new-state-dv',
237
+                                    'display: none;').
238 238
                                 EEH_HTML::h6(
239 239
                                     esc_html__(
240 240
                                         'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:',
241 241
                                         'event_espresso'
242 242
                                     )
243
-                                ) .
244
-                                EEH_HTML::ul() .
243
+                                ).
244
+                                EEH_HTML::ul().
245 245
                                 EEH_HTML::li(
246 246
                                     esc_html__(
247 247
                                         'first select the Country that your State/Province belongs to',
248 248
                                         'event_espresso'
249 249
                                     )
250
-                                ) .
250
+                                ).
251 251
                                 EEH_HTML::li(
252 252
                                     esc_html__('enter the name of your State/Province', 'event_espresso')
253
-                                ) .
253
+                                ).
254 254
                                 EEH_HTML::li(
255 255
                                     esc_html__(
256 256
                                         'enter a two to six letter abbreviation for the name of your State/Province',
257 257
                                         'event_espresso'
258 258
                                     )
259
-                                ) .
260
-                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) .
259
+                                ).
260
+                                EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')).
261 261
                                 EEH_HTML::ulx()
262 262
                             )
263 263
                         ),
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
                                     'state',
271 271
                                     'nsmf_new_state_country', $input->html_id()
272 272
                                 ),
273
-                                'html_class'      => $input->html_class() . ' new-state-country',
273
+                                'html_class'      => $input->html_class().' new-state-country',
274 274
                                 'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'),
275 275
                                 'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
276 276
                                 'required'        => false,
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                                     'state',
285 285
                                     'nsmf_new_state_name', $input->html_id()
286 286
                                 ),
287
-                                'html_class'      => $input->html_class() . ' new-state-state',
287
+                                'html_class'      => $input->html_class().' new-state-state',
288 288
                                 'html_label_text' => esc_html__('New State/Province Name',
289 289
                                     'event_espresso'),
290 290
                                 'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
                                 'html_name'             => $abbrv_name,
299 299
                                 'html_id'               => str_replace('state', 'nsmf_new_state_abbrv',
300 300
                                     $input->html_id()),
301
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
301
+                                'html_class'            => $input->html_class().' new-state-abbrv',
302 302
                                 'html_label_text'       => esc_html__(
303 303
                                     'New State/Province Abbreviation',
304 304
                                     'event_espresso'
305
-                                ) . ' *',
305
+                                ).' *',
306 306
                                 'html_other_attributes' => 'size="24"',
307 307
                                 'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
308 308
                                 'required'              => false,
@@ -312,15 +312,15 @@  discard block
 block discarded – undo
312 312
                         'add_new_state_submit_button' => new EE_Form_Section_HTML(
313 313
                             apply_filters(
314 314
                                 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
315
-                                EEH_HTML::nbsp(3) .
315
+                                EEH_HTML::nbsp(3).
316 316
                                 EEH_HTML::link(
317 317
                                     '',
318 318
                                     esc_html__('ADD', 'event_espresso'),
319 319
                                     '',
320
-                                    'submit-' . $new_state_submit_id,
320
+                                    'submit-'.$new_state_submit_id,
321 321
                                     'ee-form-add-new-state-submit button button-secondary',
322 322
                                     '',
323
-                                    'data-target="' . $new_state_submit_id . '"'
323
+                                    'data-target="'.$new_state_submit_id.'"'
324 324
                                 )
325 325
                             )
326 326
                         ),
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                                 EEH_HTML::div('', '', 'small-text')
334 334
                                 .
335 335
                                 EEH_HTML::strong(
336
-                                    '* ' .
336
+                                    '* '.
337 337
                                     esc_html__(
338 338
                                         'Don\'t know your State/Province Abbreviation?',
339 339
                                         'event_espresso'
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
                                     '',
367 367
                                     esc_html__('cancel new State/Province', 'event_espresso'),
368 368
                                     '',
369
-                                    'hide-' . $input->html_id(),
369
+                                    'hide-'.$input->html_id(),
370 370
                                     'ee-form-cancel-new-state-lnk smaller-text',
371 371
                                     '',
372
-                                    'data-target="' . $input->html_id() . '"'
372
+                                    'data-target="'.$input->html_id().'"'
373 373
                                 )
374 374
                                 .
375 375
                                 EEH_HTML::divx()
@@ -508,27 +508,27 @@  discard block
 block discarded – undo
508 508
     public static function save_new_state_to_db($props_n_values = array())
509 509
     {
510 510
         $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
511
-        if (! empty($existing_state)) {
511
+        if ( ! empty($existing_state)) {
512 512
             return array_pop($existing_state);
513 513
         }
514 514
         $new_state = EE_State::new_instance($props_n_values);
515 515
         if ($new_state instanceof EE_State) {
516 516
             // if not non-ajax admin
517
-            $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev();
517
+            $new_state_key = 'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev();
518 518
             $new_state_notice = sprintf(
519 519
                 esc_html__(
520 520
                     '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.',
521 521
                     'event_espresso'
522 522
                 ),
523
-                '<b>' . $new_state->name() . '</b>',
524
-                '<b>' . $new_state->abbrev() . '</b>',
525
-                '<b>' . $new_state->country()->name() . '</b>',
526
-                '<a href="' . add_query_arg(array(
523
+                '<b>'.$new_state->name().'</b>',
524
+                '<b>'.$new_state->abbrev().'</b>',
525
+                '<b>'.$new_state->country()->name().'</b>',
526
+                '<a href="'.add_query_arg(array(
527 527
                     'page'    => 'espresso_general_settings',
528 528
                     'action'  => 'country_settings',
529 529
                     'country' => $new_state->country_iso(),
530
-                ), admin_url('admin.php')) . '">' . esc_html__('Event Espresso - General Settings > Countries Tab',
531
-                    'event_espresso') . '</a>',
530
+                ), admin_url('admin.php')).'">'.esc_html__('Event Espresso - General Settings > Countries Tab',
531
+                    'event_espresso').'</a>',
532 532
                 '<br />'
533 533
             );
534 534
             EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice);
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
     public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
551 551
     {
552 552
         $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false;
553
-        if (! $CNT_ISO) {
553
+        if ( ! $CNT_ISO) {
554 554
             EE_Error::add_error(
555 555
                 esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'),
556 556
                 __FILE__,
@@ -560,13 +560,13 @@  discard block
 block discarded – undo
560 560
         }
561 561
         $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
562 562
             : false;
563
-        if (! $STA_abbrev && ! empty($STA_ID)) {
563
+        if ( ! $STA_abbrev && ! empty($STA_ID)) {
564 564
             $state = EEM_State::instance()->get_one_by_ID($STA_ID);
565 565
             if ($state instanceof EE_State) {
566 566
                 $STA_abbrev = $state->abbrev();
567 567
             }
568 568
         }
569
-        if (! $STA_abbrev) {
569
+        if ( ! $STA_abbrev) {
570 570
             EE_Error::add_error(
571 571
                 esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
572 572
                 __FILE__,
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
                 __LINE__
575 575
             );
576 576
         }
577
-        EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true);
577
+        EE_Error::dismiss_persistent_admin_notice($CNT_ISO.'-'.$STA_abbrev, true, true);
578 578
     }
579 579
 
580 580
 
@@ -599,15 +599,15 @@  discard block
 block discarded – undo
599 599
                === EEM_Question::QST_type_state
600 600
         ) {
601 601
             $STA_ID = $answer->value();
602
-            if (! empty($STA_ID)) {
602
+            if ( ! empty($STA_ID)) {
603 603
                 $state = EEM_State::instance()->get_one_by_ID($STA_ID);
604 604
                 if ($state instanceof EE_State) {
605 605
                     $country = $state->country();
606 606
                     if ($country instanceof EE_Country) {
607
-                        if (! isset($state_options[$country->name()])) {
607
+                        if ( ! isset($state_options[$country->name()])) {
608 608
                             $state_options[$country->name()] = array();
609 609
                         }
610
-                        if (! isset($state_options[$country->name()][$STA_ID])) {
610
+                        if ( ! isset($state_options[$country->name()][$STA_ID])) {
611 611
                             $state_options[$country->name()][$STA_ID] = $state->name();
612 612
                         }
613 613
                     }
@@ -639,10 +639,10 @@  discard block
 block discarded – undo
639 639
                === EEM_Question::QST_type_country
640 640
         ) {
641 641
             $CNT_ISO = $answer->value();
642
-            if (! empty($CNT_ISO)) {
642
+            if ( ! empty($CNT_ISO)) {
643 643
                 $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
644 644
                 if ($country instanceof EE_Country) {
645
-                    if (! isset($country_options[$CNT_ISO])) {
645
+                    if ( ! isset($country_options[$CNT_ISO])) {
646 646
                         $country_options[$CNT_ISO] = $country->name();
647 647
                     }
648 648
                 }
Please login to merge, or discard this patch.
strategies/normalization/EE_Credit_Card_Normalization.strategy.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 class EE_Credit_Card_Normalization extends EE_Text_Normalization
15 15
 {
16 16
 
17
-    /**
18
-     * @param string $value_to_normalize
19
-     * @return mixed
20
-     */
21
-    public function normalize($value_to_normalize)
22
-    {
23
-        $normalized_by_parent = parent::normalize($value_to_normalize);
24
-        //we want to make it consistent, so remove whitespace from cc number
25
-        return preg_replace('/\s+/', '', $normalized_by_parent);
26
-    }
17
+	/**
18
+	 * @param string $value_to_normalize
19
+	 * @return mixed
20
+	 */
21
+	public function normalize($value_to_normalize)
22
+	{
23
+		$normalized_by_parent = parent::normalize($value_to_normalize);
24
+		//we want to make it consistent, so remove whitespace from cc number
25
+		return preg_replace('/\s+/', '', $normalized_by_parent);
26
+	}
27 27
 }
28 28
 // End of file EE_Credit_Card_Normalization.strategy.php
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
Please login to merge, or discard this patch.
strategies/normalization/EE_Many_Valued_Normalization.strategy.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -14,91 +14,91 @@  discard block
 block discarded – undo
14 14
 class EE_Many_Valued_Normalization extends EE_Normalization_Strategy_Base
15 15
 {
16 16
 
17
-    protected $_individual_item_normalization_strategy = array();
18
-
19
-
20
-
21
-    /**
22
-     * @param EE_Normalization_Strategy_Base $individual_item_normalization_strategy
23
-     */
24
-    public function __construct($individual_item_normalization_strategy)
25
-    {
26
-        $this->_individual_item_normalization_strategy = $individual_item_normalization_strategy;
27
-        parent::__construct();
28
-    }
29
-
30
-
31
-
32
-    /**
33
-     * Normalizes the input into an array, and normalizes each item according to its
34
-     * individual item normalization strategy
35
-     *
36
-     * @param array | string $value_to_normalize
37
-     * @return array
38
-     */
39
-    public function normalize($value_to_normalize)
40
-    {
41
-        if (is_array($value_to_normalize)) {
42
-            $items_to_normalize = $value_to_normalize;
43
-        } else if ($value_to_normalize !== null) {
44
-            $items_to_normalize = array($value_to_normalize);
45
-        } else {
46
-            $items_to_normalize = array();
47
-        }
48
-        $normalized_array_value = array();
49
-        foreach ($items_to_normalize as $key => $individual_item) {
50
-            $normalized_array_value[$key] = $this->normalize_one($individual_item);
51
-        }
52
-        return $normalized_array_value;
53
-    }
54
-
55
-
56
-
57
-    /**
58
-     * Normalized the one item (called for each array item in EE_Many_values_Normalization::normalize())
59
-     *
60
-     * @param string $individual_value_to_normalize but definitely NOT an array
61
-     * @return mixed
62
-     */
63
-    public function normalize_one($individual_value_to_normalize)
64
-    {
65
-        return $this->_individual_item_normalization_strategy->normalize($individual_value_to_normalize);
66
-    }
67
-
68
-
69
-
70
-    /**
71
-     * Converts the array of normalized things to an array of raw html values.
72
-     *
73
-     * @param array $normalized_values
74
-     * @return string[]
75
-     */
76
-    public function unnormalize($normalized_values)
77
-    {
78
-        if ($normalized_values === null) {
79
-            $normalized_values = array();
80
-        }
81
-        if (! is_array($normalized_values)) {
82
-            $normalized_values = array($normalized_values);
83
-        }
84
-        $non_normal_values = array();
85
-        foreach ($normalized_values as $key => $value) {
86
-            $non_normal_values[$key] = $this->unnormalize_one($value);
87
-        }
88
-        return $non_normal_values;
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * Unnormalizes an individual item in the array of values
95
-     *
96
-     * @param mixed $individual_value_to_unnormalize but certainly NOT an array
97
-     * @return string
98
-     */
99
-    public function unnormalize_one($individual_value_to_unnormalize)
100
-    {
101
-        return $this->_individual_item_normalization_strategy->unnormalize($individual_value_to_unnormalize);
102
-    }
17
+	protected $_individual_item_normalization_strategy = array();
18
+
19
+
20
+
21
+	/**
22
+	 * @param EE_Normalization_Strategy_Base $individual_item_normalization_strategy
23
+	 */
24
+	public function __construct($individual_item_normalization_strategy)
25
+	{
26
+		$this->_individual_item_normalization_strategy = $individual_item_normalization_strategy;
27
+		parent::__construct();
28
+	}
29
+
30
+
31
+
32
+	/**
33
+	 * Normalizes the input into an array, and normalizes each item according to its
34
+	 * individual item normalization strategy
35
+	 *
36
+	 * @param array | string $value_to_normalize
37
+	 * @return array
38
+	 */
39
+	public function normalize($value_to_normalize)
40
+	{
41
+		if (is_array($value_to_normalize)) {
42
+			$items_to_normalize = $value_to_normalize;
43
+		} else if ($value_to_normalize !== null) {
44
+			$items_to_normalize = array($value_to_normalize);
45
+		} else {
46
+			$items_to_normalize = array();
47
+		}
48
+		$normalized_array_value = array();
49
+		foreach ($items_to_normalize as $key => $individual_item) {
50
+			$normalized_array_value[$key] = $this->normalize_one($individual_item);
51
+		}
52
+		return $normalized_array_value;
53
+	}
54
+
55
+
56
+
57
+	/**
58
+	 * Normalized the one item (called for each array item in EE_Many_values_Normalization::normalize())
59
+	 *
60
+	 * @param string $individual_value_to_normalize but definitely NOT an array
61
+	 * @return mixed
62
+	 */
63
+	public function normalize_one($individual_value_to_normalize)
64
+	{
65
+		return $this->_individual_item_normalization_strategy->normalize($individual_value_to_normalize);
66
+	}
67
+
68
+
69
+
70
+	/**
71
+	 * Converts the array of normalized things to an array of raw html values.
72
+	 *
73
+	 * @param array $normalized_values
74
+	 * @return string[]
75
+	 */
76
+	public function unnormalize($normalized_values)
77
+	{
78
+		if ($normalized_values === null) {
79
+			$normalized_values = array();
80
+		}
81
+		if (! is_array($normalized_values)) {
82
+			$normalized_values = array($normalized_values);
83
+		}
84
+		$non_normal_values = array();
85
+		foreach ($normalized_values as $key => $value) {
86
+			$non_normal_values[$key] = $this->unnormalize_one($value);
87
+		}
88
+		return $non_normal_values;
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * Unnormalizes an individual item in the array of values
95
+	 *
96
+	 * @param mixed $individual_value_to_unnormalize but certainly NOT an array
97
+	 * @return string
98
+	 */
99
+	public function unnormalize_one($individual_value_to_unnormalize)
100
+	{
101
+		return $this->_individual_item_normalization_strategy->unnormalize($individual_value_to_unnormalize);
102
+	}
103 103
 }
104 104
 // End of file EE_Many_Valued_Normalization.strategy.php
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         if ($normalized_values === null) {
79 79
             $normalized_values = array();
80 80
         }
81
-        if (! is_array($normalized_values)) {
81
+        if ( ! is_array($normalized_values)) {
82 82
             $normalized_values = array($normalized_values);
83 83
         }
84 84
         $non_normal_values = array();
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Float_Normalization.strategy.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
             return null;
37 37
         }
38 38
         if (is_float($value_to_normalize) || is_int($value_to_normalize)) {
39
-            return (float)$value_to_normalize;
39
+            return (float) $value_to_normalize;
40 40
         }
41
-        if (! is_string($value_to_normalize)) {
41
+        if ( ! is_string($value_to_normalize)) {
42 42
             throw new EE_Validation_Error(
43 43
                 sprintf(
44 44
                     __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
                 // if first match is the negative sign,
61 61
                 // then the number needs to be multiplied by -1 to remain negative
62 62
                 return $matches[1] === '-'
63
-                    ? (float)$matches[2] * -1
64
-                    : (float)$matches[2];
63
+                    ? (float) $matches[2] * -1
64
+                    : (float) $matches[2];
65 65
             }
66 66
         }
67 67
         //find if this input has a float validation strategy
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         }
75 75
         //this really shouldn't ever happen because fields with a float normalization strategy
76 76
         //should also have a float validation strategy, but in case it doesn't use the default
77
-        if (! $validation_error_message) {
77
+        if ( ! $validation_error_message) {
78 78
             $default_validation_strategy = new EE_Float_Validation_Strategy();
79 79
             $validation_error_message = $default_validation_strategy->get_validation_error_message();
80 80
         }
Please login to merge, or discard this patch.
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -15,85 +15,85 @@  discard block
 block discarded – undo
15 15
 class EE_Float_Normalization extends EE_Normalization_Strategy_Base
16 16
 {
17 17
 
18
-    /*
18
+	/*
19 19
      * regex pattern that matches for the following:
20 20
      *      * optional negative sign
21 21
      *      * one or more digits or decimals
22 22
      */
23
-    const REGEX = '/^(-?)([\d.]+)$/';
23
+	const REGEX = '/^(-?)([\d.]+)$/';
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * @param string $value_to_normalize
29
-     * @return float
30
-     * @throws \EE_Validation_Error
31
-     */
32
-    public function normalize($value_to_normalize)
33
-    {
34
-        if ($value_to_normalize === null) {
35
-            return null;
36
-        }
37
-        if (is_float($value_to_normalize) || is_int($value_to_normalize)) {
38
-            return (float)$value_to_normalize;
39
-        }
40
-        if (! is_string($value_to_normalize)) {
41
-            throw new EE_Validation_Error(
42
-                sprintf(
43
-                    __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
44
-                    print_r($value_to_normalize, true),
45
-                    gettype($value_to_normalize)
46
-                )
47
-            );
48
-        }
49
-        $normalized_value = filter_var(
50
-            $value_to_normalize,
51
-            FILTER_SANITIZE_NUMBER_FLOAT,
52
-            FILTER_FLAG_ALLOW_FRACTION
53
-        );
54
-        if ($normalized_value === '') {
55
-            return null;
56
-        }
57
-        if (preg_match(EE_Float_Normalization::REGEX, $normalized_value, $matches)) {
58
-            if (count($matches) === 3) {
59
-                // if first match is the negative sign,
60
-                // then the number needs to be multiplied by -1 to remain negative
61
-                return $matches[1] === '-'
62
-                    ? (float)$matches[2] * -1
63
-                    : (float)$matches[2];
64
-            }
65
-        }
66
-        //find if this input has a float validation strategy
67
-        //in which case, use its message
68
-        $validation_error_message = null;
69
-        foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
70
-            if ($validation_strategy instanceof EE_Float_Validation_Strategy) {
71
-                $validation_error_message = $validation_strategy->get_validation_error_message();
72
-            }
73
-        }
74
-        //this really shouldn't ever happen because fields with a float normalization strategy
75
-        //should also have a float validation strategy, but in case it doesn't use the default
76
-        if (! $validation_error_message) {
77
-            $default_validation_strategy = new EE_Float_Validation_Strategy();
78
-            $validation_error_message = $default_validation_strategy->get_validation_error_message();
79
-        }
80
-        throw new EE_Validation_Error($validation_error_message, 'float_only');
81
-    }
27
+	/**
28
+	 * @param string $value_to_normalize
29
+	 * @return float
30
+	 * @throws \EE_Validation_Error
31
+	 */
32
+	public function normalize($value_to_normalize)
33
+	{
34
+		if ($value_to_normalize === null) {
35
+			return null;
36
+		}
37
+		if (is_float($value_to_normalize) || is_int($value_to_normalize)) {
38
+			return (float)$value_to_normalize;
39
+		}
40
+		if (! is_string($value_to_normalize)) {
41
+			throw new EE_Validation_Error(
42
+				sprintf(
43
+					__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'),
44
+					print_r($value_to_normalize, true),
45
+					gettype($value_to_normalize)
46
+				)
47
+			);
48
+		}
49
+		$normalized_value = filter_var(
50
+			$value_to_normalize,
51
+			FILTER_SANITIZE_NUMBER_FLOAT,
52
+			FILTER_FLAG_ALLOW_FRACTION
53
+		);
54
+		if ($normalized_value === '') {
55
+			return null;
56
+		}
57
+		if (preg_match(EE_Float_Normalization::REGEX, $normalized_value, $matches)) {
58
+			if (count($matches) === 3) {
59
+				// if first match is the negative sign,
60
+				// then the number needs to be multiplied by -1 to remain negative
61
+				return $matches[1] === '-'
62
+					? (float)$matches[2] * -1
63
+					: (float)$matches[2];
64
+			}
65
+		}
66
+		//find if this input has a float validation strategy
67
+		//in which case, use its message
68
+		$validation_error_message = null;
69
+		foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
70
+			if ($validation_strategy instanceof EE_Float_Validation_Strategy) {
71
+				$validation_error_message = $validation_strategy->get_validation_error_message();
72
+			}
73
+		}
74
+		//this really shouldn't ever happen because fields with a float normalization strategy
75
+		//should also have a float validation strategy, but in case it doesn't use the default
76
+		if (! $validation_error_message) {
77
+			$default_validation_strategy = new EE_Float_Validation_Strategy();
78
+			$validation_error_message = $default_validation_strategy->get_validation_error_message();
79
+		}
80
+		throw new EE_Validation_Error($validation_error_message, 'float_only');
81
+	}
82 82
 
83 83
 
84 84
 
85
-    /**
86
-     * Converts a float into a string
87
-     *
88
-     * @param float $normalized_value
89
-     * @return string
90
-     */
91
-    public function unnormalize($normalized_value)
92
-    {
93
-        if (empty($normalized_value)) {
94
-            return '0.00';
95
-        }
96
-        return "{$normalized_value}";
97
-    }
85
+	/**
86
+	 * Converts a float into a string
87
+	 *
88
+	 * @param float $normalized_value
89
+	 * @return string
90
+	 */
91
+	public function unnormalize($normalized_value)
92
+	{
93
+		if (empty($normalized_value)) {
94
+			return '0.00';
95
+		}
96
+		return "{$normalized_value}";
97
+	}
98 98
 }
99 99
 // End of file EE_Float_Normalization.strategy.php
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Slug_Normalization.strategy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -15,26 +15,26 @@  discard block
 block discarded – undo
15 15
 class EE_Slug_Normalization extends EE_Normalization_Strategy_Base
16 16
 {
17 17
 
18
-    /**
19
-     * @param string $value_to_normalize
20
-     * @return string
21
-     */
22
-    public function normalize($value_to_normalize)
23
-    {
24
-        return sanitize_title($value_to_normalize);
25
-    }
18
+	/**
19
+	 * @param string $value_to_normalize
20
+	 * @return string
21
+	 */
22
+	public function normalize($value_to_normalize)
23
+	{
24
+		return sanitize_title($value_to_normalize);
25
+	}
26 26
 
27 27
 
28 28
 
29
-    /**
30
-     * It's hard to unnormalize this- let's just take a guess
31
-     *
32
-     * @param string $normalized_value
33
-     * @return string
34
-     */
35
-    public function unnormalize($normalized_value)
36
-    {
37
-        return str_replace("-", " ", $normalized_value);
38
-    }
29
+	/**
30
+	 * It's hard to unnormalize this- let's just take a guess
31
+	 *
32
+	 * @param string $normalized_value
33
+	 * @return string
34
+	 */
35
+	public function unnormalize($normalized_value)
36
+	{
37
+		return str_replace("-", " ", $normalized_value);
38
+	}
39 39
 }
40 40
 // End of file EE_Slug_Normalization.strategy.php
Please login to merge, or discard this patch.
strategies/normalization/EE_All_Caps_Normalization.strategy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -16,27 +16,27 @@  discard block
 block discarded – undo
16 16
 class EE_All_Caps_Normalization extends EE_Normalization_Strategy_Base
17 17
 {
18 18
 
19
-    /**
20
-     * @param string $value_to_normalize
21
-     * @return string
22
-     */
23
-    public function normalize($value_to_normalize)
24
-    {
25
-        return strtoupper($value_to_normalize);
26
-    }
27
-
28
-
29
-
30
-    /**
31
-     * It's kinda hard to unnormalize this- we can't determine which parts used to be lowercase
32
-     * so just return it as-is.
33
-     *
34
-     * @param string $normalized_value
35
-     * @return string
36
-     */
37
-    public function unnormalize($normalized_value)
38
-    {
39
-        return $normalized_value;
40
-    }
19
+	/**
20
+	 * @param string $value_to_normalize
21
+	 * @return string
22
+	 */
23
+	public function normalize($value_to_normalize)
24
+	{
25
+		return strtoupper($value_to_normalize);
26
+	}
27
+
28
+
29
+
30
+	/**
31
+	 * It's kinda hard to unnormalize this- we can't determine which parts used to be lowercase
32
+	 * so just return it as-is.
33
+	 *
34
+	 * @param string $normalized_value
35
+	 * @return string
36
+	 */
37
+	public function unnormalize($normalized_value)
38
+	{
39
+		return $normalized_value;
40
+	}
41 41
 
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
strategies/normalization/EE_Boolean_Normalization.strategy.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -18,28 +18,28 @@  discard block
 block discarded – undo
18 18
 class EE_Boolean_Normalization extends EE_Normalization_Strategy_Base
19 19
 {
20 20
 
21
-    /**
22
-     * @param string | int | bool $value_to_normalize
23
-     * @return boolean
24
-     */
25
-    public function normalize($value_to_normalize)
26
-    {
27
-        return filter_var($value_to_normalize, FILTER_VALIDATE_BOOLEAN);
28
-    }
21
+	/**
22
+	 * @param string | int | bool $value_to_normalize
23
+	 * @return boolean
24
+	 */
25
+	public function normalize($value_to_normalize)
26
+	{
27
+		return filter_var($value_to_normalize, FILTER_VALIDATE_BOOLEAN);
28
+	}
29 29
 
30 30
 
31 31
 
32
-    /**
33
-     * @param boolean $normalized_value
34
-     * @return string
35
-     */
36
-    public function unnormalize($normalized_value)
37
-    {
38
-        if ($normalized_value) {
39
-            return '1';
40
-        } else {
41
-            return '0';
42
-        }
43
-    }
32
+	/**
33
+	 * @param boolean $normalized_value
34
+	 * @return string
35
+	 */
36
+	public function unnormalize($normalized_value)
37
+	{
38
+		if ($normalized_value) {
39
+			return '1';
40
+		} else {
41
+			return '0';
42
+		}
43
+	}
44 44
 }
45 45
 // End of file EE_Boolean_Normalization.strategy.php
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
Please login to merge, or discard this patch.