Completed
Branch FET-10693-composite-command-ha... (43df37)
by
unknown
48:48 queued 38:21
created
core/domain/ConstantsAbstract.php 2 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -14,72 +14,72 @@
 block discarded – undo
14 14
  */
15 15
 abstract class ConstantsAbstract
16 16
 {
17
-    /**
18
-     * Equivalent to `__FILE__` for main plugin file.
19
-     * @var string
20
-     */
21
-    private static $plugin_file ='';
22
-
23
-
24
-    /**
25
-     * String indicating version for plugin
26
-     * @var string
27
-     */
28
-    private static $version = '';
29
-
30
-
31
-    /**
32
-     * Initializes internal static properties.
33
-     * @param $plugin_file
34
-     * @param $version
35
-     */
36
-    public static function init($plugin_file, $version)
37
-    {
38
-        self::$plugin_file = $plugin_file;
39
-        self::$version     = $version;
40
-    }
41
-
42
-
43
-    /**
44
-     * @return string
45
-     */
46
-    public static function pluginFile()
47
-    {
48
-        return self::$plugin_file;
49
-    }
50
-
51
-    /**
52
-     * @return string
53
-     */
54
-    public static function pluginBasename()
55
-    {
56
-        return plugin_basename(self::$plugin_file);
57
-    }
58
-
59
-    /**
60
-     * @return string
61
-     */
62
-    public static function pluginPath()
63
-    {
64
-        return plugin_dir_path(self::$plugin_file);
65
-    }
66
-
67
-
68
-    /**
69
-     * @return string
70
-     */
71
-    public static function pluginUrl()
72
-    {
73
-        return plugin_dir_url(self::$plugin_file);
74
-    }
75
-
76
-
77
-    /**
78
-     * @return string
79
-     */
80
-    public static function version()
81
-    {
82
-        return self::$version;
83
-    }
17
+	/**
18
+	 * Equivalent to `__FILE__` for main plugin file.
19
+	 * @var string
20
+	 */
21
+	private static $plugin_file ='';
22
+
23
+
24
+	/**
25
+	 * String indicating version for plugin
26
+	 * @var string
27
+	 */
28
+	private static $version = '';
29
+
30
+
31
+	/**
32
+	 * Initializes internal static properties.
33
+	 * @param $plugin_file
34
+	 * @param $version
35
+	 */
36
+	public static function init($plugin_file, $version)
37
+	{
38
+		self::$plugin_file = $plugin_file;
39
+		self::$version     = $version;
40
+	}
41
+
42
+
43
+	/**
44
+	 * @return string
45
+	 */
46
+	public static function pluginFile()
47
+	{
48
+		return self::$plugin_file;
49
+	}
50
+
51
+	/**
52
+	 * @return string
53
+	 */
54
+	public static function pluginBasename()
55
+	{
56
+		return plugin_basename(self::$plugin_file);
57
+	}
58
+
59
+	/**
60
+	 * @return string
61
+	 */
62
+	public static function pluginPath()
63
+	{
64
+		return plugin_dir_path(self::$plugin_file);
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return string
70
+	 */
71
+	public static function pluginUrl()
72
+	{
73
+		return plugin_dir_url(self::$plugin_file);
74
+	}
75
+
76
+
77
+	/**
78
+	 * @return string
79
+	 */
80
+	public static function version()
81
+	{
82
+		return self::$version;
83
+	}
84 84
 
85 85
 }
86 86
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
      * Equivalent to `__FILE__` for main plugin file.
19 19
      * @var string
20 20
      */
21
-    private static $plugin_file ='';
21
+    private static $plugin_file = '';
22 22
 
23 23
 
24 24
     /**
Please login to merge, or discard this patch.
core/services/commands/CommandBus.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\services\commands\middleware\InvalidCommandBusMiddlewareException;
8 8
 
9 9
 if (! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 
@@ -40,78 +40,78 @@  discard block
 block discarded – undo
40 40
 class CommandBus implements CommandBusInterface
41 41
 {
42 42
 
43
-    /**
44
-     * @type CommandHandlerManagerInterface $command_handler_manager
45
-     */
46
-    private $command_handler_manager;
47
-
48
-    /**
49
-     * @type CommandBusMiddlewareInterface[] $command_bus_middleware
50
-     */
51
-    private $command_bus_middleware;
52
-
53
-
54
-
55
-    /**
56
-     * CommandBus constructor
57
-     *
58
-     * @param CommandHandlerManagerInterface  $command_handler_manager
59
-     * @param CommandBusMiddlewareInterface[] $command_bus_middleware
60
-     */
61
-    public function __construct(
62
-        CommandHandlerManagerInterface $command_handler_manager,
63
-        $command_bus_middleware = array()
64
-    ) {
65
-        $this->command_handler_manager = $command_handler_manager;
66
-        $this->command_bus_middleware = is_array($command_bus_middleware)
67
-            ? $command_bus_middleware
68
-            : array($command_bus_middleware);
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     * @return CommandHandlerManagerInterface
75
-     */
76
-    public function getCommandHandlerManager()
77
-    {
78
-        return $this->command_handler_manager;
79
-    }
80
-
81
-
82
-
83
-    /**
84
-     * @param CommandInterface $command
85
-     * @return mixed
86
-     * @throws InvalidDataTypeException
87
-     * @throws InvalidCommandBusMiddlewareException
88
-     */
89
-    public function execute($command)
90
-    {
91
-        if (! $command instanceof CommandInterface) {
92
-            throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface');
93
-        }
94
-        // we're going to add the Command Handler as a callable
95
-        // that will get run at the end of our middleware stack
96
-        // can't pass $this to a Closure, so use a named variable
97
-        $command_bus = $this;
98
-        $middleware = function ($command) use ($command_bus) {
99
-            return $command_bus->getCommandHandlerManager()
100
-                ->getCommandHandler($command, $command_bus)
101
-                ->handle($command);
102
-        };
103
-        // now build the rest of the middleware stack
104
-        while ($command_bus_middleware = array_pop($this->command_bus_middleware)) {
105
-            if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
106
-                throw new InvalidCommandBusMiddlewareException($command_bus_middleware);
107
-            }
108
-            $middleware = function ($command) use ($command_bus_middleware, $middleware) {
109
-                return $command_bus_middleware->handle($command, $middleware);
110
-            };
111
-        }
112
-        // and finally, pass the command into the stack and return the results
113
-        return $middleware($command);
114
-    }
43
+	/**
44
+	 * @type CommandHandlerManagerInterface $command_handler_manager
45
+	 */
46
+	private $command_handler_manager;
47
+
48
+	/**
49
+	 * @type CommandBusMiddlewareInterface[] $command_bus_middleware
50
+	 */
51
+	private $command_bus_middleware;
52
+
53
+
54
+
55
+	/**
56
+	 * CommandBus constructor
57
+	 *
58
+	 * @param CommandHandlerManagerInterface  $command_handler_manager
59
+	 * @param CommandBusMiddlewareInterface[] $command_bus_middleware
60
+	 */
61
+	public function __construct(
62
+		CommandHandlerManagerInterface $command_handler_manager,
63
+		$command_bus_middleware = array()
64
+	) {
65
+		$this->command_handler_manager = $command_handler_manager;
66
+		$this->command_bus_middleware = is_array($command_bus_middleware)
67
+			? $command_bus_middleware
68
+			: array($command_bus_middleware);
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 * @return CommandHandlerManagerInterface
75
+	 */
76
+	public function getCommandHandlerManager()
77
+	{
78
+		return $this->command_handler_manager;
79
+	}
80
+
81
+
82
+
83
+	/**
84
+	 * @param CommandInterface $command
85
+	 * @return mixed
86
+	 * @throws InvalidDataTypeException
87
+	 * @throws InvalidCommandBusMiddlewareException
88
+	 */
89
+	public function execute($command)
90
+	{
91
+		if (! $command instanceof CommandInterface) {
92
+			throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface');
93
+		}
94
+		// we're going to add the Command Handler as a callable
95
+		// that will get run at the end of our middleware stack
96
+		// can't pass $this to a Closure, so use a named variable
97
+		$command_bus = $this;
98
+		$middleware = function ($command) use ($command_bus) {
99
+			return $command_bus->getCommandHandlerManager()
100
+				->getCommandHandler($command, $command_bus)
101
+				->handle($command);
102
+		};
103
+		// now build the rest of the middleware stack
104
+		while ($command_bus_middleware = array_pop($this->command_bus_middleware)) {
105
+			if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
106
+				throw new InvalidCommandBusMiddlewareException($command_bus_middleware);
107
+			}
108
+			$middleware = function ($command) use ($command_bus_middleware, $middleware) {
109
+				return $command_bus_middleware->handle($command, $middleware);
110
+			};
111
+		}
112
+		// and finally, pass the command into the stack and return the results
113
+		return $middleware($command);
114
+	}
115 115
 
116 116
 
117 117
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\services\commands\middleware\CommandBusMiddlewareInterface;
7 7
 use EventEspresso\core\services\commands\middleware\InvalidCommandBusMiddlewareException;
8 8
 
9
-if (! defined('EVENT_ESPRESSO_VERSION')) {
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10 10
     exit('No direct script access allowed');
11 11
 }
12 12
 
@@ -88,24 +88,24 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function execute($command)
90 90
     {
91
-        if (! $command instanceof CommandInterface) {
92
-            throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface');
91
+        if ( ! $command instanceof CommandInterface) {
92
+            throw new InvalidDataTypeException(__METHOD__.'( $command )', $command, 'CommandInterface');
93 93
         }
94 94
         // we're going to add the Command Handler as a callable
95 95
         // that will get run at the end of our middleware stack
96 96
         // can't pass $this to a Closure, so use a named variable
97 97
         $command_bus = $this;
98
-        $middleware = function ($command) use ($command_bus) {
98
+        $middleware = function($command) use ($command_bus) {
99 99
             return $command_bus->getCommandHandlerManager()
100 100
                 ->getCommandHandler($command, $command_bus)
101 101
                 ->handle($command);
102 102
         };
103 103
         // now build the rest of the middleware stack
104 104
         while ($command_bus_middleware = array_pop($this->command_bus_middleware)) {
105
-            if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
105
+            if ( ! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
106 106
                 throw new InvalidCommandBusMiddlewareException($command_bus_middleware);
107 107
             }
108
-            $middleware = function ($command) use ($command_bus_middleware, $middleware) {
108
+            $middleware = function($command) use ($command_bus_middleware, $middleware) {
109 109
                 return $command_bus_middleware->handle($command, $middleware);
110 110
             };
111 111
         }
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   +615 added lines, -615 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,620 +16,620 @@  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('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
98
-    }
99
-
100
-
101
-
102
-    /**
103
-     * @param WP $WP
104
-     * @return void
105
-     */
106
-    public function run($WP)
107
-    {
108
-    }
109
-
110
-
111
-
112
-    /**
113
-      * @return void
114
-     */
115
-    public static function translate_js_strings()
116
-    {
117
-        EE_Registry::$i18n_js_strings['ans_no_country'] = __('In order to proceed, you need to select the Country that your State/Province belongs to.',
118
-            'event_espresso');
119
-        EE_Registry::$i18n_js_strings['ans_no_name'] = __('In order to proceed, you need to enter the name of your State/Province.',
120
-            'event_espresso');
121
-        EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = __('In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
122
-            'event_espresso');
123
-        EE_Registry::$i18n_js_strings['ans_save_success'] = __('The new state was successfully saved to the database.',
124
-            'event_espresso');
125
-        EE_Registry::$i18n_js_strings['ans_server_save_error'] = __('An unknown error has occurred on the server while saving the new state to the database.',
126
-            'event_espresso');
127
-    }
128
-
129
-
130
-
131
-    /**
132
-      * @return void
133
-     */
134
-    public static function wp_enqueue_scripts()
135
-    {
136
-        if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
137
-            wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js',
138
-                array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true);
139
-            wp_enqueue_script('add_new_state');
140
-        }
141
-    }
142
-
143
-
144
-
145
-    /**
146
-     * display_add_new_state_micro_form
147
-     *
148
-     * @param EE_Form_Section_Proper $question_group_reg_form
149
-     * @return string
150
-     * @throws EE_Error
151
-     */
152
-    //	public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){
153
-    public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
154
-    {
155
-        // only add the 'new_state_micro_form' when displaying reg forms,
156
-        // not during processing since we process the 'new_state_micro_form' in it's own AJAX request
157
-        $action = EE_Registry::instance()->REQ->get('action', '');
158
-        // is the "state" question in this form section?
159
-        $input = $question_group_reg_form->get_subsection('state');
160
-        if ($action === 'process_reg_step' || $action === 'update_reg_step') {
161
-            //ok then all we need to do is make sure the input's HTML name is consistent
162
-            //by forcing it to set it now, like it did while getting the form for display
163
-            if ($input instanceof EE_State_Select_Input) {
164
-                $input->html_name();
165
-            }
166
-            return $question_group_reg_form;
167
-        }
168
-        // we're only doing this for state select inputs
169
-        if ($input instanceof EE_State_Select_Input) {
170
-            // grab any set values from the request
171
-            $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
172
-            $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
173
-            $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
174
-            $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
175
-            $country_options = array();
176
-            $countries = EEM_Country::instance()->get_all_countries();
177
-            if (! empty($countries)) {
178
-                foreach ($countries as $country) {
179
-                    if ($country instanceof EE_Country) {
180
-                        $country_options[$country->ID()] = $country->name();
181
-                    }
182
-                }
183
-            }
184
-            $new_state_micro_form = new EE_Form_Section_Proper(
185
-                array(
186
-                    'name'            => 'new_state_micro_form',
187
-                    'html_id'         => 'new_state_micro_form',
188
-                    'layout_strategy' => new EE_No_Layout(),
189
-                    'subsections'     => array(
190
-                        // add hidden input to indicate that a new state is being added
191
-                        'add_new_state'               => new EE_Hidden_Input(
192
-                            array(
193
-                                'html_name' => str_replace('state', 'nsmf_add_new_state', $input->html_name()),
194
-                                'html_id'   => str_replace('state', 'nsmf_add_new_state', $input->html_id()),
195
-                                'default'   => 0,
196
-                            )
197
-                        ),
198
-                        // add link for displaying hidden container
199
-                        'click_here_link'             => new EE_Form_Section_HTML(
200
-                            apply_filters(
201
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
202
-                                EEH_HTML::link(
203
-                                    '',
204
-                                    __('click here to add a new state/province', 'event_espresso'),
205
-                                    '',
206
-                                    'display-' . $input->html_id(),
207
-                                    'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
208
-                                    '',
209
-                                    'data-target="' . $input->html_id() . '"'
210
-                                )
211
-                            )
212
-                        ),
213
-                        // add initial html for hidden container
214
-                        'add_new_state_micro_form'    => new EE_Form_Section_HTML(
215
-                            apply_filters(
216
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
217
-                                EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv',
218
-                                    'display: none;') .
219
-                                EEH_HTML::h6(__('If your State/Province does not appear in the list above, you can easily add it by doing the following:',
220
-                                    'event_espresso')) .
221
-                                EEH_HTML::ul() .
222
-                                EEH_HTML::li(__('first select the Country that your State/Province belongs to',
223
-                                    'event_espresso')) .
224
-                                EEH_HTML::li(__('enter the name of your State/Province', 'event_espresso')) .
225
-                                EEH_HTML::li(__('enter a two to six letter abbreviation for the name of your State/Province',
226
-                                    'event_espresso')) .
227
-                                EEH_HTML::li(__('click the ADD button', 'event_espresso')) .
228
-                                EEH_HTML::ulx()
229
-                            )
230
-                        ),
231
-                        // NEW STATE COUNTRY
232
-                        'new_state_country'           => new EE_Country_Select_Input(
233
-                            $country_options,
234
-                            array(
235
-                                'html_name'       => $country_name,
236
-                                'html_id'         => str_replace('state', 'nsmf_new_state_country', $input->html_id()),
237
-                                'html_class'      => $input->html_class() . ' new-state-country',
238
-                                'html_label_text' => __('New State/Province Country', 'event_espresso'),
239
-                                'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
240
-                                'required'        => false,
241
-                            )
242
-                        ),
243
-                        // NEW STATE NAME
244
-                        'new_state_name'              => new EE_Text_Input(
245
-                            array(
246
-                                'html_name'       => $state_name,
247
-                                'html_id'         => str_replace('state', 'nsmf_new_state_name', $input->html_id()),
248
-                                'html_class'      => $input->html_class() . ' new-state-state',
249
-                                'html_label_text' => __('New State/Province Name', 'event_espresso'),
250
-                                'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
251
-                                'required'        => false,
252
-                            )
253
-                        ),
254
-                        'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
255
-                        // NEW STATE NAME
256
-                        'new_state_abbrv'             => new EE_Text_Input(
257
-                            array(
258
-                                'html_name'             => $abbrv_name,
259
-                                'html_id'               => str_replace('state', 'nsmf_new_state_abbrv',
260
-                                    $input->html_id()),
261
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
262
-                                'html_label_text'       => __('New State/Province Abbreviation', 'event_espresso'),
263
-                                'html_other_attributes' => 'size="24"',
264
-                                'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
265
-                                'required'              => false,
266
-                            )
267
-                        ),
268
-                        // "submit" button
269
-                        'add_new_state_submit_button' => new EE_Form_Section_HTML(
270
-                            apply_filters(
271
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
272
-                                EEH_HTML::nbsp(3) .
273
-                                EEH_HTML::link(
274
-                                    '',
275
-                                    __('ADD', 'event_espresso'),
276
-                                    '',
277
-                                    'submit-' . $new_state_submit_id,
278
-                                    'ee-form-add-new-state-submit button button-secondary',
279
-                                    '',
280
-                                    'data-target="' . $new_state_submit_id . '"'
281
-                                )
282
-                            )
283
-                        ),
284
-                        // extra info
285
-                        'add_new_state_extra'         => new EE_Form_Section_HTML(
286
-                            apply_filters(
287
-                                'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
288
-                                EEH_HTML::br(2)
289
-                                .
290
-                                EEH_HTML::div('', '', 'small-text')
291
-                                .
292
-                                EEH_HTML::strong(__('Don\'t know your State/Province Abbreviation?', 'event_espresso'))
293
-                                .
294
-                                EEH_HTML::br()
295
-                                .
296
-                                sprintf(
297
-                                    __('You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
298
-                                        'event_espresso'),
299
-                                    EEH_HTML::link('http://en.wikipedia.org/wiki/ISO_3166-2',
300
-                                        'http://en.wikipedia.org/wiki/ISO_3166-2', '', '',
301
-                                        'ee-form-add-new-state-wiki-lnk')
302
-                                )
303
-                                .
304
-                                EEH_HTML::divx()
305
-                                .
306
-                                EEH_HTML::br()
307
-                                .
308
-                                EEH_HTML::link('', __('cancel new state/province', 'event_espresso'), '',
309
-                                    'hide-' . $input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '',
310
-                                    'data-target="' . $input->html_id() . '"')
311
-                                .
312
-                                EEH_HTML::divx()
313
-                                .
314
-                                EEH_HTML::br()
315
-                            )
316
-                        ),
317
-                    ),
318
-                )
319
-            );
320
-            $question_group_reg_form->add_subsections(array('new_state_micro_form' => $new_state_micro_form), 'state',
321
-                false);
322
-        }
323
-        return $question_group_reg_form;
324
-    }
325
-
326
-
327
-
328
-    /**
329
-     * set_new_state_input_width
330
-     *
331
-     * @return int|string
332
-     * @throws EE_Error
333
-     */
334
-    public static function add_new_state()
335
-    {
336
-        $REQ = EE_Registry::instance()->load_core('Request_Handler');
337
-        if ( absint($REQ->get('nsmf_add_new_state')) === 1 ) {
338
-            EE_Registry::instance()->load_model('State');
339
-            // grab country ISO code, new state name, and new state abbreviation
340
-            $state_country = $REQ->is_set('nsmf_new_state_country')
341
-                ? sanitize_text_field($REQ->get('nsmf_new_state_country'))
342
-                : false;
343
-            $state_name = $REQ->is_set('nsmf_new_state_name')
344
-                ? sanitize_text_field($REQ->get('nsmf_new_state_name'))
345
-                : false;
346
-            $state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
347
-                ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
348
-                : false;
349
-            if ($state_country && $state_name && $state_abbr) {
350
-                $new_state = EED_Add_New_State::save_new_state_to_db(array(
351
-                    'CNT_ISO'    => strtoupper($state_country),
352
-                    'STA_abbrev' => strtoupper($state_abbr),
353
-                    'STA_name'   => ucwords($state_name),
354
-                    'STA_active' => false,
355
-                ));
356
-                if ($new_state instanceof EE_State) {
357
-                    // clean house
358
-                    EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
359
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
360
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
361
-                    EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
362
-                    // get any existing new states
363
-                    $new_states = EE_Registry::instance()->SSN->get_session_data(
364
-                        'nsmf_new_states'
365
-                    );
366
-                    $new_states[$new_state->ID()] = $new_state;
367
-                    EE_Registry::instance()->SSN->set_session_data(
368
-                        array('nsmf_new_states' => $new_states)
369
-                    );
370
-                    if (EE_Registry::instance()->REQ->ajax) {
371
-                        echo wp_json_encode(array(
372
-                            'success'      => true,
373
-                            'id'           => $new_state->ID(),
374
-                            'name'         => $new_state->name(),
375
-                            'abbrev'       => $new_state->abbrev(),
376
-                            'country_iso'  => $new_state->country_iso(),
377
-                            'country_name' => $new_state->country()->name(),
378
-                        ));
379
-                        exit();
380
-                    }
381
-                    return $new_state->ID();
382
-                }
383
-            } else {
384
-                $error = __('A new State/Province could not be added because invalid or missing data was received.',
385
-                    'event_espresso');
386
-                if (EE_Registry::instance()->REQ->ajax) {
387
-                    echo wp_json_encode(array('error' => $error));
388
-                    exit();
389
-                }
390
-                EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
391
-            }
392
-        }
393
-        return false;
394
-    }
395
-
396
-
397
-
398
-    /**
399
-     * recursively drills down through request params to remove any that were added by this module
400
-     *
401
-     * @param array $request_params
402
-     * @return array
403
-     */
404
-    public static function filter_checkout_request_params($request_params)
405
-    {
406
-        foreach ($request_params as $form_section) {
407
-            if (is_array($form_section)) {
408
-                EED_Add_New_State::unset_new_state_request_params($form_section);
409
-                EED_Add_New_State::filter_checkout_request_params($form_section);
410
-            }
411
-        }
412
-        return $request_params;
413
-    }
414
-
415
-
416
-
417
-    /**
418
-     * @param array $request_params
419
-     * @return array
420
-     */
421
-    public static function unset_new_state_request_params($request_params)
422
-    {
423
-        unset(
424
-            $request_params['new_state_micro_form'],
425
-            $request_params['new_state_micro_add_new_state'],
426
-            $request_params['new_state_micro_new_state_country'],
427
-            $request_params['new_state_micro_new_state_name'],
428
-            $request_params['new_state_micro_new_state_abbrv']
429
-        );
430
-        return $request_params;
431
-    }
432
-
433
-
434
-
435
-    /**
436
-     * @param array $props_n_values
437
-     * @return bool
438
-     * @throws EE_Error
439
-     */
440
-    public static function save_new_state_to_db($props_n_values = array())
441
-    {
442
-        $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
443
-        if (! empty($existing_state)) {
444
-            return array_pop($existing_state);
445
-        }
446
-        $new_state = EE_State::new_instance($props_n_values);
447
-        if ($new_state instanceof EE_State) {
448
-            // if not non-ajax admin
449
-            $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev();
450
-            $new_state_notice = sprintf(
451
-                __('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.',
452
-                    'event_espresso'),
453
-                '<b>' . $new_state->name() . '</b>',
454
-                '<b>' . $new_state->abbrev() . '</b>',
455
-                '<b>' . $new_state->country()->name() . '</b>',
456
-                '<a href="' . add_query_arg(array(
457
-                    'page'    => 'espresso_general_settings',
458
-                    'action'  => 'country_settings',
459
-                    'country' => $new_state->country_iso(),
460
-                ), admin_url('admin.php')) . '">' . __('Event Espresso - General Settings > Countries Tab',
461
-                    'event_espresso') . '</a>',
462
-                '<br />'
463
-            );
464
-            EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice);
465
-            $new_state->save();
466
-            EEM_State::instance()->reset_cached_states();
467
-            return $new_state;
468
-        }
469
-        return false;
470
-    }
471
-
472
-
473
-
474
-    /**
475
-     * @param string $CNT_ISO
476
-     * @param string $STA_ID
477
-     * @param array  $cols_n_values
478
-     * @return void
479
-     */
480
-    public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
481
-    {
482
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false;
483
-        if (! $CNT_ISO) {
484
-            EE_Error::add_error(__('An invalid or missing Country ISO Code was received.', 'event_espresso'), __FILE__,
485
-                __FUNCTION__, __LINE__);
486
-        }
487
-        $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
488
-            : false;
489
-        if (! $STA_abbrev && ! empty($STA_ID)) {
490
-            $state = EEM_State::instance()->get_one_by_ID($STA_ID);
491
-            if ($state instanceof EE_State) {
492
-                $STA_abbrev = $state->abbrev();
493
-            }
494
-        }
495
-        if (! $STA_abbrev) {
496
-            EE_Error::add_error(__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
497
-                __FILE__, __FUNCTION__, __LINE__);
498
-        }
499
-        EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true);
500
-    }
501
-
502
-
503
-
504
-    /**
505
-     * @param EE_State[]                            $state_options
506
-     * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
507
-     * @param EE_Registration                       $registration
508
-     * @param EE_Question                           $question
509
-     * @param                                        $answer
510
-     * @return array
511
-     */
512
-    public static function inject_new_reg_state_into_options(
513
-        $state_options = array(),
514
-        EE_SPCO_Reg_Step_Attendee_Information $reg_step,
515
-        EE_Registration $registration,
516
-        EE_Question $question,
517
-        $answer
518
-    ) {
519
-        if ($answer instanceof EE_Answer && $question instanceof EE_Question
520
-            && $question->type()
521
-               === EEM_Question::QST_type_state
522
-        ) {
523
-            $STA_ID = $answer->value();
524
-            if (! empty($STA_ID)) {
525
-                $state = EEM_State::instance()->get_one_by_ID($STA_ID);
526
-                if ($state instanceof EE_State) {
527
-                    $country = $state->country();
528
-                    if ($country instanceof EE_Country) {
529
-                        if (! isset($state_options[$country->name()])) {
530
-                            $state_options[$country->name()] = array();
531
-                        }
532
-                        if (! isset($state_options[$country->name()][$STA_ID])) {
533
-                            $state_options[$country->name()][$STA_ID] = $state->name();
534
-                        }
535
-                    }
536
-                }
537
-            }
538
-        }
539
-        return $state_options;
540
-    }
541
-
542
-
543
-
544
-    /**
545
-     * @param EE_Country[]                          $country_options
546
-     * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
547
-     * @param EE_Registration                       $registration
548
-     * @param EE_Question                           $question
549
-     * @param                                        $answer
550
-     * @return array
551
-     */
552
-    public static function inject_new_reg_country_into_options(
553
-        $country_options = array(),
554
-        EE_SPCO_Reg_Step_Attendee_Information $reg_step,
555
-        EE_Registration $registration,
556
-        EE_Question $question,
557
-        $answer
558
-    ) {
559
-        if ($answer instanceof EE_Answer && $question instanceof EE_Question
560
-            && $question->type()
561
-               === EEM_Question::QST_type_country
562
-        ) {
563
-            $CNT_ISO = $answer->value();
564
-            if (! empty($CNT_ISO)) {
565
-                $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
566
-                if ($country instanceof EE_Country) {
567
-                    if (! isset($country_options[$CNT_ISO])) {
568
-                        $country_options[$CNT_ISO] = $country->name();
569
-                    }
570
-                }
571
-            }
572
-        }
573
-        return $country_options;
574
-    }
575
-
576
-
577
-
578
-    /**
579
-     * @param EE_State[] $state_options
580
-     * @return array
581
-     * @throws EE_Error
582
-     */
583
-    public static function state_options($state_options = array())
584
-    {
585
-        $new_states = EED_Add_New_State::_get_new_states();
586
-        foreach ($new_states as $new_state) {
587
-            if (
588
-                $new_state instanceof EE_State
589
-                && $new_state->country() instanceof EE_Country
590
-            ) {
591
-                $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name();
592
-            }
593
-        }
594
-        return $state_options;
595
-    }
596
-
597
-
598
-
599
-    /**
600
-     * @return array
601
-     */
602
-    protected static function _get_new_states()
603
-    {
604
-        $new_states = array();
605
-        if (EE_Registry::instance()->SSN instanceof EE_Session) {
606
-            $new_states = EE_Registry::instance()->SSN->get_session_data(
607
-                'nsmf_new_states'
608
-            );
609
-        }
610
-        return is_array($new_states) ? $new_states : array();
611
-    }
612
-
613
-
614
-
615
-    /**
616
-     * @param EE_Country[] $country_options
617
-     * @return array
618
-     * @throws EE_Error
619
-     */
620
-    public static function country_options($country_options = array())
621
-    {
622
-        $new_states = EED_Add_New_State::_get_new_states();
623
-        foreach ($new_states as $new_state) {
624
-            if (
625
-                $new_state instanceof EE_State
626
-                && $new_state->country() instanceof EE_Country
627
-            ) {
628
-                $country_options[$new_state->country()->ID()] = $new_state->country()->name();
629
-            }
630
-        }
631
-        return $country_options;
632
-    }
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('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
98
+	}
99
+
100
+
101
+
102
+	/**
103
+	 * @param WP $WP
104
+	 * @return void
105
+	 */
106
+	public function run($WP)
107
+	{
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * @return void
114
+	 */
115
+	public static function translate_js_strings()
116
+	{
117
+		EE_Registry::$i18n_js_strings['ans_no_country'] = __('In order to proceed, you need to select the Country that your State/Province belongs to.',
118
+			'event_espresso');
119
+		EE_Registry::$i18n_js_strings['ans_no_name'] = __('In order to proceed, you need to enter the name of your State/Province.',
120
+			'event_espresso');
121
+		EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = __('In order to proceed, you need to enter an abbreviation for the name of your State/Province.',
122
+			'event_espresso');
123
+		EE_Registry::$i18n_js_strings['ans_save_success'] = __('The new state was successfully saved to the database.',
124
+			'event_espresso');
125
+		EE_Registry::$i18n_js_strings['ans_server_save_error'] = __('An unknown error has occurred on the server while saving the new state to the database.',
126
+			'event_espresso');
127
+	}
128
+
129
+
130
+
131
+	/**
132
+	 * @return void
133
+	 */
134
+	public static function wp_enqueue_scripts()
135
+	{
136
+		if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
137
+			wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js',
138
+				array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true);
139
+			wp_enqueue_script('add_new_state');
140
+		}
141
+	}
142
+
143
+
144
+
145
+	/**
146
+	 * display_add_new_state_micro_form
147
+	 *
148
+	 * @param EE_Form_Section_Proper $question_group_reg_form
149
+	 * @return string
150
+	 * @throws EE_Error
151
+	 */
152
+	//	public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){
153
+	public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
154
+	{
155
+		// only add the 'new_state_micro_form' when displaying reg forms,
156
+		// not during processing since we process the 'new_state_micro_form' in it's own AJAX request
157
+		$action = EE_Registry::instance()->REQ->get('action', '');
158
+		// is the "state" question in this form section?
159
+		$input = $question_group_reg_form->get_subsection('state');
160
+		if ($action === 'process_reg_step' || $action === 'update_reg_step') {
161
+			//ok then all we need to do is make sure the input's HTML name is consistent
162
+			//by forcing it to set it now, like it did while getting the form for display
163
+			if ($input instanceof EE_State_Select_Input) {
164
+				$input->html_name();
165
+			}
166
+			return $question_group_reg_form;
167
+		}
168
+		// we're only doing this for state select inputs
169
+		if ($input instanceof EE_State_Select_Input) {
170
+			// grab any set values from the request
171
+			$country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
172
+			$state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
173
+			$abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
174
+			$new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
175
+			$country_options = array();
176
+			$countries = EEM_Country::instance()->get_all_countries();
177
+			if (! empty($countries)) {
178
+				foreach ($countries as $country) {
179
+					if ($country instanceof EE_Country) {
180
+						$country_options[$country->ID()] = $country->name();
181
+					}
182
+				}
183
+			}
184
+			$new_state_micro_form = new EE_Form_Section_Proper(
185
+				array(
186
+					'name'            => 'new_state_micro_form',
187
+					'html_id'         => 'new_state_micro_form',
188
+					'layout_strategy' => new EE_No_Layout(),
189
+					'subsections'     => array(
190
+						// add hidden input to indicate that a new state is being added
191
+						'add_new_state'               => new EE_Hidden_Input(
192
+							array(
193
+								'html_name' => str_replace('state', 'nsmf_add_new_state', $input->html_name()),
194
+								'html_id'   => str_replace('state', 'nsmf_add_new_state', $input->html_id()),
195
+								'default'   => 0,
196
+							)
197
+						),
198
+						// add link for displaying hidden container
199
+						'click_here_link'             => new EE_Form_Section_HTML(
200
+							apply_filters(
201
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link',
202
+								EEH_HTML::link(
203
+									'',
204
+									__('click here to add a new state/province', 'event_espresso'),
205
+									'',
206
+									'display-' . $input->html_id(),
207
+									'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
208
+									'',
209
+									'data-target="' . $input->html_id() . '"'
210
+								)
211
+							)
212
+						),
213
+						// add initial html for hidden container
214
+						'add_new_state_micro_form'    => new EE_Form_Section_HTML(
215
+							apply_filters(
216
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
217
+								EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv',
218
+									'display: none;') .
219
+								EEH_HTML::h6(__('If your State/Province does not appear in the list above, you can easily add it by doing the following:',
220
+									'event_espresso')) .
221
+								EEH_HTML::ul() .
222
+								EEH_HTML::li(__('first select the Country that your State/Province belongs to',
223
+									'event_espresso')) .
224
+								EEH_HTML::li(__('enter the name of your State/Province', 'event_espresso')) .
225
+								EEH_HTML::li(__('enter a two to six letter abbreviation for the name of your State/Province',
226
+									'event_espresso')) .
227
+								EEH_HTML::li(__('click the ADD button', 'event_espresso')) .
228
+								EEH_HTML::ulx()
229
+							)
230
+						),
231
+						// NEW STATE COUNTRY
232
+						'new_state_country'           => new EE_Country_Select_Input(
233
+							$country_options,
234
+							array(
235
+								'html_name'       => $country_name,
236
+								'html_id'         => str_replace('state', 'nsmf_new_state_country', $input->html_id()),
237
+								'html_class'      => $input->html_class() . ' new-state-country',
238
+								'html_label_text' => __('New State/Province Country', 'event_espresso'),
239
+								'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
240
+								'required'        => false,
241
+							)
242
+						),
243
+						// NEW STATE NAME
244
+						'new_state_name'              => new EE_Text_Input(
245
+							array(
246
+								'html_name'       => $state_name,
247
+								'html_id'         => str_replace('state', 'nsmf_new_state_name', $input->html_id()),
248
+								'html_class'      => $input->html_class() . ' new-state-state',
249
+								'html_label_text' => __('New State/Province Name', 'event_espresso'),
250
+								'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
251
+								'required'        => false,
252
+							)
253
+						),
254
+						'spacer'                      => new EE_Form_Section_HTML(EEH_HTML::br()),
255
+						// NEW STATE NAME
256
+						'new_state_abbrv'             => new EE_Text_Input(
257
+							array(
258
+								'html_name'             => $abbrv_name,
259
+								'html_id'               => str_replace('state', 'nsmf_new_state_abbrv',
260
+									$input->html_id()),
261
+								'html_class'            => $input->html_class() . ' new-state-abbrv',
262
+								'html_label_text'       => __('New State/Province Abbreviation', 'event_espresso'),
263
+								'html_other_attributes' => 'size="24"',
264
+								'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
265
+								'required'              => false,
266
+							)
267
+						),
268
+						// "submit" button
269
+						'add_new_state_submit_button' => new EE_Form_Section_HTML(
270
+							apply_filters(
271
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
272
+								EEH_HTML::nbsp(3) .
273
+								EEH_HTML::link(
274
+									'',
275
+									__('ADD', 'event_espresso'),
276
+									'',
277
+									'submit-' . $new_state_submit_id,
278
+									'ee-form-add-new-state-submit button button-secondary',
279
+									'',
280
+									'data-target="' . $new_state_submit_id . '"'
281
+								)
282
+							)
283
+						),
284
+						// extra info
285
+						'add_new_state_extra'         => new EE_Form_Section_HTML(
286
+							apply_filters(
287
+								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
288
+								EEH_HTML::br(2)
289
+								.
290
+								EEH_HTML::div('', '', 'small-text')
291
+								.
292
+								EEH_HTML::strong(__('Don\'t know your State/Province Abbreviation?', 'event_espresso'))
293
+								.
294
+								EEH_HTML::br()
295
+								.
296
+								sprintf(
297
+									__('You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).',
298
+										'event_espresso'),
299
+									EEH_HTML::link('http://en.wikipedia.org/wiki/ISO_3166-2',
300
+										'http://en.wikipedia.org/wiki/ISO_3166-2', '', '',
301
+										'ee-form-add-new-state-wiki-lnk')
302
+								)
303
+								.
304
+								EEH_HTML::divx()
305
+								.
306
+								EEH_HTML::br()
307
+								.
308
+								EEH_HTML::link('', __('cancel new state/province', 'event_espresso'), '',
309
+									'hide-' . $input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '',
310
+									'data-target="' . $input->html_id() . '"')
311
+								.
312
+								EEH_HTML::divx()
313
+								.
314
+								EEH_HTML::br()
315
+							)
316
+						),
317
+					),
318
+				)
319
+			);
320
+			$question_group_reg_form->add_subsections(array('new_state_micro_form' => $new_state_micro_form), 'state',
321
+				false);
322
+		}
323
+		return $question_group_reg_form;
324
+	}
325
+
326
+
327
+
328
+	/**
329
+	 * set_new_state_input_width
330
+	 *
331
+	 * @return int|string
332
+	 * @throws EE_Error
333
+	 */
334
+	public static function add_new_state()
335
+	{
336
+		$REQ = EE_Registry::instance()->load_core('Request_Handler');
337
+		if ( absint($REQ->get('nsmf_add_new_state')) === 1 ) {
338
+			EE_Registry::instance()->load_model('State');
339
+			// grab country ISO code, new state name, and new state abbreviation
340
+			$state_country = $REQ->is_set('nsmf_new_state_country')
341
+				? sanitize_text_field($REQ->get('nsmf_new_state_country'))
342
+				: false;
343
+			$state_name = $REQ->is_set('nsmf_new_state_name')
344
+				? sanitize_text_field($REQ->get('nsmf_new_state_name'))
345
+				: false;
346
+			$state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
347
+				? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
348
+				: false;
349
+			if ($state_country && $state_name && $state_abbr) {
350
+				$new_state = EED_Add_New_State::save_new_state_to_db(array(
351
+					'CNT_ISO'    => strtoupper($state_country),
352
+					'STA_abbrev' => strtoupper($state_abbr),
353
+					'STA_name'   => ucwords($state_name),
354
+					'STA_active' => false,
355
+				));
356
+				if ($new_state instanceof EE_State) {
357
+					// clean house
358
+					EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
359
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
360
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
361
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
362
+					// get any existing new states
363
+					$new_states = EE_Registry::instance()->SSN->get_session_data(
364
+						'nsmf_new_states'
365
+					);
366
+					$new_states[$new_state->ID()] = $new_state;
367
+					EE_Registry::instance()->SSN->set_session_data(
368
+						array('nsmf_new_states' => $new_states)
369
+					);
370
+					if (EE_Registry::instance()->REQ->ajax) {
371
+						echo wp_json_encode(array(
372
+							'success'      => true,
373
+							'id'           => $new_state->ID(),
374
+							'name'         => $new_state->name(),
375
+							'abbrev'       => $new_state->abbrev(),
376
+							'country_iso'  => $new_state->country_iso(),
377
+							'country_name' => $new_state->country()->name(),
378
+						));
379
+						exit();
380
+					}
381
+					return $new_state->ID();
382
+				}
383
+			} else {
384
+				$error = __('A new State/Province could not be added because invalid or missing data was received.',
385
+					'event_espresso');
386
+				if (EE_Registry::instance()->REQ->ajax) {
387
+					echo wp_json_encode(array('error' => $error));
388
+					exit();
389
+				}
390
+				EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
391
+			}
392
+		}
393
+		return false;
394
+	}
395
+
396
+
397
+
398
+	/**
399
+	 * recursively drills down through request params to remove any that were added by this module
400
+	 *
401
+	 * @param array $request_params
402
+	 * @return array
403
+	 */
404
+	public static function filter_checkout_request_params($request_params)
405
+	{
406
+		foreach ($request_params as $form_section) {
407
+			if (is_array($form_section)) {
408
+				EED_Add_New_State::unset_new_state_request_params($form_section);
409
+				EED_Add_New_State::filter_checkout_request_params($form_section);
410
+			}
411
+		}
412
+		return $request_params;
413
+	}
414
+
415
+
416
+
417
+	/**
418
+	 * @param array $request_params
419
+	 * @return array
420
+	 */
421
+	public static function unset_new_state_request_params($request_params)
422
+	{
423
+		unset(
424
+			$request_params['new_state_micro_form'],
425
+			$request_params['new_state_micro_add_new_state'],
426
+			$request_params['new_state_micro_new_state_country'],
427
+			$request_params['new_state_micro_new_state_name'],
428
+			$request_params['new_state_micro_new_state_abbrv']
429
+		);
430
+		return $request_params;
431
+	}
432
+
433
+
434
+
435
+	/**
436
+	 * @param array $props_n_values
437
+	 * @return bool
438
+	 * @throws EE_Error
439
+	 */
440
+	public static function save_new_state_to_db($props_n_values = array())
441
+	{
442
+		$existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
443
+		if (! empty($existing_state)) {
444
+			return array_pop($existing_state);
445
+		}
446
+		$new_state = EE_State::new_instance($props_n_values);
447
+		if ($new_state instanceof EE_State) {
448
+			// if not non-ajax admin
449
+			$new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev();
450
+			$new_state_notice = sprintf(
451
+				__('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.',
452
+					'event_espresso'),
453
+				'<b>' . $new_state->name() . '</b>',
454
+				'<b>' . $new_state->abbrev() . '</b>',
455
+				'<b>' . $new_state->country()->name() . '</b>',
456
+				'<a href="' . add_query_arg(array(
457
+					'page'    => 'espresso_general_settings',
458
+					'action'  => 'country_settings',
459
+					'country' => $new_state->country_iso(),
460
+				), admin_url('admin.php')) . '">' . __('Event Espresso - General Settings > Countries Tab',
461
+					'event_espresso') . '</a>',
462
+				'<br />'
463
+			);
464
+			EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice);
465
+			$new_state->save();
466
+			EEM_State::instance()->reset_cached_states();
467
+			return $new_state;
468
+		}
469
+		return false;
470
+	}
471
+
472
+
473
+
474
+	/**
475
+	 * @param string $CNT_ISO
476
+	 * @param string $STA_ID
477
+	 * @param array  $cols_n_values
478
+	 * @return void
479
+	 */
480
+	public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
481
+	{
482
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false;
483
+		if (! $CNT_ISO) {
484
+			EE_Error::add_error(__('An invalid or missing Country ISO Code was received.', 'event_espresso'), __FILE__,
485
+				__FUNCTION__, __LINE__);
486
+		}
487
+		$STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
488
+			: false;
489
+		if (! $STA_abbrev && ! empty($STA_ID)) {
490
+			$state = EEM_State::instance()->get_one_by_ID($STA_ID);
491
+			if ($state instanceof EE_State) {
492
+				$STA_abbrev = $state->abbrev();
493
+			}
494
+		}
495
+		if (! $STA_abbrev) {
496
+			EE_Error::add_error(__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
497
+				__FILE__, __FUNCTION__, __LINE__);
498
+		}
499
+		EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true);
500
+	}
501
+
502
+
503
+
504
+	/**
505
+	 * @param EE_State[]                            $state_options
506
+	 * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
507
+	 * @param EE_Registration                       $registration
508
+	 * @param EE_Question                           $question
509
+	 * @param                                        $answer
510
+	 * @return array
511
+	 */
512
+	public static function inject_new_reg_state_into_options(
513
+		$state_options = array(),
514
+		EE_SPCO_Reg_Step_Attendee_Information $reg_step,
515
+		EE_Registration $registration,
516
+		EE_Question $question,
517
+		$answer
518
+	) {
519
+		if ($answer instanceof EE_Answer && $question instanceof EE_Question
520
+			&& $question->type()
521
+			   === EEM_Question::QST_type_state
522
+		) {
523
+			$STA_ID = $answer->value();
524
+			if (! empty($STA_ID)) {
525
+				$state = EEM_State::instance()->get_one_by_ID($STA_ID);
526
+				if ($state instanceof EE_State) {
527
+					$country = $state->country();
528
+					if ($country instanceof EE_Country) {
529
+						if (! isset($state_options[$country->name()])) {
530
+							$state_options[$country->name()] = array();
531
+						}
532
+						if (! isset($state_options[$country->name()][$STA_ID])) {
533
+							$state_options[$country->name()][$STA_ID] = $state->name();
534
+						}
535
+					}
536
+				}
537
+			}
538
+		}
539
+		return $state_options;
540
+	}
541
+
542
+
543
+
544
+	/**
545
+	 * @param EE_Country[]                          $country_options
546
+	 * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
547
+	 * @param EE_Registration                       $registration
548
+	 * @param EE_Question                           $question
549
+	 * @param                                        $answer
550
+	 * @return array
551
+	 */
552
+	public static function inject_new_reg_country_into_options(
553
+		$country_options = array(),
554
+		EE_SPCO_Reg_Step_Attendee_Information $reg_step,
555
+		EE_Registration $registration,
556
+		EE_Question $question,
557
+		$answer
558
+	) {
559
+		if ($answer instanceof EE_Answer && $question instanceof EE_Question
560
+			&& $question->type()
561
+			   === EEM_Question::QST_type_country
562
+		) {
563
+			$CNT_ISO = $answer->value();
564
+			if (! empty($CNT_ISO)) {
565
+				$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
566
+				if ($country instanceof EE_Country) {
567
+					if (! isset($country_options[$CNT_ISO])) {
568
+						$country_options[$CNT_ISO] = $country->name();
569
+					}
570
+				}
571
+			}
572
+		}
573
+		return $country_options;
574
+	}
575
+
576
+
577
+
578
+	/**
579
+	 * @param EE_State[] $state_options
580
+	 * @return array
581
+	 * @throws EE_Error
582
+	 */
583
+	public static function state_options($state_options = array())
584
+	{
585
+		$new_states = EED_Add_New_State::_get_new_states();
586
+		foreach ($new_states as $new_state) {
587
+			if (
588
+				$new_state instanceof EE_State
589
+				&& $new_state->country() instanceof EE_Country
590
+			) {
591
+				$state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name();
592
+			}
593
+		}
594
+		return $state_options;
595
+	}
596
+
597
+
598
+
599
+	/**
600
+	 * @return array
601
+	 */
602
+	protected static function _get_new_states()
603
+	{
604
+		$new_states = array();
605
+		if (EE_Registry::instance()->SSN instanceof EE_Session) {
606
+			$new_states = EE_Registry::instance()->SSN->get_session_data(
607
+				'nsmf_new_states'
608
+			);
609
+		}
610
+		return is_array($new_states) ? $new_states : array();
611
+	}
612
+
613
+
614
+
615
+	/**
616
+	 * @param EE_Country[] $country_options
617
+	 * @return array
618
+	 * @throws EE_Error
619
+	 */
620
+	public static function country_options($country_options = array())
621
+	{
622
+		$new_states = EED_Add_New_State::_get_new_states();
623
+		foreach ($new_states as $new_state) {
624
+			if (
625
+				$new_state instanceof EE_State
626
+				&& $new_state->country() instanceof EE_Country
627
+			) {
628
+				$country_options[$new_state->country()->ID()] = $new_state->country()->name();
629
+			}
630
+		}
631
+		return $country_options;
632
+	}
633 633
 
634 634
 
635 635
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 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,8 +93,8 @@  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);
97
-        define('ANS_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
96
+        define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
97
+        define('ANS_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
98 98
     }
99 99
 
100 100
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     public static function wp_enqueue_scripts()
135 135
     {
136 136
         if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
137
-            wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js',
137
+            wp_register_script('add_new_state', ANS_ASSETS_URL.'add_new_state.js',
138 138
                 array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true);
139 139
             wp_enqueue_script('add_new_state');
140 140
         }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
175 175
             $country_options = array();
176 176
             $countries = EEM_Country::instance()->get_all_countries();
177
-            if (! empty($countries)) {
177
+            if ( ! empty($countries)) {
178 178
                 foreach ($countries as $country) {
179 179
                     if ($country instanceof EE_Country) {
180 180
                         $country_options[$country->ID()] = $country->name();
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
                                     '',
204 204
                                     __('click here to add a new state/province', 'event_espresso'),
205 205
                                     '',
206
-                                    'display-' . $input->html_id(),
206
+                                    'display-'.$input->html_id(),
207 207
                                     'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
208 208
                                     '',
209
-                                    'data-target="' . $input->html_id() . '"'
209
+                                    'data-target="'.$input->html_id().'"'
210 210
                                 )
211 211
                             )
212 212
                         ),
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
                         'add_new_state_micro_form'    => new EE_Form_Section_HTML(
215 215
                             apply_filters(
216 216
                                 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
217
-                                EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv',
218
-                                    'display: none;') .
217
+                                EEH_HTML::div('', $input->html_id().'-dv', 'ee-form-add-new-state-dv',
218
+                                    'display: none;').
219 219
                                 EEH_HTML::h6(__('If your State/Province does not appear in the list above, you can easily add it by doing the following:',
220
-                                    'event_espresso')) .
221
-                                EEH_HTML::ul() .
220
+                                    'event_espresso')).
221
+                                EEH_HTML::ul().
222 222
                                 EEH_HTML::li(__('first select the Country that your State/Province belongs to',
223
-                                    'event_espresso')) .
224
-                                EEH_HTML::li(__('enter the name of your State/Province', 'event_espresso')) .
223
+                                    'event_espresso')).
224
+                                EEH_HTML::li(__('enter the name of your State/Province', 'event_espresso')).
225 225
                                 EEH_HTML::li(__('enter a two to six letter abbreviation for the name of your State/Province',
226
-                                    'event_espresso')) .
227
-                                EEH_HTML::li(__('click the ADD button', 'event_espresso')) .
226
+                                    'event_espresso')).
227
+                                EEH_HTML::li(__('click the ADD button', 'event_espresso')).
228 228
                                 EEH_HTML::ulx()
229 229
                             )
230 230
                         ),
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
                             array(
235 235
                                 'html_name'       => $country_name,
236 236
                                 'html_id'         => str_replace('state', 'nsmf_new_state_country', $input->html_id()),
237
-                                'html_class'      => $input->html_class() . ' new-state-country',
237
+                                'html_class'      => $input->html_class().' new-state-country',
238 238
                                 'html_label_text' => __('New State/Province Country', 'event_espresso'),
239 239
                                 'default'         => EE_Registry::instance()->REQ->get($country_name, ''),
240 240
                                 'required'        => false,
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                             array(
246 246
                                 'html_name'       => $state_name,
247 247
                                 'html_id'         => str_replace('state', 'nsmf_new_state_name', $input->html_id()),
248
-                                'html_class'      => $input->html_class() . ' new-state-state',
248
+                                'html_class'      => $input->html_class().' new-state-state',
249 249
                                 'html_label_text' => __('New State/Province Name', 'event_espresso'),
250 250
                                 'default'         => EE_Registry::instance()->REQ->get($state_name, ''),
251 251
                                 'required'        => false,
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
                                 'html_name'             => $abbrv_name,
259 259
                                 'html_id'               => str_replace('state', 'nsmf_new_state_abbrv',
260 260
                                     $input->html_id()),
261
-                                'html_class'            => $input->html_class() . ' new-state-abbrv',
261
+                                'html_class'            => $input->html_class().' new-state-abbrv',
262 262
                                 'html_label_text'       => __('New State/Province Abbreviation', 'event_espresso'),
263 263
                                 'html_other_attributes' => 'size="24"',
264 264
                                 'default'               => EE_Registry::instance()->REQ->get($abbrv_name, ''),
@@ -269,15 +269,15 @@  discard block
 block discarded – undo
269 269
                         'add_new_state_submit_button' => new EE_Form_Section_HTML(
270 270
                             apply_filters(
271 271
                                 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
272
-                                EEH_HTML::nbsp(3) .
272
+                                EEH_HTML::nbsp(3).
273 273
                                 EEH_HTML::link(
274 274
                                     '',
275 275
                                     __('ADD', 'event_espresso'),
276 276
                                     '',
277
-                                    'submit-' . $new_state_submit_id,
277
+                                    'submit-'.$new_state_submit_id,
278 278
                                     'ee-form-add-new-state-submit button button-secondary',
279 279
                                     '',
280
-                                    'data-target="' . $new_state_submit_id . '"'
280
+                                    'data-target="'.$new_state_submit_id.'"'
281 281
                                 )
282 282
                             )
283 283
                         ),
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
                                 EEH_HTML::br()
307 307
                                 .
308 308
                                 EEH_HTML::link('', __('cancel new state/province', 'event_espresso'), '',
309
-                                    'hide-' . $input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '',
310
-                                    'data-target="' . $input->html_id() . '"')
309
+                                    'hide-'.$input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '',
310
+                                    'data-target="'.$input->html_id().'"')
311 311
                                 .
312 312
                                 EEH_HTML::divx()
313 313
                                 .
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
     public static function add_new_state()
335 335
     {
336 336
         $REQ = EE_Registry::instance()->load_core('Request_Handler');
337
-        if ( absint($REQ->get('nsmf_add_new_state')) === 1 ) {
337
+        if (absint($REQ->get('nsmf_add_new_state')) === 1) {
338 338
             EE_Registry::instance()->load_model('State');
339 339
             // grab country ISO code, new state name, and new state abbreviation
340 340
             $state_country = $REQ->is_set('nsmf_new_state_country')
@@ -440,25 +440,25 @@  discard block
 block discarded – undo
440 440
     public static function save_new_state_to_db($props_n_values = array())
441 441
     {
442 442
         $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
443
-        if (! empty($existing_state)) {
443
+        if ( ! empty($existing_state)) {
444 444
             return array_pop($existing_state);
445 445
         }
446 446
         $new_state = EE_State::new_instance($props_n_values);
447 447
         if ($new_state instanceof EE_State) {
448 448
             // if not non-ajax admin
449
-            $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev();
449
+            $new_state_key = 'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev();
450 450
             $new_state_notice = sprintf(
451 451
                 __('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.',
452 452
                     'event_espresso'),
453
-                '<b>' . $new_state->name() . '</b>',
454
-                '<b>' . $new_state->abbrev() . '</b>',
455
-                '<b>' . $new_state->country()->name() . '</b>',
456
-                '<a href="' . add_query_arg(array(
453
+                '<b>'.$new_state->name().'</b>',
454
+                '<b>'.$new_state->abbrev().'</b>',
455
+                '<b>'.$new_state->country()->name().'</b>',
456
+                '<a href="'.add_query_arg(array(
457 457
                     'page'    => 'espresso_general_settings',
458 458
                     'action'  => 'country_settings',
459 459
                     'country' => $new_state->country_iso(),
460
-                ), admin_url('admin.php')) . '">' . __('Event Espresso - General Settings > Countries Tab',
461
-                    'event_espresso') . '</a>',
460
+                ), admin_url('admin.php')).'">'.__('Event Espresso - General Settings > Countries Tab',
461
+                    'event_espresso').'</a>',
462 462
                 '<br />'
463 463
             );
464 464
             EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice);
@@ -480,23 +480,23 @@  discard block
 block discarded – undo
480 480
     public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array())
481 481
     {
482 482
         $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false;
483
-        if (! $CNT_ISO) {
483
+        if ( ! $CNT_ISO) {
484 484
             EE_Error::add_error(__('An invalid or missing Country ISO Code was received.', 'event_espresso'), __FILE__,
485 485
                 __FUNCTION__, __LINE__);
486 486
         }
487 487
         $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev']
488 488
             : false;
489
-        if (! $STA_abbrev && ! empty($STA_ID)) {
489
+        if ( ! $STA_abbrev && ! empty($STA_ID)) {
490 490
             $state = EEM_State::instance()->get_one_by_ID($STA_ID);
491 491
             if ($state instanceof EE_State) {
492 492
                 $STA_abbrev = $state->abbrev();
493 493
             }
494 494
         }
495
-        if (! $STA_abbrev) {
495
+        if ( ! $STA_abbrev) {
496 496
             EE_Error::add_error(__('An invalid or missing State Abbreviation was received.', 'event_espresso'),
497 497
                 __FILE__, __FUNCTION__, __LINE__);
498 498
         }
499
-        EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true);
499
+        EE_Error::dismiss_persistent_admin_notice($CNT_ISO.'-'.$STA_abbrev, true, true);
500 500
     }
501 501
 
502 502
 
@@ -521,15 +521,15 @@  discard block
 block discarded – undo
521 521
                === EEM_Question::QST_type_state
522 522
         ) {
523 523
             $STA_ID = $answer->value();
524
-            if (! empty($STA_ID)) {
524
+            if ( ! empty($STA_ID)) {
525 525
                 $state = EEM_State::instance()->get_one_by_ID($STA_ID);
526 526
                 if ($state instanceof EE_State) {
527 527
                     $country = $state->country();
528 528
                     if ($country instanceof EE_Country) {
529
-                        if (! isset($state_options[$country->name()])) {
529
+                        if ( ! isset($state_options[$country->name()])) {
530 530
                             $state_options[$country->name()] = array();
531 531
                         }
532
-                        if (! isset($state_options[$country->name()][$STA_ID])) {
532
+                        if ( ! isset($state_options[$country->name()][$STA_ID])) {
533 533
                             $state_options[$country->name()][$STA_ID] = $state->name();
534 534
                         }
535 535
                     }
@@ -561,10 +561,10 @@  discard block
 block discarded – undo
561 561
                === EEM_Question::QST_type_country
562 562
         ) {
563 563
             $CNT_ISO = $answer->value();
564
-            if (! empty($CNT_ISO)) {
564
+            if ( ! empty($CNT_ISO)) {
565 565
                 $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
566 566
                 if ($country instanceof EE_Country) {
567
-                    if (! isset($country_options[$CNT_ISO])) {
567
+                    if ( ! isset($country_options[$CNT_ISO])) {
568 568
                         $country_options[$CNT_ISO] = $country->name();
569 569
                     }
570 570
                 }
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.