Completed
Branch dependabot/composer/wp-graphql... (9d68cf)
by
unknown
15:17 queued 10:50
created
core/libraries/form_sections/inputs/EE_State_Select_Input.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     {
37 37
         if (isset($input_settings['value_field_name'])) {
38 38
             $this->valueFieldName = $input_settings['value_field_name'];
39
-            if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
39
+            if ( ! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
40 40
                 throw new InvalidArgumentException(
41 41
                     sprintf(
42 42
                         esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'),
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             $this
54 54
         );
55 55
         $input_settings['html_class'] = isset($input_settings['html_class'])
56
-            ? $input_settings['html_class'] . ' ee-state-select-js'
56
+            ? $input_settings['html_class'].' ee-state-select-js'
57 57
             : 'ee-state-select-js';
58 58
         parent::__construct($state_options, $input_settings);
59 59
     }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     public function get_state_answer_options($state_options = null)
84 84
     {
85 85
         // if passed something that is NOT an array
86
-        if (! is_array($state_options) || empty($state_options)) {
86
+        if ( ! is_array($state_options) || empty($state_options)) {
87 87
             // get possibly cached list of states
88 88
             $states = EEM_State::instance()->get_all_active_states();
89 89
         }
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
             $states = $state_options;
92 92
             $state_options = array();
93 93
         }
94
-        if (! empty($states)) {
94
+        if ( ! empty($states)) {
95 95
             // set the default
96 96
             $state_options[''][''] = '';
97 97
             foreach ($states as $state) {
98 98
                 if ($state instanceof EE_State) {
99
-                    $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name();
99
+                    $state_options[$state->country()->name()][$state->get($this->valueFieldName())] = $state->name();
100 100
                 }
101 101
             }
102 102
         }
Please login to merge, or discard this patch.
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -12,94 +12,94 @@
 block discarded – undo
12 12
  */
13 13
 class EE_State_Select_Input extends EE_Select_Input
14 14
 {
15
-    /**
16
-     * @var string the name of the EE_State field to use for option values in the HTML form input.
17
-     */
18
-    protected $valueFieldName;
15
+	/**
16
+	 * @var string the name of the EE_State field to use for option values in the HTML form input.
17
+	 */
18
+	protected $valueFieldName;
19 19
 
20
-    /**
21
-     * @param EE_State[]|array|null $state_options. If a flat array of string is provided,
22
-     * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for
23
-     * the keys (which will become the option values). If null or empty is passed, all active states will be used,
24
-     * and $input_settings['value_field_name'] will again be used.     *
25
-     * @param array $input_settings same as parent, but also {
26
-     *   @type string $value_field_name the name of the field to use
27
-     *   for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`.
28
-     * }
29
-     * @throws EE_Error
30
-     * @throws InvalidArgumentException
31
-     * @throws InvalidDataTypeException
32
-     * @throws InvalidInterfaceException
33
-     * @throws ReflectionException
34
-     */
35
-    public function __construct($state_options, $input_settings = array())
36
-    {
37
-        if (isset($input_settings['value_field_name'])) {
38
-            $this->valueFieldName = $input_settings['value_field_name'];
39
-            if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
40
-                throw new InvalidArgumentException(
41
-                    sprintf(
42
-                        esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'),
43
-                        $this->valueFieldName()
44
-                    )
45
-                );
46
-            }
47
-        } else {
48
-            $this->valueFieldName = 'STA_ID';
49
-        }
50
-        $state_options = apply_filters(
51
-            'FHEE__EE_State_Select_Input____construct__state_options',
52
-            $this->get_state_answer_options($state_options),
53
-            $this
54
-        );
55
-        $input_settings['html_class'] = isset($input_settings['html_class'])
56
-            ? $input_settings['html_class'] . ' ee-state-select-js'
57
-            : 'ee-state-select-js';
58
-        parent::__construct($state_options, $input_settings);
59
-    }
20
+	/**
21
+	 * @param EE_State[]|array|null $state_options. If a flat array of string is provided,
22
+	 * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for
23
+	 * the keys (which will become the option values). If null or empty is passed, all active states will be used,
24
+	 * and $input_settings['value_field_name'] will again be used.     *
25
+	 * @param array $input_settings same as parent, but also {
26
+	 *   @type string $value_field_name the name of the field to use
27
+	 *   for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`.
28
+	 * }
29
+	 * @throws EE_Error
30
+	 * @throws InvalidArgumentException
31
+	 * @throws InvalidDataTypeException
32
+	 * @throws InvalidInterfaceException
33
+	 * @throws ReflectionException
34
+	 */
35
+	public function __construct($state_options, $input_settings = array())
36
+	{
37
+		if (isset($input_settings['value_field_name'])) {
38
+			$this->valueFieldName = $input_settings['value_field_name'];
39
+			if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
40
+				throw new InvalidArgumentException(
41
+					sprintf(
42
+						esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'),
43
+						$this->valueFieldName()
44
+					)
45
+				);
46
+			}
47
+		} else {
48
+			$this->valueFieldName = 'STA_ID';
49
+		}
50
+		$state_options = apply_filters(
51
+			'FHEE__EE_State_Select_Input____construct__state_options',
52
+			$this->get_state_answer_options($state_options),
53
+			$this
54
+		);
55
+		$input_settings['html_class'] = isset($input_settings['html_class'])
56
+			? $input_settings['html_class'] . ' ee-state-select-js'
57
+			: 'ee-state-select-js';
58
+		parent::__construct($state_options, $input_settings);
59
+	}
60 60
 
61
-    /**
62
-     * Returns the name of the state field used for the HTML option values.
63
-     * @since 4.10.0.p
64
-     * @return string
65
-     */
66
-    public function valueFieldName()
67
-    {
68
-        return $this->valueFieldName;
69
-    }
61
+	/**
62
+	 * Returns the name of the state field used for the HTML option values.
63
+	 * @since 4.10.0.p
64
+	 * @return string
65
+	 */
66
+	public function valueFieldName()
67
+	{
68
+		return $this->valueFieldName;
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * get_state_answer_options
74
-     *
75
-     * @param array $state_options
76
-     * @return array
77
-     * @throws EE_Error
78
-     * @throws InvalidArgumentException
79
-     * @throws ReflectionException
80
-     * @throws InvalidDataTypeException
81
-     * @throws InvalidInterfaceException
82
-     */
83
-    public function get_state_answer_options($state_options = null)
84
-    {
85
-        // if passed something that is NOT an array
86
-        if (! is_array($state_options) || empty($state_options)) {
87
-            // get possibly cached list of states
88
-            $states = EEM_State::instance()->get_all_active_states();
89
-        }
90
-        if (is_array($state_options) && reset($state_options) instanceof EE_State) {
91
-            $states = $state_options;
92
-            $state_options = array();
93
-        }
94
-        if (! empty($states)) {
95
-            // set the default
96
-            $state_options[''][''] = '';
97
-            foreach ($states as $state) {
98
-                if ($state instanceof EE_State) {
99
-                    $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name();
100
-                }
101
-            }
102
-        }
103
-        return $state_options ?? [];
104
-    }
72
+	/**
73
+	 * get_state_answer_options
74
+	 *
75
+	 * @param array $state_options
76
+	 * @return array
77
+	 * @throws EE_Error
78
+	 * @throws InvalidArgumentException
79
+	 * @throws ReflectionException
80
+	 * @throws InvalidDataTypeException
81
+	 * @throws InvalidInterfaceException
82
+	 */
83
+	public function get_state_answer_options($state_options = null)
84
+	{
85
+		// if passed something that is NOT an array
86
+		if (! is_array($state_options) || empty($state_options)) {
87
+			// get possibly cached list of states
88
+			$states = EEM_State::instance()->get_all_active_states();
89
+		}
90
+		if (is_array($state_options) && reset($state_options) instanceof EE_State) {
91
+			$states = $state_options;
92
+			$state_options = array();
93
+		}
94
+		if (! empty($states)) {
95
+			// set the default
96
+			$state_options[''][''] = '';
97
+			foreach ($states as $state) {
98
+				if ($state instanceof EE_State) {
99
+					$state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name();
100
+				}
101
+			}
102
+		}
103
+		return $state_options ?? [];
104
+	}
105 105
 }
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page_Init.core.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@
 block discarded – undo
23 23
     public function __construct()
24 24
     {
25 25
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
-        if (! defined('REG_PG_SLUG')) {
26
+        if ( ! defined('REG_PG_SLUG')) {
27 27
             define('REG_PG_SLUG', 'espresso_registrations');
28 28
             define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
29
-            define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
30
-            define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
31
-            define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
32
-            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
33
-            define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
34
-            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
29
+            define('REG_ADMIN', EE_ADMIN_PAGES.'registrations/');
30
+            define('REG_ADMIN_URL', admin_url('admin.php?page='.REG_PG_SLUG));
31
+            define('REG_ASSETS_PATH', REG_ADMIN.'assets/');
32
+            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL.'registrations/assets/');
33
+            define('REG_TEMPLATE_PATH', REG_ADMIN.'templates/');
34
+            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registrations/templates/');
35 35
         }
36 36
 
37 37
         parent::__construct();
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -11,48 +11,48 @@
 block discarded – undo
11 11
  */
12 12
 class Registrations_Admin_Page_Init extends EE_Admin_Page_CPT_Init
13 13
 {
14
-    /**
15
-     *        constructor
16
-     *
17
-     * @Constructor
18
-     * @access public
19
-     * @return void
20
-     */
21
-    public function __construct()
22
-    {
23
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
24
-        if (! defined('REG_PG_SLUG')) {
25
-            define('REG_PG_SLUG', 'espresso_registrations');
26
-            define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
27
-            define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
28
-            define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
29
-            define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
30
-            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
31
-            define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
32
-            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
33
-        }
14
+	/**
15
+	 *        constructor
16
+	 *
17
+	 * @Constructor
18
+	 * @access public
19
+	 * @return void
20
+	 */
21
+	public function __construct()
22
+	{
23
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
24
+		if (! defined('REG_PG_SLUG')) {
25
+			define('REG_PG_SLUG', 'espresso_registrations');
26
+			define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
27
+			define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
28
+			define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
29
+			define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
30
+			define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
31
+			define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
32
+			define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
33
+		}
34 34
 
35
-        parent::__construct();
36
-    }
35
+		parent::__construct();
36
+	}
37 37
 
38 38
 
39
-    protected function _set_init_properties()
40
-    {
41
-        $this->label = esc_html__('Registrations Overview', 'event_espresso');
42
-    }
39
+	protected function _set_init_properties()
40
+	{
41
+		$this->label = esc_html__('Registrations Overview', 'event_espresso');
42
+	}
43 43
 
44 44
 
45
-    public function getMenuProperties(): array
46
-    {
47
-        return [
48
-            'menu_type'       => AdminMenuItem::TYPE_MENU_SUB_ITEM,
49
-            'menu_group'      => 'main',
50
-            'menu_order'      => 40,
51
-            'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
52
-            'parent_slug'     => 'espresso_events',
53
-            'menu_slug'       => REG_PG_SLUG,
54
-            'menu_label'      => esc_html__('Registrations', 'event_espresso'),
55
-            'capability'      => 'ee_read_registrations',
56
-        ];
57
-    }
45
+	public function getMenuProperties(): array
46
+	{
47
+		return [
48
+			'menu_type'       => AdminMenuItem::TYPE_MENU_SUB_ITEM,
49
+			'menu_group'      => 'main',
50
+			'menu_order'      => 40,
51
+			'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
52
+			'parent_slug'     => 'espresso_events',
53
+			'menu_slug'       => REG_PG_SLUG,
54
+			'menu_label'      => esc_html__('Registrations', 'event_espresso'),
55
+			'capability'      => 'ee_read_registrations',
56
+		];
57
+	}
58 58
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapCore.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         // load interfaces
200 200
         espresso_load_required(
201 201
             'EEH_Autoloader',
202
-            EE_CORE . 'helpers/EEH_Autoloader.helper.php'
202
+            EE_CORE.'helpers/EEH_Autoloader.helper.php'
203 203
         );
204 204
         EEH_Autoloader::instance();
205 205
     }
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
     protected function setAutoloadersForRequiredFiles()
214 214
     {
215 215
         // load interfaces
216
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
216
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces', true);
217 217
         // load helpers
218 218
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219 219
         // register legacy request stack classes just in case
220
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
220
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack/');
221 221
         // register legacy middleware classes just in case
222
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
222
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware/');
223 223
     }
224 224
 
225 225
 
Please login to merge, or discard this patch.
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -53,212 +53,212 @@
 block discarded – undo
53 53
  */
54 54
 class BootstrapCore
55 55
 {
56
-    private LoaderInterface       $loader;
56
+	private LoaderInterface       $loader;
57 57
 
58
-    protected RequestInterface    $request;
58
+	protected RequestInterface    $request;
59 59
 
60
-    protected ResponseInterface   $response;
60
+	protected ResponseInterface   $response;
61 61
 
62
-    protected RequestStackBuilder $request_stack_builder;
62
+	protected RequestStackBuilder $request_stack_builder;
63 63
 
64
-    protected RequestStack        $request_stack;
64
+	protected RequestStack        $request_stack;
65 65
 
66 66
 
67
-    /**
68
-     * BootstrapCore constructor.
69
-     */
70
-    public function __construct()
71
-    {
72
-        do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
73
-        // construct request stack and run middleware apps as soon as all WP plugins are loaded
74
-        add_action('plugins_loaded', [$this, 'initialize'], 0);
75
-    }
67
+	/**
68
+	 * BootstrapCore constructor.
69
+	 */
70
+	public function __construct()
71
+	{
72
+		do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
73
+		// construct request stack and run middleware apps as soon as all WP plugins are loaded
74
+		add_action('plugins_loaded', [$this, 'initialize'], 0);
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * @throws DomainException
80
-     * @throws EE_Error
81
-     * @throws Exception
82
-     * @throws InvalidArgumentException
83
-     * @throws InvalidClassException
84
-     * @throws InvalidDataTypeException
85
-     * @throws InvalidFilePathException
86
-     * @throws InvalidInterfaceException
87
-     * @throws InvalidRequestStackMiddlewareException
88
-     * @throws OutOfBoundsException
89
-     * @throws ReflectionException
90
-     * @throws Throwable
91
-     */
92
-    public function initialize()
93
-    {
94
-        $this->bootstrapDependencyInjectionContainer();
95
-        $this->bootstrapDomain();
96
-        $bootstrap_request = $this->bootstrapRequestResponseObjects();
97
-        add_action(
98
-            'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
99
-            [$bootstrap_request, 'setupLegacyRequest']
100
-        );
101
-        $this->runRequestStack();
102
-    }
78
+	/**
79
+	 * @throws DomainException
80
+	 * @throws EE_Error
81
+	 * @throws Exception
82
+	 * @throws InvalidArgumentException
83
+	 * @throws InvalidClassException
84
+	 * @throws InvalidDataTypeException
85
+	 * @throws InvalidFilePathException
86
+	 * @throws InvalidInterfaceException
87
+	 * @throws InvalidRequestStackMiddlewareException
88
+	 * @throws OutOfBoundsException
89
+	 * @throws ReflectionException
90
+	 * @throws Throwable
91
+	 */
92
+	public function initialize()
93
+	{
94
+		$this->bootstrapDependencyInjectionContainer();
95
+		$this->bootstrapDomain();
96
+		$bootstrap_request = $this->bootstrapRequestResponseObjects();
97
+		add_action(
98
+			'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
99
+			[$bootstrap_request, 'setupLegacyRequest']
100
+		);
101
+		$this->runRequestStack();
102
+	}
103 103
 
104 104
 
105
-    /**
106
-     * @throws ReflectionException
107
-     * @throws EE_Error
108
-     * @throws InvalidArgumentException
109
-     * @throws InvalidDataTypeException
110
-     * @throws InvalidInterfaceException
111
-     * @throws OutOfBoundsException
112
-     */
113
-    private function bootstrapDependencyInjectionContainer()
114
-    {
115
-        $bootstrap_di = new BootstrapDependencyInjectionContainer();
116
-        $bootstrap_di->buildLegacyDependencyInjectionContainer();
117
-        $bootstrap_di->buildLoader();
118
-        $registry       = $bootstrap_di->getRegistry();
119
-        $dependency_map = $bootstrap_di->getDependencyMap();
120
-        $dependency_map->initialize();
121
-        $registry->initialize();
122
-        $this->loader = $bootstrap_di->getLoader();
123
-    }
105
+	/**
106
+	 * @throws ReflectionException
107
+	 * @throws EE_Error
108
+	 * @throws InvalidArgumentException
109
+	 * @throws InvalidDataTypeException
110
+	 * @throws InvalidInterfaceException
111
+	 * @throws OutOfBoundsException
112
+	 */
113
+	private function bootstrapDependencyInjectionContainer()
114
+	{
115
+		$bootstrap_di = new BootstrapDependencyInjectionContainer();
116
+		$bootstrap_di->buildLegacyDependencyInjectionContainer();
117
+		$bootstrap_di->buildLoader();
118
+		$registry       = $bootstrap_di->getRegistry();
119
+		$dependency_map = $bootstrap_di->getDependencyMap();
120
+		$dependency_map->initialize();
121
+		$registry->initialize();
122
+		$this->loader = $bootstrap_di->getLoader();
123
+	}
124 124
 
125 125
 
126
-    /**
127
-     * configures the Domain object for core
128
-     *
129
-     * @return void
130
-     * @throws DomainException
131
-     * @throws InvalidArgumentException
132
-     * @throws InvalidDataTypeException
133
-     * @throws InvalidClassException
134
-     * @throws InvalidFilePathException
135
-     * @throws InvalidInterfaceException
136
-     */
137
-    private function bootstrapDomain()
138
-    {
139
-        DomainFactory::getEventEspressoCoreDomain();
140
-    }
126
+	/**
127
+	 * configures the Domain object for core
128
+	 *
129
+	 * @return void
130
+	 * @throws DomainException
131
+	 * @throws InvalidArgumentException
132
+	 * @throws InvalidDataTypeException
133
+	 * @throws InvalidClassException
134
+	 * @throws InvalidFilePathException
135
+	 * @throws InvalidInterfaceException
136
+	 */
137
+	private function bootstrapDomain()
138
+	{
139
+		DomainFactory::getEventEspressoCoreDomain();
140
+	}
141 141
 
142 142
 
143
-    /**
144
-     * sets up the request and response objects
145
-     *
146
-     * @return BootstrapRequestResponseObjects
147
-     * @throws InvalidArgumentException
148
-     */
149
-    private function bootstrapRequestResponseObjects(): BootstrapRequestResponseObjects
150
-    {
151
-        /** @var BootstrapRequestResponseObjects $bootstrap_request */
152
-        $bootstrap_request = $this->loader->getShared(
153
-            'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
154
-            [$this->loader]
155
-        );
156
-        $bootstrap_request->buildRequestResponse();
157
-        $bootstrap_request->shareRequestResponse();
158
-        $this->request  = $this->loader->getShared('EventEspresso\core\services\request\Request');
159
-        $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
160
-        return $bootstrap_request;
161
-    }
143
+	/**
144
+	 * sets up the request and response objects
145
+	 *
146
+	 * @return BootstrapRequestResponseObjects
147
+	 * @throws InvalidArgumentException
148
+	 */
149
+	private function bootstrapRequestResponseObjects(): BootstrapRequestResponseObjects
150
+	{
151
+		/** @var BootstrapRequestResponseObjects $bootstrap_request */
152
+		$bootstrap_request = $this->loader->getShared(
153
+			'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
154
+			[$this->loader]
155
+		);
156
+		$bootstrap_request->buildRequestResponse();
157
+		$bootstrap_request->shareRequestResponse();
158
+		$this->request  = $this->loader->getShared('EventEspresso\core\services\request\Request');
159
+		$this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
160
+		return $bootstrap_request;
161
+	}
162 162
 
163 163
 
164
-    /**
165
-     * run_request_stack
166
-     * construct request stack and run middleware apps
167
-     *
168
-     * @throws EE_Error
169
-     * @throws Exception
170
-     * @throws Throwable
171
-     */
172
-    public function runRequestStack()
173
-    {
174
-        $this->loadAutoloader();
175
-        $this->setAutoloadersForRequiredFiles();
176
-        $this->request_stack_builder = $this->buildRequestStack();
177
-        $this->request_stack         = $this->request_stack_builder->resolve(
178
-            new RequestStackCoreApp()
179
-        );
180
-        $this->request_stack->handleRequest($this->request, $this->response);
181
-        $this->request_stack->handleResponse();
182
-    }
164
+	/**
165
+	 * run_request_stack
166
+	 * construct request stack and run middleware apps
167
+	 *
168
+	 * @throws EE_Error
169
+	 * @throws Exception
170
+	 * @throws Throwable
171
+	 */
172
+	public function runRequestStack()
173
+	{
174
+		$this->loadAutoloader();
175
+		$this->setAutoloadersForRequiredFiles();
176
+		$this->request_stack_builder = $this->buildRequestStack();
177
+		$this->request_stack         = $this->request_stack_builder->resolve(
178
+			new RequestStackCoreApp()
179
+		);
180
+		$this->request_stack->handleRequest($this->request, $this->response);
181
+		$this->request_stack->handleResponse();
182
+	}
183 183
 
184 184
 
185
-    /**
186
-     * load_autoloader
187
-     *
188
-     * @throws EE_Error
189
-     */
190
-    protected function loadAutoloader()
191
-    {
192
-        // load interfaces
193
-        espresso_load_required(
194
-            'EEH_Autoloader',
195
-            EE_CORE . 'helpers/EEH_Autoloader.helper.php'
196
-        );
197
-        EEH_Autoloader::instance();
198
-    }
185
+	/**
186
+	 * load_autoloader
187
+	 *
188
+	 * @throws EE_Error
189
+	 */
190
+	protected function loadAutoloader()
191
+	{
192
+		// load interfaces
193
+		espresso_load_required(
194
+			'EEH_Autoloader',
195
+			EE_CORE . 'helpers/EEH_Autoloader.helper.php'
196
+		);
197
+		EEH_Autoloader::instance();
198
+	}
199 199
 
200 200
 
201
-    /**
202
-     * load_required_files
203
-     *
204
-     * @throws EE_Error
205
-     */
206
-    protected function setAutoloadersForRequiredFiles()
207
-    {
208
-        // load interfaces
209
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
210
-        // load helpers
211
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
212
-        // register legacy request stack classes just in case
213
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
214
-        // register legacy middleware classes just in case
215
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
216
-    }
201
+	/**
202
+	 * load_required_files
203
+	 *
204
+	 * @throws EE_Error
205
+	 */
206
+	protected function setAutoloadersForRequiredFiles()
207
+	{
208
+		// load interfaces
209
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
210
+		// load helpers
211
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
212
+		// register legacy request stack classes just in case
213
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
214
+		// register legacy middleware classes just in case
215
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
216
+	}
217 217
 
218 218
 
219
-    /**
220
-     * build_request_stack
221
-     *
222
-     * @return RequestStackBuilder
223
-     */
224
-    public function buildRequestStack(): RequestStackBuilder
225
-    {
226
-        $request_stack_builder = new RequestStackBuilder($this->loader);
227
-        /**
228
-         * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
229
-         * so items at the beginning of the final middleware stack will run last.
230
-         * First parameter is the middleware classname, second is an array of arguments
231
-         */
232
-        $stack_apps = apply_filters(
233
-            'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
234
-            [
235
-                // first in last out
236
-                BotDetector::class                 => [],
237
-                DetectFileEditorRequest::class     => [],
238
-                PreProductionVersionWarning::class => [],
239
-                RecommendedVersions::class         => [],
240
-                // last in first out
241
-                DetectLogin::class                 => [],
242
-            ]
243
-        );
244
-        // legacy filter for backwards compatibility
245
-        $stack_apps = apply_filters(
246
-            'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
247
-            $stack_apps
248
-        );
249
-        // load middleware onto stack : FILO (First In Last Out)
250
-        // items at the beginning of the $stack_apps array will run last
251
-        foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
252
-            $request_stack_builder->push([$stack_app, $stack_app_args]);
253
-        }
254
-        // finally, we'll add this on its own because we need it to always be part of the stack
255
-        // and we also need it to always run first because the rest of the system relies on it
256
-        $request_stack_builder->push(
257
-            [SetRequestTypeContextChecker::class, []]
258
-        );
259
-        return apply_filters(
260
-            'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
261
-            $request_stack_builder
262
-        );
263
-    }
219
+	/**
220
+	 * build_request_stack
221
+	 *
222
+	 * @return RequestStackBuilder
223
+	 */
224
+	public function buildRequestStack(): RequestStackBuilder
225
+	{
226
+		$request_stack_builder = new RequestStackBuilder($this->loader);
227
+		/**
228
+		 * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
229
+		 * so items at the beginning of the final middleware stack will run last.
230
+		 * First parameter is the middleware classname, second is an array of arguments
231
+		 */
232
+		$stack_apps = apply_filters(
233
+			'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
234
+			[
235
+				// first in last out
236
+				BotDetector::class                 => [],
237
+				DetectFileEditorRequest::class     => [],
238
+				PreProductionVersionWarning::class => [],
239
+				RecommendedVersions::class         => [],
240
+				// last in first out
241
+				DetectLogin::class                 => [],
242
+			]
243
+		);
244
+		// legacy filter for backwards compatibility
245
+		$stack_apps = apply_filters(
246
+			'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
247
+			$stack_apps
248
+		);
249
+		// load middleware onto stack : FILO (First In Last Out)
250
+		// items at the beginning of the $stack_apps array will run last
251
+		foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
252
+			$request_stack_builder->push([$stack_app, $stack_app_args]);
253
+		}
254
+		// finally, we'll add this on its own because we need it to always be part of the stack
255
+		// and we also need it to always run first because the rest of the system relies on it
256
+		$request_stack_builder->push(
257
+			[SetRequestTypeContextChecker::class, []]
258
+		);
259
+		return apply_filters(
260
+			'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
261
+			$request_stack_builder
262
+		);
263
+	}
264 264
 }
Please login to merge, or discard this patch.
core/services/container/OpenCoffeeShop.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
                 array(),
130 130
                 CoffeeMaker::BREW_LOAD_ONLY,
131 131
                 array(
132
-                    EE_INTERFACES . '*.php',
133
-                    EE_INTERFACES . '*.interfaces.php',
132
+                    EE_INTERFACES.'*.php',
133
+                    EE_INTERFACES.'*.interfaces.php',
134 134
                 )
135 135
             )
136 136
         );
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                 array(),
143 143
                 array(),
144 144
                 CoffeeMaker::BREW_SHARED,
145
-                EE_MODELS . '*.model.php'
145
+                EE_MODELS.'*.model.php'
146 146
             )
147 147
         );
148 148
         // add a wildcard recipe for loading core classes
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
                 array(),
155 155
                 CoffeeMaker::BREW_SHARED,
156 156
                 array(
157
-                    EE_CORE . '*.core.php',
158
-                    EE_ADMIN . '*.core.php',
159
-                    EE_CPTS . '*.core.php',
160
-                    EE_CORE . 'data_migration_scripts/*.core.php',
157
+                    EE_CORE.'*.core.php',
158
+                    EE_ADMIN.'*.core.php',
159
+                    EE_CPTS.'*.core.php',
160
+                    EE_CORE.'data_migration_scripts/*.core.php',
161 161
                 )
162 162
             )
163 163
         );
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
                 array(),
170 170
                 array(),
171 171
                 CoffeeMaker::BREW_LOAD_ONLY,
172
-                array(EE_ADMIN . '*.core.php')
172
+                array(EE_ADMIN.'*.core.php')
173 173
             )
174 174
         );
175 175
         // add a wildcard recipe for loading core classes
Please login to merge, or discard this patch.
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -19,192 +19,192 @@
 block discarded – undo
19 19
  */
20 20
 class OpenCoffeeShop
21 21
 {
22
-    /**
23
-     * @var CoffeeShop $CoffeeShop
24
-     */
25
-    private $CoffeeShop;
22
+	/**
23
+	 * @var CoffeeShop $CoffeeShop
24
+	 */
25
+	private $CoffeeShop;
26 26
 
27 27
 
28
-    /**
29
-     * OpenCoffeeShop constructor
30
-     *
31
-     * @throws InvalidInterfaceException
32
-     */
33
-    public function __construct()
34
-    {
35
-        // instantiate the DI container
36
-        $this->CoffeeShop = new CoffeeShop();
37
-    }
28
+	/**
29
+	 * OpenCoffeeShop constructor
30
+	 *
31
+	 * @throws InvalidInterfaceException
32
+	 */
33
+	public function __construct()
34
+	{
35
+		// instantiate the DI container
36
+		$this->CoffeeShop = new CoffeeShop();
37
+	}
38 38
 
39 39
 
40
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
41
-    /**
42
-     * @return CoffeeShop
43
-     */
44
-    public function CoffeeShop()
45
-    {
46
-        return $this->CoffeeShop;
47
-    }
40
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
41
+	/**
42
+	 * @return CoffeeShop
43
+	 */
44
+	public function CoffeeShop()
45
+	{
46
+		return $this->CoffeeShop;
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * configure coffee makers which control the different kinds of brews
52
-     * ( shared services, new factory objects, etc )
53
-     *
54
-     * @throws InvalidEntityException
55
-     */
56
-    public function setupCoffeeMakers()
57
-    {
58
-        // create a dependency injector class for resolving class constructor arguments
59
-        $DependencyInjector = new DependencyInjector(
60
-            $this->CoffeeShop,
61
-            new \EEH_Array()
62
-        );
63
-        // and some coffeemakers, one for creating new instances
64
-        $this->CoffeeShop->addCoffeeMaker(
65
-            new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector),
66
-            CoffeeMaker::BREW_NEW
67
-        );
68
-        // one for shared services
69
-        $this->CoffeeShop->addCoffeeMaker(
70
-            new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector),
71
-            CoffeeMaker::BREW_SHARED
72
-        );
73
-        // and one for classes that only get loaded
74
-        $this->CoffeeShop->addCoffeeMaker(
75
-            new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector),
76
-            CoffeeMaker::BREW_LOAD_ONLY
77
-        );
78
-    }
50
+	/**
51
+	 * configure coffee makers which control the different kinds of brews
52
+	 * ( shared services, new factory objects, etc )
53
+	 *
54
+	 * @throws InvalidEntityException
55
+	 */
56
+	public function setupCoffeeMakers()
57
+	{
58
+		// create a dependency injector class for resolving class constructor arguments
59
+		$DependencyInjector = new DependencyInjector(
60
+			$this->CoffeeShop,
61
+			new \EEH_Array()
62
+		);
63
+		// and some coffeemakers, one for creating new instances
64
+		$this->CoffeeShop->addCoffeeMaker(
65
+			new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector),
66
+			CoffeeMaker::BREW_NEW
67
+		);
68
+		// one for shared services
69
+		$this->CoffeeShop->addCoffeeMaker(
70
+			new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector),
71
+			CoffeeMaker::BREW_SHARED
72
+		);
73
+		// and one for classes that only get loaded
74
+		$this->CoffeeShop->addCoffeeMaker(
75
+			new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector),
76
+			CoffeeMaker::BREW_LOAD_ONLY
77
+		);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * Recipes define how to load legacy classes
83
-     *
84
-     * @throws InvalidIdentifierException
85
-     */
86
-    public function addRecipes()
87
-    {
88
-        // add default recipe, which should handle loading for most PSR-4 compatible classes
89
-        // as long as they are not type hinting for interfaces
90
-        $this->CoffeeShop->addRecipe(
91
-            new Recipe(
92
-                Recipe::DEFAULT_ID
93
-            )
94
-        );
95
-        // PSR-4 compatible class with aliases
96
-        $this->CoffeeShop->addRecipe(
97
-            new Recipe(
98
-                'CommandHandlerManager',
99
-                'EventEspresso\core\services\commands\CommandHandlerManager',
100
-                array(
101
-                    'CommandHandlerManagerInterface',
102
-                    'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
103
-                ),
104
-                array(),
105
-                CoffeeMaker::BREW_SHARED
106
-            )
107
-        );
108
-        // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager
109
-        $this->CoffeeShop->addRecipe(
110
-            new Recipe(
111
-                'CommandBus',
112
-                'EventEspresso\core\services\commands\CommandBus',
113
-                array(
114
-                    'CommandBusInterface',
115
-                    'EventEspresso\core\services\commands\CommandBusInterface',
116
-                ),
117
-                array(),
118
-                CoffeeMaker::BREW_SHARED
119
-            )
120
-        );
121
-        // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath
122
-        // add a wildcard recipe for loading legacy core interfaces
123
-        $this->CoffeeShop->addRecipe(
124
-            new Recipe(
125
-                'EEI_*',
126
-                '',
127
-                array(),
128
-                array(),
129
-                CoffeeMaker::BREW_LOAD_ONLY,
130
-                array(
131
-                    EE_INTERFACES . '*.php',
132
-                    EE_INTERFACES . '*.interfaces.php',
133
-                )
134
-            )
135
-        );
136
-        // add a wildcard recipe for loading models
137
-        $this->CoffeeShop->addRecipe(
138
-            new Recipe(
139
-                'EEM_*',
140
-                '',
141
-                array(),
142
-                array(),
143
-                CoffeeMaker::BREW_SHARED,
144
-                EE_MODELS . '*.model.php'
145
-            )
146
-        );
147
-        // add a wildcard recipe for loading core classes
148
-        $this->CoffeeShop->addRecipe(
149
-            new Recipe(
150
-                'EE_*',
151
-                '',
152
-                array(),
153
-                array(),
154
-                CoffeeMaker::BREW_SHARED,
155
-                array(
156
-                    EE_CORE . '*.core.php',
157
-                    EE_ADMIN . '*.core.php',
158
-                    EE_CPTS . '*.core.php',
159
-                    EE_CORE . 'data_migration_scripts/*.core.php',
160
-                )
161
-            )
162
-        );
163
-        // load admin page parent class
164
-        $this->CoffeeShop->addRecipe(
165
-            new Recipe(
166
-                'EE_Admin_Page*',
167
-                '',
168
-                array(),
169
-                array(),
170
-                CoffeeMaker::BREW_LOAD_ONLY,
171
-                array(EE_ADMIN . '*.core.php')
172
-            )
173
-        );
174
-        // add a wildcard recipe for loading core classes
175
-        // $this->CoffeeShop->addRecipe(
176
-        //     new Recipe(
177
-        //         '*_Admin_Page',
178
-        //         '',
179
-        //         array(),
180
-        //         array(),
181
-        //         CoffeeMaker::BREW_SHARED,
182
-        //         array(
183
-        //             EE_ADMIN_PAGES . 'transactions/*.core.php',
184
-        //         )
185
-        //     )
186
-        // );
187
-    }
81
+	/**
82
+	 * Recipes define how to load legacy classes
83
+	 *
84
+	 * @throws InvalidIdentifierException
85
+	 */
86
+	public function addRecipes()
87
+	{
88
+		// add default recipe, which should handle loading for most PSR-4 compatible classes
89
+		// as long as they are not type hinting for interfaces
90
+		$this->CoffeeShop->addRecipe(
91
+			new Recipe(
92
+				Recipe::DEFAULT_ID
93
+			)
94
+		);
95
+		// PSR-4 compatible class with aliases
96
+		$this->CoffeeShop->addRecipe(
97
+			new Recipe(
98
+				'CommandHandlerManager',
99
+				'EventEspresso\core\services\commands\CommandHandlerManager',
100
+				array(
101
+					'CommandHandlerManagerInterface',
102
+					'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
103
+				),
104
+				array(),
105
+				CoffeeMaker::BREW_SHARED
106
+			)
107
+		);
108
+		// PSR-4 compatible class with aliases, which dependency on CommandHandlerManager
109
+		$this->CoffeeShop->addRecipe(
110
+			new Recipe(
111
+				'CommandBus',
112
+				'EventEspresso\core\services\commands\CommandBus',
113
+				array(
114
+					'CommandBusInterface',
115
+					'EventEspresso\core\services\commands\CommandBusInterface',
116
+				),
117
+				array(),
118
+				CoffeeMaker::BREW_SHARED
119
+			)
120
+		);
121
+		// LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath
122
+		// add a wildcard recipe for loading legacy core interfaces
123
+		$this->CoffeeShop->addRecipe(
124
+			new Recipe(
125
+				'EEI_*',
126
+				'',
127
+				array(),
128
+				array(),
129
+				CoffeeMaker::BREW_LOAD_ONLY,
130
+				array(
131
+					EE_INTERFACES . '*.php',
132
+					EE_INTERFACES . '*.interfaces.php',
133
+				)
134
+			)
135
+		);
136
+		// add a wildcard recipe for loading models
137
+		$this->CoffeeShop->addRecipe(
138
+			new Recipe(
139
+				'EEM_*',
140
+				'',
141
+				array(),
142
+				array(),
143
+				CoffeeMaker::BREW_SHARED,
144
+				EE_MODELS . '*.model.php'
145
+			)
146
+		);
147
+		// add a wildcard recipe for loading core classes
148
+		$this->CoffeeShop->addRecipe(
149
+			new Recipe(
150
+				'EE_*',
151
+				'',
152
+				array(),
153
+				array(),
154
+				CoffeeMaker::BREW_SHARED,
155
+				array(
156
+					EE_CORE . '*.core.php',
157
+					EE_ADMIN . '*.core.php',
158
+					EE_CPTS . '*.core.php',
159
+					EE_CORE . 'data_migration_scripts/*.core.php',
160
+				)
161
+			)
162
+		);
163
+		// load admin page parent class
164
+		$this->CoffeeShop->addRecipe(
165
+			new Recipe(
166
+				'EE_Admin_Page*',
167
+				'',
168
+				array(),
169
+				array(),
170
+				CoffeeMaker::BREW_LOAD_ONLY,
171
+				array(EE_ADMIN . '*.core.php')
172
+			)
173
+		);
174
+		// add a wildcard recipe for loading core classes
175
+		// $this->CoffeeShop->addRecipe(
176
+		//     new Recipe(
177
+		//         '*_Admin_Page',
178
+		//         '',
179
+		//         array(),
180
+		//         array(),
181
+		//         CoffeeMaker::BREW_SHARED,
182
+		//         array(
183
+		//             EE_ADMIN_PAGES . 'transactions/*.core.php',
184
+		//         )
185
+		//     )
186
+		// );
187
+	}
188 188
 
189 189
 
190
-    /**
191
-     * bootstrap EE and the request stack
192
-     *
193
-     * @throws ServiceNotFoundException
194
-     * @throws InvalidClassException
195
-     * @throws InvalidDataTypeException
196
-     * @throws InvalidIdentifierException
197
-     * @throws exceptions\ServiceExistsException
198
-     * @throws OutOfBoundsException
199
-     * @throws exceptions\InstantiationException
200
-     */
201
-    public function firstBrew()
202
-    {
203
-        $this->CoffeeShop->brew(
204
-            'EventEspresso\core\services\request\Request',
205
-            array($_GET, $_POST, $_COOKIE, $_SERVER)
206
-        );
207
-        $this->CoffeeShop->brew('EventEspresso\core\services\request\Response');
208
-        $this->CoffeeShop->brew('EE_Bootstrap');
209
-    }
190
+	/**
191
+	 * bootstrap EE and the request stack
192
+	 *
193
+	 * @throws ServiceNotFoundException
194
+	 * @throws InvalidClassException
195
+	 * @throws InvalidDataTypeException
196
+	 * @throws InvalidIdentifierException
197
+	 * @throws exceptions\ServiceExistsException
198
+	 * @throws OutOfBoundsException
199
+	 * @throws exceptions\InstantiationException
200
+	 */
201
+	public function firstBrew()
202
+	{
203
+		$this->CoffeeShop->brew(
204
+			'EventEspresso\core\services\request\Request',
205
+			array($_GET, $_POST, $_COOKIE, $_SERVER)
206
+		);
207
+		$this->CoffeeShop->brew('EventEspresso\core\services\request\Response');
208
+		$this->CoffeeShop->brew('EE_Bootstrap');
209
+	}
210 210
 }
Please login to merge, or discard this patch.
display_strategies/number_bubbles/NumberBubblesProgressStepsDisplay.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
27 27
         wp_enqueue_style(
28 28
             'ee_progress_steps_display_number_bubbles',
29
-            plugin_dir_url(__FILE__) . 'number_bubbles.css'
29
+            plugin_dir_url(__FILE__).'number_bubbles.css'
30 30
         );
31 31
     }
32 32
 
@@ -39,6 +39,6 @@  discard block
 block discarded – undo
39 39
     public function getTemplate()
40 40
     {
41 41
         // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
42
-        return __DIR__ . '/number_bubbles.template.php';
42
+        return __DIR__.'/number_bubbles.template.php';
43 43
     }
44 44
 }
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -14,29 +14,29 @@
 block discarded – undo
14 14
  */
15 15
 class NumberBubblesProgressStepsDisplay implements ProgressStepsDisplayInterface
16 16
 {
17
-    /**
18
-     * used for setting up css and js required for the display strategy
19
-     *
20
-     * @return void
21
-     */
22
-    public function enqueueStylesAndScripts()
23
-    {
24
-        // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
25
-        wp_enqueue_style(
26
-            'ee_progress_steps_display_number_bubbles',
27
-            plugin_dir_url(__FILE__) . 'number_bubbles.css'
28
-        );
29
-    }
17
+	/**
18
+	 * used for setting up css and js required for the display strategy
19
+	 *
20
+	 * @return void
21
+	 */
22
+	public function enqueueStylesAndScripts()
23
+	{
24
+		// core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
25
+		wp_enqueue_style(
26
+			'ee_progress_steps_display_number_bubbles',
27
+			plugin_dir_url(__FILE__) . 'number_bubbles.css'
28
+		);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * loads and returns a full server path to the template used for the display strategy
34
-     *
35
-     * @return string
36
-     */
37
-    public function getTemplate()
38
-    {
39
-        // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
40
-        return __DIR__ . '/number_bubbles.template.php';
41
-    }
32
+	/**
33
+	 * loads and returns a full server path to the template used for the display strategy
34
+	 *
35
+	 * @return string
36
+	 */
37
+	public function getTemplate()
38
+	{
39
+		// return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
40
+		return __DIR__ . '/number_bubbles.template.php';
41
+	}
42 42
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Proper.form.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
             // AND we are going to make sure they're in that specified order
112 112
             $reordered_subsections = array();
113 113
             foreach ($options_array['include'] as $input_name) {
114
-                if (isset($this->_subsections[ $input_name ])) {
115
-                    $reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
114
+                if (isset($this->_subsections[$input_name])) {
115
+                    $reordered_subsections[$input_name] = $this->_subsections[$input_name];
116 116
                 }
117 117
             }
118 118
             $this->_subsections = $reordered_subsections;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         if (isset($options_array['layout_strategy'])) {
125 125
             $this->_layout_strategy = $options_array['layout_strategy'];
126 126
         }
127
-        if (! $this->_layout_strategy) {
127
+        if ( ! $this->_layout_strategy) {
128 128
             $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
129 129
         }
130 130
         $this->_layout_strategy->_construct_finalize($this);
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         if ($validate) {
314 314
             $this->_validate();
315 315
             // if it's invalid, we're going to want to re-display so remember what they submitted
316
-            if (! $this->is_valid()) {
316
+            if ( ! $this->is_valid()) {
317 317
                 $this->store_submitted_form_data_in_session();
318 318
             }
319 319
         }
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
     public function populate_defaults($default_data)
427 427
     {
428 428
         foreach ($this->subsections(false) as $subsection_name => $subsection) {
429
-            if (isset($default_data[ $subsection_name ])) {
429
+            if (isset($default_data[$subsection_name])) {
430 430
                 if ($subsection instanceof EE_Form_Input_Base) {
431
-                    $subsection->set_default($default_data[ $subsection_name ]);
431
+                    $subsection->set_default($default_data[$subsection_name]);
432 432
                 } elseif ($subsection instanceof EE_Form_Section_Proper) {
433
-                    $subsection->populate_defaults($default_data[ $subsection_name ]);
433
+                    $subsection->populate_defaults($default_data[$subsection_name]);
434 434
                 }
435 435
             }
436 436
         }
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
      */
446 446
     public function subsection_exists($name)
447 447
     {
448
-        return isset($this->_subsections[ $name ]) ? true : false;
448
+        return isset($this->_subsections[$name]) ? true : false;
449 449
     }
450 450
 
451 451
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
         if ($require_construction_to_be_finalized) {
468 468
             $this->ensure_construct_finalized_called();
469 469
         }
470
-        return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
470
+        return $this->subsection_exists($name) ? $this->_subsections[$name] : null;
471 471
     }
472 472
 
473 473
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
         $validatable_subsections = array();
483 483
         foreach ($this->subsections() as $name => $obj) {
484 484
             if ($obj instanceof EE_Form_Section_Validatable) {
485
-                $validatable_subsections[ $name ] = $obj;
485
+                $validatable_subsections[$name] = $obj;
486 486
             }
487 487
         }
488 488
         return $validatable_subsections;
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
             $name,
510 510
             $require_construction_to_be_finalized
511 511
         );
512
-        if (! $subsection instanceof EE_Form_Input_Base) {
512
+        if ( ! $subsection instanceof EE_Form_Input_Base) {
513 513
             throw new EE_Error(
514 514
                 sprintf(
515 515
                     esc_html__(
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
             $name,
547 547
             $require_construction_to_be_finalized
548 548
         );
549
-        if (! $subsection instanceof EE_Form_Section_Proper) {
549
+        if ( ! $subsection instanceof EE_Form_Section_Proper) {
550 550
             throw new EE_Error(
551 551
                 sprintf(
552 552
                     esc_html__(
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
     public function is_valid()
587 587
     {
588 588
         if ($this->is_valid === null) {
589
-            if (! $this->has_received_submission()) {
589
+            if ( ! $this->has_received_submission()) {
590 590
                 throw new EE_Error(
591 591
                     sprintf(
592 592
                         esc_html__(
@@ -596,14 +596,14 @@  discard block
 block discarded – undo
596 596
                     )
597 597
                 );
598 598
             }
599
-            if (! parent::is_valid()) {
599
+            if ( ! parent::is_valid()) {
600 600
                 $this->is_valid = false;
601 601
             } else {
602 602
                 // ok so no general errors to this entire form section.
603 603
                 // so let's check the subsections, but only set errors if that hasn't been done yet
604 604
                 $this->is_valid = true;
605 605
                 foreach ($this->get_validatable_subsections() as $subsection) {
606
-                    if (! $subsection->is_valid()) {
606
+                    if ( ! $subsection->is_valid()) {
607 607
                         $this->is_valid = false;
608 608
                     }
609 609
                 }
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
      */
621 621
     protected function _set_default_name_if_empty()
622 622
     {
623
-        if (! $this->_name) {
623
+        if ( ! $this->_name) {
624 624
             $classname    = get_class($this);
625 625
             $default_name = str_replace('EE_', '', $classname);
626 626
             $this->_name  = $default_name;
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
     {
711 711
         wp_register_script(
712 712
             'ee_form_section_validation',
713
-            EE_GLOBAL_ASSETS_URL . 'scripts' . '/form_section_validation.js',
713
+            EE_GLOBAL_ASSETS_URL.'scripts'.'/form_section_validation.js',
714 714
             array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
715 715
             EVENT_ESPRESSO_VERSION,
716 716
             true
@@ -754,13 +754,13 @@  discard block
 block discarded – undo
754 754
         // we only want to localize vars ONCE for the entire form,
755 755
         // so if the form section doesn't have a parent, then it must be the top dog
756 756
         if ($return_for_subsection || ! $this->parent_section()) {
757
-            EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
757
+            EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array(
758 758
                 'form_section_id'  => $this->html_id(true),
759 759
                 'validation_rules' => $this->get_jquery_validation_rules(),
760 760
                 'other_data'       => $this->get_other_js_data(),
761 761
                 'errors'           => $this->subsection_validation_errors_by_html_name(),
762 762
             );
763
-            EE_Form_Section_Proper::$_scripts_localized                                = true;
763
+            EE_Form_Section_Proper::$_scripts_localized = true;
764 764
         }
765 765
     }
766 766
 
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
         $inputs = array();
796 796
         foreach ($this->subsections() as $subsection) {
797 797
             if ($subsection instanceof EE_Form_Input_Base) {
798
-                $inputs[ $subsection->html_name() ] = $subsection;
798
+                $inputs[$subsection->html_name()] = $subsection;
799 799
             } elseif ($subsection instanceof EE_Form_Section_Proper) {
800 800
                 $inputs += $subsection->inputs_in_subsections();
801 801
             }
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
         $errors = array();
819 819
         foreach ($inputs as $form_input) {
820 820
             if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
821
-                $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
821
+                $errors[$form_input->html_name()] = $form_input->get_validation_error_string();
822 822
             }
823 823
         }
824 824
         return $errors;
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
         $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
842 842
             ? EE_Registry::instance()->CFG->registration->email_validation_level
843 843
             : 'wp_default';
844
-        EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
844
+        EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level;
845 845
         wp_enqueue_script('ee_form_section_validation');
846 846
         wp_localize_script(
847 847
             'ee_form_section_validation',
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
      */
859 859
     public function ensure_scripts_localized()
860 860
     {
861
-        if (! EE_Form_Section_Proper::$_scripts_localized) {
861
+        if ( ! EE_Form_Section_Proper::$_scripts_localized) {
862 862
             $this->_enqueue_and_localize_form_js();
863 863
         }
864 864
     }
@@ -954,8 +954,8 @@  discard block
 block discarded – undo
954 954
         // reset the cache of whether this form is valid or not- we're re-validating it now
955 955
         $this->is_valid = null;
956 956
         foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
957
-            if (method_exists($this, '_validate_' . $subsection_name)) {
958
-                call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
957
+            if (method_exists($this, '_validate_'.$subsection_name)) {
958
+                call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
959 959
             }
960 960
             $subsection->_validate();
961 961
         }
@@ -973,9 +973,9 @@  discard block
 block discarded – undo
973 973
         $inputs = array();
974 974
         foreach ($this->subsections() as $subsection_name => $subsection) {
975 975
             if ($subsection instanceof EE_Form_Section_Proper) {
976
-                $inputs[ $subsection_name ] = $subsection->valid_data();
976
+                $inputs[$subsection_name] = $subsection->valid_data();
977 977
             } elseif ($subsection instanceof EE_Form_Input_Base) {
978
-                $inputs[ $subsection_name ] = $subsection->normalized_value();
978
+                $inputs[$subsection_name] = $subsection->normalized_value();
979 979
             }
980 980
         }
981 981
         return $inputs;
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
         $inputs = array();
994 994
         foreach ($this->subsections() as $subsection_name => $subsection) {
995 995
             if ($subsection instanceof EE_Form_Input_Base) {
996
-                $inputs[ $subsection_name ] = $subsection;
996
+                $inputs[$subsection_name] = $subsection;
997 997
             }
998 998
         }
999 999
         return $inputs;
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
         $form_sections = array();
1012 1012
         foreach ($this->subsections() as $name => $obj) {
1013 1013
             if ($obj instanceof EE_Form_Section_Proper) {
1014
-                $form_sections[ $name ] = $obj;
1014
+                $form_sections[$name] = $obj;
1015 1015
             }
1016 1016
         }
1017 1017
         return $form_sections;
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
         $input_values = array();
1119 1119
         foreach ($this->subsections() as $subsection_name => $subsection) {
1120 1120
             if ($subsection instanceof EE_Form_Input_Base) {
1121
-                $input_values[ $subsection_name ] = $pretty
1121
+                $input_values[$subsection_name] = $pretty
1122 1122
                     ? $subsection->pretty_value()
1123 1123
                     : $subsection->normalized_value();
1124 1124
             } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
                 if ($flatten) {
1131 1131
                     $input_values = array_merge($input_values, $subform_input_values);
1132 1132
                 } else {
1133
-                    $input_values[ $subsection_name ] = $subform_input_values;
1133
+                    $input_values[$subsection_name] = $subform_input_values;
1134 1134
                 }
1135 1135
             }
1136 1136
         }
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
             if ($subsection instanceof EE_Form_Input_Base) {
1159 1159
                 // is this input part of an array of inputs?
1160 1160
                 if (strpos($subsection->html_name(), '[') !== false) {
1161
-                    $full_input_name  = EEH_Array::convert_array_values_to_keys(
1161
+                    $full_input_name = EEH_Array::convert_array_values_to_keys(
1162 1162
                         explode(
1163 1163
                             '[',
1164 1164
                             str_replace(']', '', $subsection->html_name())
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
                     );
1168 1168
                     $submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1169 1169
                 } else {
1170
-                    $submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1170
+                    $submitted_values[$subsection->html_name()] = $subsection->raw_value();
1171 1171
                 }
1172 1172
             } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1173 1173
                 $subform_input_values = $subsection->submitted_values($include_subforms);
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
     public function exclude(array $inputs_to_exclude = array())
1203 1203
     {
1204 1204
         foreach ($inputs_to_exclude as $input_to_exclude_name) {
1205
-            unset($this->_subsections[ $input_to_exclude_name ]);
1205
+            unset($this->_subsections[$input_to_exclude_name]);
1206 1206
         }
1207 1207
     }
1208 1208
 
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
     public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1246 1246
     {
1247 1247
         foreach ($new_subsections as $subsection_name => $subsection) {
1248
-            if (! $subsection instanceof EE_Form_Section_Base) {
1248
+            if ( ! $subsection instanceof EE_Form_Section_Base) {
1249 1249
                 EE_Error::add_error(
1250 1250
                     sprintf(
1251 1251
                         esc_html__(
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
                         $this->name()
1258 1258
                     )
1259 1259
                 );
1260
-                unset($new_subsections[ $subsection_name ]);
1260
+                unset($new_subsections[$subsection_name]);
1261 1261
             }
1262 1262
         }
1263 1263
         $this->_subsections = EEH_Array::insert_into_array(
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
     public function html_name_prefix()
1373 1373
     {
1374 1374
         if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1375
-            return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1375
+            return $this->parent_section()->html_name_prefix().'['.$this->name().']';
1376 1376
         }
1377 1377
         return $this->name();
1378 1378
     }
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
      */
1413 1413
     public function ensure_construct_finalized_called()
1414 1414
     {
1415
-        if (! $this->_construction_finalized) {
1415
+        if ( ! $this->_construction_finalized) {
1416 1416
             $this->_construct_finalize($this->_parent_section, $this->_name);
1417 1417
         }
1418 1418
     }
Please login to merge, or discard this patch.
Indentation   +1532 added lines, -1532 removed lines patch added patch discarded remove patch
@@ -15,1536 +15,1536 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Form_Section_Proper extends EE_Form_Section_Validatable
17 17
 {
18
-    const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
19
-
20
-    /**
21
-     * Subsections
22
-     *
23
-     * @var EE_Form_Section_Validatable[]
24
-     */
25
-    protected $_subsections = array();
26
-
27
-    /**
28
-     * Strategy for laying out the form
29
-     *
30
-     * @var EE_Form_Section_Layout_Base
31
-     */
32
-    protected $_layout_strategy;
33
-
34
-    /**
35
-     * Whether or not this form has received and validated a form submission yet
36
-     *
37
-     * @var boolean
38
-     */
39
-    protected $_received_submission = false;
40
-
41
-    /**
42
-     * message displayed to users upon successful form submission
43
-     *
44
-     * @var string
45
-     */
46
-    protected $_form_submission_success_message = '';
47
-
48
-    /**
49
-     * message displayed to users upon unsuccessful form submission
50
-     *
51
-     * @var string
52
-     */
53
-    protected $_form_submission_error_message = '';
54
-
55
-    /**
56
-     * @var array like post / request
57
-     */
58
-    protected $cached_request_data;
59
-
60
-    /**
61
-     * Stores whether this form (and its sub-sections) were found to be valid or not.
62
-     * Starts off as null, but once the form is validated, it set to either true or false
63
-     * @var boolean|null
64
-     */
65
-    protected $is_valid;
66
-
67
-    /**
68
-     * Stores all the data that will localized for form validation
69
-     *
70
-     * @var array
71
-     */
72
-    protected static $_js_localization = array();
73
-
74
-    /**
75
-     * whether or not the form's localized validation JS vars have been set
76
-     *
77
-     * @type boolean
78
-     */
79
-    protected static $_scripts_localized = false;
80
-
81
-
82
-    /**
83
-     * when constructing a proper form section, calls _construct_finalize on children
84
-     * so that they know who their parent is, and what name they've been given.
85
-     *
86
-     * @param array[] $options_array   {
87
-     * @type          $subsections     EE_Form_Section_Validatable[] where keys are the section's name
88
-     * @type          $include         string[] numerically-indexed where values are section names to be included,
89
-     *                                 and in that order. This is handy if you want
90
-     *                                 the subsections to be ordered differently than the default, and if you override
91
-     *                                 which fields are shown
92
-     * @type          $exclude         string[] values are subsections to be excluded. This is handy if you want
93
-     *                                 to remove certain default subsections (note: if you specify BOTH 'include' AND
94
-     *                                 'exclude', the inclusions will be applied first, and the exclusions will exclude
95
-     *                                 items from that list of inclusions)
96
-     * @type          $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
97
-     *                                 } @see EE_Form_Section_Validatable::__construct()
98
-     * @throws EE_Error
99
-     */
100
-    public function __construct($options_array = array())
101
-    {
102
-        $options_array = (array) apply_filters(
103
-            'FHEE__EE_Form_Section_Proper___construct__options_array',
104
-            $options_array,
105
-            $this
106
-        );
107
-        // call parent first, as it may be setting the name
108
-        parent::__construct($options_array);
109
-        // if they've included subsections in the constructor, add them now
110
-        if (isset($options_array['include'])) {
111
-            // we are going to make sure we ONLY have those subsections to include
112
-            // AND we are going to make sure they're in that specified order
113
-            $reordered_subsections = array();
114
-            foreach ($options_array['include'] as $input_name) {
115
-                if (isset($this->_subsections[ $input_name ])) {
116
-                    $reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
117
-                }
118
-            }
119
-            $this->_subsections = $reordered_subsections;
120
-        }
121
-        if (isset($options_array['exclude'])) {
122
-            $exclude            = $options_array['exclude'];
123
-            $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
124
-        }
125
-        if (isset($options_array['layout_strategy'])) {
126
-            $this->_layout_strategy = $options_array['layout_strategy'];
127
-        }
128
-        if (! $this->_layout_strategy) {
129
-            $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
130
-        }
131
-        $this->_layout_strategy->_construct_finalize($this);
132
-        // ok so we are definitely going to want the forms JS,
133
-        // so enqueue it or remember to enqueue it during wp_enqueue_scripts
134
-        if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
135
-            // ok so they've constructed this object after when they should have.
136
-            // just enqueue the generic form scripts and initialize the form immediately in the JS
137
-            EE_Form_Section_Proper::wp_enqueue_scripts(true);
138
-        } else {
139
-            add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
140
-            add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
141
-        }
142
-        add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
143
-        /**
144
-         * Gives other plugins a chance to hook in before construct finalize is called.
145
-         * The form probably doesn't yet have a parent form section.
146
-         * Since 4.9.32, when this action was introduced, this is the best place to add a subsection onto a form,
147
-         * assuming you don't care what the form section's name, HTML ID, or HTML name etc are.
148
-         * Also see AHEE__EE_Form_Section_Proper___construct_finalize__end
149
-         *
150
-         * @since 4.9.32
151
-         * @param EE_Form_Section_Proper $this          before __construct is done, but all of its logic,
152
-         *                                              except maybe calling _construct_finalize has been done
153
-         * @param array                  $options_array options passed into the constructor
154
-         */
155
-        do_action(
156
-            'AHEE__EE_Form_Input_Base___construct__before_construct_finalize_called',
157
-            $this,
158
-            $options_array
159
-        );
160
-        if (isset($options_array['name'])) {
161
-            $this->_construct_finalize(null, $options_array['name']);
162
-        }
163
-    }
164
-
165
-
166
-    /**
167
-     * Finishes construction given the parent form section and this form section's name
168
-     *
169
-     * @param EE_Form_Section_Proper $parent_form_section
170
-     * @param string                 $name
171
-     * @throws EE_Error
172
-     */
173
-    public function _construct_finalize($parent_form_section, $name)
174
-    {
175
-        parent::_construct_finalize($parent_form_section, $name);
176
-        $this->_set_default_name_if_empty();
177
-        $this->_set_default_html_id_if_empty();
178
-        foreach ($this->_subsections as $subsection_name => $subsection) {
179
-            if ($subsection instanceof EE_Form_Section_Base) {
180
-                $subsection->_construct_finalize($this, $subsection_name);
181
-            } else {
182
-                throw new EE_Error(
183
-                    sprintf(
184
-                        esc_html__(
185
-                            'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
186
-                            'event_espresso'
187
-                        ),
188
-                        $subsection_name,
189
-                        get_class($this),
190
-                        $subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
191
-                    )
192
-                );
193
-            }
194
-        }
195
-        /**
196
-         * Action performed just after form has been given a name (and HTML ID etc) and is fully constructed.
197
-         * If you have code that should modify the form and needs it and its subsections to have a name, HTML ID
198
-         * (or other attributes derived from the name like the HTML label id, etc), this is where it should be done.
199
-         * This might only happen just before displaying the form, or just before it receives form submission data.
200
-         * If you need to modify the form or its subsections before _construct_finalize is called on it (and we've
201
-         * ensured it has a name, HTML IDs, etc
202
-         *
203
-         * @param EE_Form_Section_Proper      $this
204
-         * @param EE_Form_Section_Proper|null $parent_form_section
205
-         * @param string                      $name
206
-         */
207
-        do_action(
208
-            'AHEE__EE_Form_Section_Proper___construct_finalize__end',
209
-            $this,
210
-            $parent_form_section,
211
-            $name
212
-        );
213
-    }
214
-
215
-
216
-    /**
217
-     * Gets the layout strategy for this form section
218
-     *
219
-     * @return EE_Form_Section_Layout_Base
220
-     */
221
-    public function get_layout_strategy()
222
-    {
223
-        return $this->_layout_strategy;
224
-    }
225
-
226
-
227
-    /**
228
-     * Gets the HTML for a single input for this form section according
229
-     * to the layout strategy
230
-     *
231
-     * @param EE_Form_Input_Base $input
232
-     * @return string
233
-     */
234
-    public function get_html_for_input($input)
235
-    {
236
-        return $this->_layout_strategy->layout_input($input);
237
-    }
238
-
239
-
240
-    /**
241
-     * was_submitted - checks if form inputs are present in request data
242
-     * Basically an alias for form_data_present_in() (which is used by both
243
-     * proper form sections and form inputs)
244
-     *
245
-     * @param null $form_data
246
-     * @return boolean
247
-     * @throws EE_Error
248
-     */
249
-    public function was_submitted($form_data = null)
250
-    {
251
-        return $this->form_data_present_in($form_data);
252
-    }
253
-
254
-    /**
255
-     * Gets the cached request data; but if there is none, or $req_data was set with
256
-     * something different, refresh the cache, and then return it
257
-     * @param null $req_data
258
-     * @return array
259
-     */
260
-    protected function getCachedRequest($req_data = null)
261
-    {
262
-        if (
263
-            $this->cached_request_data === null
264
-            || (
265
-                $req_data !== null
266
-                && $req_data !== $this->cached_request_data
267
-            )
268
-        ) {
269
-            $req_data = apply_filters(
270
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
271
-                $req_data,
272
-                $this
273
-            );
274
-            if ($req_data === null) {
275
-                /** @var RequestInterface $request */
276
-                $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
277
-                $req_data = $request->requestParams();
278
-            }
279
-            $req_data = apply_filters(
280
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
281
-                $req_data,
282
-                $this
283
-            );
284
-            $this->cached_request_data = (array) $req_data;
285
-        }
286
-        return $this->cached_request_data;
287
-    }
288
-
289
-
290
-    /**
291
-     * After the form section is initially created, call this to sanitize the data in the submission
292
-     * which relates to this form section, validate it, and set it as properties on the form.
293
-     *
294
-     * @param array|null $req_data should usually be post data (the default).
295
-     *                             However, you CAN supply a different array.
296
-     *                             Consider using set_defaults() instead however.
297
-     *                             (If you rendered the form in the page using $form_x->get_html()
298
-     *                             the inputs will have the correct name in the request data for this function
299
-     *                             to find them and populate the form with them.
300
-     *                             If you have a flat form (with only input subsections),
301
-     *                             you can supply a flat array where keys
302
-     *                             are the form input names and values are their values)
303
-     * @param boolean    $validate whether or not to perform validation on this data. Default is,
304
-     *                             of course, to validate that data, and set errors on the invalid values.
305
-     *                             But if the data has already been validated
306
-     *                             (eg you validated the data then stored it in the DB)
307
-     *                             you may want to skip this step.
308
-     * @throws InvalidArgumentException
309
-     * @throws InvalidInterfaceException
310
-     * @throws InvalidDataTypeException
311
-     * @throws EE_Error
312
-     */
313
-    public function receive_form_submission($req_data = null, $validate = true)
314
-    {
315
-        $req_data = $this->getCachedRequest($req_data);
316
-        $this->_normalize($req_data);
317
-        if ($validate) {
318
-            $this->_validate();
319
-            // if it's invalid, we're going to want to re-display so remember what they submitted
320
-            if (! $this->is_valid()) {
321
-                $this->store_submitted_form_data_in_session();
322
-            }
323
-        }
324
-        if ($this->submission_error_message() === '' && ! $this->is_valid()) {
325
-            $this->set_submission_error_message();
326
-        }
327
-        do_action(
328
-            'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
329
-            $req_data,
330
-            $this,
331
-            $validate
332
-        );
333
-    }
334
-
335
-
336
-    /**
337
-     * caches the originally submitted input values in the session
338
-     * so that they can be used to repopulate the form if it failed validation
339
-     *
340
-     * @return boolean whether or not the data was successfully stored in the session
341
-     * @throws InvalidArgumentException
342
-     * @throws InvalidInterfaceException
343
-     * @throws InvalidDataTypeException
344
-     * @throws EE_Error
345
-     */
346
-    protected function store_submitted_form_data_in_session()
347
-    {
348
-        $session = EE_Registry::instance()->SSN;
349
-        if ($session instanceof EE_Session) {
350
-            return EE_Registry::instance()->SSN->set_session_data(
351
-                [
352
-                    EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
353
-                ]
354
-            );
355
-        }
356
-        return false;
357
-    }
358
-
359
-
360
-    /**
361
-     * retrieves the originally submitted input values in the session
362
-     * so that they can be used to repopulate the form if it failed validation
363
-     *
364
-     * @return array
365
-     * @throws InvalidArgumentException
366
-     * @throws InvalidInterfaceException
367
-     * @throws InvalidDataTypeException
368
-     */
369
-    protected function get_submitted_form_data_from_session()
370
-    {
371
-        $session = EE_Registry::instance()->SSN;
372
-        if ($session instanceof EE_Session) {
373
-            return $session->get_session_data(
374
-                EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
375
-            );
376
-        }
377
-        return array();
378
-    }
379
-
380
-
381
-    /**
382
-     * flushed the originally submitted input values from the session
383
-     *
384
-     * @return boolean whether or not the data was successfully removed from the session
385
-     * @throws InvalidArgumentException
386
-     * @throws InvalidInterfaceException
387
-     * @throws InvalidDataTypeException
388
-     */
389
-    public static function flush_submitted_form_data_from_session()
390
-    {
391
-        return EE_Registry::instance()->SSN->reset_data(
392
-            array(EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
393
-        );
394
-    }
395
-
396
-
397
-    /**
398
-     * Populates this form and its subsections with data from the session.
399
-     * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
400
-     * validation errors when displaying too)
401
-     * Returns true if the form was populated from the session, false otherwise
402
-     *
403
-     * @return boolean
404
-     * @throws InvalidArgumentException
405
-     * @throws InvalidInterfaceException
406
-     * @throws InvalidDataTypeException
407
-     * @throws EE_Error
408
-     */
409
-    public function populate_from_session()
410
-    {
411
-        $form_data_in_session = $this->get_submitted_form_data_from_session();
412
-        if (empty($form_data_in_session)) {
413
-            return false;
414
-        }
415
-        $this->receive_form_submission($form_data_in_session);
416
-        add_action('shutdown', array('EE_Form_Section_Proper', 'flush_submitted_form_data_from_session'));
417
-        if ($this->form_data_present_in($form_data_in_session)) {
418
-            return true;
419
-        }
420
-        return false;
421
-    }
422
-
423
-
424
-    /**
425
-     * Populates the default data for the form, given an array where keys are
426
-     * the input names, and values are their values (preferably normalized to be their
427
-     * proper PHP types, not all strings... although that should be ok too).
428
-     * Proper subsections are sub-arrays, the key being the subsection's name, and
429
-     * the value being an array formatted in teh same way
430
-     *
431
-     * @param array $default_data
432
-     * @throws EE_Error
433
-     */
434
-    public function populate_defaults($default_data)
435
-    {
436
-        foreach ($this->subsections(false) as $subsection_name => $subsection) {
437
-            if (isset($default_data[ $subsection_name ])) {
438
-                if ($subsection instanceof EE_Form_Input_Base) {
439
-                    $subsection->set_default($default_data[ $subsection_name ]);
440
-                } elseif ($subsection instanceof EE_Form_Section_Proper) {
441
-                    $subsection->populate_defaults($default_data[ $subsection_name ]);
442
-                }
443
-            }
444
-        }
445
-    }
446
-
447
-
448
-    /**
449
-     * returns true if subsection exists
450
-     *
451
-     * @param string $name
452
-     * @return boolean
453
-     */
454
-    public function subsection_exists($name)
455
-    {
456
-        return isset($this->_subsections[ $name ]) ? true : false;
457
-    }
458
-
459
-
460
-    /**
461
-     * Gets the subsection specified by its name
462
-     *
463
-     * @param string  $name
464
-     * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
465
-     *                                                      so that the inputs will be properly configured.
466
-     *                                                      However, some client code may be ok
467
-     *                                                      with construction finalize being called later
468
-     *                                                      (realizing that the subsections' html names
469
-     *                                                      might not be set yet, etc.)
470
-     * @return EE_Form_Section_Base
471
-     * @throws EE_Error
472
-     */
473
-    public function get_subsection($name, $require_construction_to_be_finalized = true)
474
-    {
475
-        if ($require_construction_to_be_finalized) {
476
-            $this->ensure_construct_finalized_called();
477
-        }
478
-        return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
479
-    }
480
-
481
-
482
-    /**
483
-     * Gets all the validatable subsections of this form section
484
-     *
485
-     * @return EE_Form_Section_Validatable[]
486
-     * @throws EE_Error
487
-     */
488
-    public function get_validatable_subsections()
489
-    {
490
-        $validatable_subsections = array();
491
-        foreach ($this->subsections() as $name => $obj) {
492
-            if ($obj instanceof EE_Form_Section_Validatable) {
493
-                $validatable_subsections[ $name ] = $obj;
494
-            }
495
-        }
496
-        return $validatable_subsections;
497
-    }
498
-
499
-
500
-    /**
501
-     * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
502
-     * throw an EE_Error.
503
-     *
504
-     * @param string  $name
505
-     * @param boolean $require_construction_to_be_finalized most client code should
506
-     *                                                      leave this as TRUE so that the inputs will be properly
507
-     *                                                      configured. However, some client code may be ok with
508
-     *                                                      construction finalize being called later
509
-     *                                                      (realizing that the subsections' html names might not be
510
-     *                                                      set yet, etc.)
511
-     * @return EE_Form_Input_Base
512
-     * @throws EE_Error
513
-     */
514
-    public function get_input($name, $require_construction_to_be_finalized = true)
515
-    {
516
-        $subsection = $this->get_subsection(
517
-            $name,
518
-            $require_construction_to_be_finalized
519
-        );
520
-        if (! $subsection instanceof EE_Form_Input_Base) {
521
-            throw new EE_Error(
522
-                sprintf(
523
-                    esc_html__(
524
-                        "Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
525
-                        'event_espresso'
526
-                    ),
527
-                    $name,
528
-                    get_class($this),
529
-                    $subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
530
-                )
531
-            );
532
-        }
533
-        return $subsection;
534
-    }
535
-
536
-
537
-    /**
538
-     * Like get_input(), gets the proper subsection of the form given the name,
539
-     * otherwise throws an EE_Error
540
-     *
541
-     * @param string  $name
542
-     * @param boolean $require_construction_to_be_finalized most client code should
543
-     *                                                      leave this as TRUE so that the inputs will be properly
544
-     *                                                      configured. However, some client code may be ok with
545
-     *                                                      construction finalize being called later
546
-     *                                                      (realizing that the subsections' html names might not be
547
-     *                                                      set yet, etc.)
548
-     * @return EE_Form_Section_Proper
549
-     * @throws EE_Error
550
-     */
551
-    public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
552
-    {
553
-        $subsection = $this->get_subsection(
554
-            $name,
555
-            $require_construction_to_be_finalized
556
-        );
557
-        if (! $subsection instanceof EE_Form_Section_Proper) {
558
-            throw new EE_Error(
559
-                sprintf(
560
-                    esc_html__(
561
-                        "Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'",
562
-                        'event_espresso'
563
-                    ),
564
-                    $name,
565
-                    get_class($this)
566
-                )
567
-            );
568
-        }
569
-        return $subsection;
570
-    }
571
-
572
-
573
-    /**
574
-     * Gets the value of the specified input. Should be called after receive_form_submission()
575
-     * or populate_defaults() on the form, where the normalized value on the input is set.
576
-     *
577
-     * @param string $name
578
-     * @return mixed depending on the input's type and its normalization strategy
579
-     * @throws EE_Error
580
-     */
581
-    public function get_input_value($name)
582
-    {
583
-        $input = $this->get_input($name);
584
-        return $input->normalized_value();
585
-    }
586
-
587
-
588
-    /**
589
-     * Checks if this form section itself is valid, and then checks its subsections
590
-     *
591
-     * @throws EE_Error
592
-     * @return boolean
593
-     */
594
-    public function is_valid()
595
-    {
596
-        if ($this->is_valid === null) {
597
-            if (! $this->has_received_submission()) {
598
-                throw new EE_Error(
599
-                    sprintf(
600
-                        esc_html__(
601
-                            'You cannot check if a form is valid before receiving the form submission using receive_form_submission',
602
-                            'event_espresso'
603
-                        )
604
-                    )
605
-                );
606
-            }
607
-            if (! parent::is_valid()) {
608
-                $this->is_valid = false;
609
-            } else {
610
-                // ok so no general errors to this entire form section.
611
-                // so let's check the subsections, but only set errors if that hasn't been done yet
612
-                $this->is_valid = true;
613
-                foreach ($this->get_validatable_subsections() as $subsection) {
614
-                    if (! $subsection->is_valid()) {
615
-                        $this->is_valid = false;
616
-                    }
617
-                }
618
-            }
619
-        }
620
-        return $this->is_valid;
621
-    }
622
-
623
-
624
-    /**
625
-     * gets the default name of this form section if none is specified
626
-     *
627
-     * @return void
628
-     */
629
-    protected function _set_default_name_if_empty()
630
-    {
631
-        if (! $this->_name) {
632
-            $classname    = get_class($this);
633
-            $default_name = str_replace('EE_', '', $classname);
634
-            $this->_name  = $default_name;
635
-        }
636
-    }
637
-
638
-
639
-    /**
640
-     * Returns the HTML for the form, except for the form opening and closing tags
641
-     * (as the form section doesn't know where you necessarily want to send the information to),
642
-     * and except for a submit button. Enqueues JS and CSS; if called early enough we will
643
-     * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
644
-     * Not doing_it_wrong because theoretically this CAN be used properly,
645
-     * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
646
-     * any CSS.
647
-     *
648
-     * @throws InvalidArgumentException
649
-     * @throws InvalidInterfaceException
650
-     * @throws InvalidDataTypeException
651
-     * @throws EE_Error
652
-     */
653
-    public function get_html_and_js()
654
-    {
655
-        $this->enqueue_js();
656
-        return $this->get_html();
657
-    }
658
-
659
-
660
-    /**
661
-     * returns HTML for displaying this form section. recursively calls display_section() on all subsections
662
-     *
663
-     * @param bool $display_previously_submitted_data
664
-     * @return string
665
-     * @throws InvalidArgumentException
666
-     * @throws InvalidInterfaceException
667
-     * @throws InvalidDataTypeException
668
-     * @throws EE_Error
669
-     * @throws EE_Error
670
-     * @throws EE_Error
671
-     */
672
-    public function get_html($display_previously_submitted_data = true)
673
-    {
674
-        $this->ensure_construct_finalized_called();
675
-        if ($display_previously_submitted_data) {
676
-            $this->populate_from_session();
677
-        }
678
-        return $this->_form_html_filter
679
-            ? $this->_form_html_filter->filterHtml($this->_layout_strategy->layout_form(), $this)
680
-            : $this->_layout_strategy->layout_form();
681
-    }
682
-
683
-
684
-    /**
685
-     * enqueues JS and CSS for the form.
686
-     * It is preferred to call this before wp_enqueue_scripts so the
687
-     * scripts and styles can be put in the header, but if called later
688
-     * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
689
-     * only be in the header; but in HTML5 its ok in the body.
690
-     * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
691
-     * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
692
-     *
693
-     * @return void
694
-     * @throws EE_Error
695
-     */
696
-    public function enqueue_js()
697
-    {
698
-        $this->_enqueue_and_localize_form_js();
699
-        foreach ($this->subsections() as $subsection) {
700
-            $subsection->enqueue_js();
701
-        }
702
-    }
703
-
704
-
705
-    /**
706
-     * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
707
-     * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
708
-     * the wp_enqueue_scripts hook.
709
-     * However, registering the form js and localizing it can happen when we
710
-     * actually output the form (which is preferred, seeing how teh form's fields
711
-     * could change until it's actually outputted)
712
-     *
713
-     * @param boolean $init_form_validation_automatically whether or not we want the form validation
714
-     *                                                    to be triggered automatically or not
715
-     * @return void
716
-     */
717
-    public static function wp_enqueue_scripts($init_form_validation_automatically = true)
718
-    {
719
-        wp_register_script(
720
-            'ee_form_section_validation',
721
-            EE_GLOBAL_ASSETS_URL . 'scripts' . '/form_section_validation.js',
722
-            array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
723
-            EVENT_ESPRESSO_VERSION,
724
-            true
725
-        );
726
-        wp_localize_script(
727
-            'ee_form_section_validation',
728
-            'ee_form_section_validation_init',
729
-            array('init' => $init_form_validation_automatically ? '1' : '0')
730
-        );
731
-    }
732
-
733
-
734
-    /**
735
-     * gets the variables used by form_section_validation.js.
736
-     * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
737
-     * but before the wordpress hook wp_loaded
738
-     *
739
-     * @throws EE_Error
740
-     */
741
-    public function _enqueue_and_localize_form_js()
742
-    {
743
-        $this->ensure_construct_finalized_called();
744
-        // actually, we don't want to localize just yet. There may be other forms on the page.
745
-        // so we need to add our form section data to a static variable accessible by all form sections
746
-        // and localize it just before the footer
747
-        $this->localize_validation_rules();
748
-        add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
749
-        add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
750
-    }
751
-
752
-
753
-    /**
754
-     * add our form section data to a static variable accessible by all form sections
755
-     *
756
-     * @param bool $return_for_subsection
757
-     * @return void
758
-     * @throws EE_Error
759
-     */
760
-    public function localize_validation_rules($return_for_subsection = false)
761
-    {
762
-        // we only want to localize vars ONCE for the entire form,
763
-        // so if the form section doesn't have a parent, then it must be the top dog
764
-        if ($return_for_subsection || ! $this->parent_section()) {
765
-            EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
766
-                'form_section_id'  => $this->html_id(true),
767
-                'validation_rules' => $this->get_jquery_validation_rules(),
768
-                'other_data'       => $this->get_other_js_data(),
769
-                'errors'           => $this->subsection_validation_errors_by_html_name(),
770
-            );
771
-            EE_Form_Section_Proper::$_scripts_localized                                = true;
772
-        }
773
-    }
774
-
775
-
776
-    /**
777
-     * Gets an array of extra data that will be useful for client-side javascript.
778
-     * This is primarily data added by inputs and forms in addition to any
779
-     * scripts they might enqueue
780
-     *
781
-     * @param array $form_other_js_data
782
-     * @return array
783
-     * @throws EE_Error
784
-     */
785
-    public function get_other_js_data($form_other_js_data = array())
786
-    {
787
-        foreach ($this->subsections() as $subsection) {
788
-            $form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
789
-        }
790
-        return $form_other_js_data;
791
-    }
792
-
793
-
794
-    /**
795
-     * Gets a flat array of inputs for this form section and its subsections.
796
-     * Keys are their form names, and values are the inputs themselves
797
-     *
798
-     * @return EE_Form_Input_Base
799
-     * @throws EE_Error
800
-     */
801
-    public function inputs_in_subsections()
802
-    {
803
-        $inputs = array();
804
-        foreach ($this->subsections() as $subsection) {
805
-            if ($subsection instanceof EE_Form_Input_Base) {
806
-                $inputs[ $subsection->html_name() ] = $subsection;
807
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
808
-                $inputs += $subsection->inputs_in_subsections();
809
-            }
810
-        }
811
-        return $inputs;
812
-    }
813
-
814
-
815
-    /**
816
-     * Gets a flat array of all the validation errors.
817
-     * Keys are html names (because those should be unique)
818
-     * and values are a string of all their validation errors
819
-     *
820
-     * @return string[]
821
-     * @throws EE_Error
822
-     */
823
-    public function subsection_validation_errors_by_html_name()
824
-    {
825
-        $inputs = $this->inputs();
826
-        $errors = array();
827
-        foreach ($inputs as $form_input) {
828
-            if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
829
-                $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
830
-            }
831
-        }
832
-        return $errors;
833
-    }
834
-
835
-
836
-    /**
837
-     * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
838
-     * Should be setup by each form during the _enqueues_and_localize_form_js
839
-     *
840
-     * @throws InvalidArgumentException
841
-     * @throws InvalidInterfaceException
842
-     * @throws InvalidDataTypeException
843
-     */
844
-    public static function localize_script_for_all_forms()
845
-    {
846
-        // allow inputs and stuff to hook in their JS and stuff here
847
-        do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
848
-        EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
849
-        $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
850
-            ? EE_Registry::instance()->CFG->registration->email_validation_level
851
-            : 'wp_default';
852
-        EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
853
-        wp_enqueue_script('ee_form_section_validation');
854
-        wp_localize_script(
855
-            'ee_form_section_validation',
856
-            'ee_form_section_vars',
857
-            EE_Form_Section_Proper::$_js_localization
858
-        );
859
-    }
860
-
861
-
862
-    /**
863
-     * ensure_scripts_localized
864
-     *
865
-     * @throws EE_Error
866
-     */
867
-    public function ensure_scripts_localized()
868
-    {
869
-        if (! EE_Form_Section_Proper::$_scripts_localized) {
870
-            $this->_enqueue_and_localize_form_js();
871
-        }
872
-    }
873
-
874
-
875
-    /**
876
-     * Gets the hard-coded validation error messages to be used in the JS. The convention
877
-     * is that the key here should be the same as the custom validation rule put in the JS file
878
-     *
879
-     * @return array keys are custom validation rules, and values are internationalized strings
880
-     */
881
-    private static function _get_localized_error_messages()
882
-    {
883
-        return array(
884
-            'validUrl' => wp_strip_all_tags(__('This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg', 'event_espresso')),
885
-            'regex'    => wp_strip_all_tags(__('Please check your input', 'event_espresso'))
886
-        );
887
-    }
888
-
889
-
890
-    /**
891
-     * @return array
892
-     */
893
-    public static function js_localization()
894
-    {
895
-        return self::$_js_localization;
896
-    }
897
-
898
-
899
-    /**
900
-     * @return void
901
-     */
902
-    public static function reset_js_localization()
903
-    {
904
-        self::$_js_localization = array();
905
-    }
906
-
907
-
908
-    /**
909
-     * Gets the JS to put inside the jquery validation rules for subsection of this form section.
910
-     * See parent function for more...
911
-     *
912
-     * @return array
913
-     * @throws EE_Error
914
-     */
915
-    public function get_jquery_validation_rules()
916
-    {
917
-        $jquery_validation_rules = array();
918
-        foreach ($this->get_validatable_subsections() as $subsection) {
919
-            $jquery_validation_rules = array_merge(
920
-                $jquery_validation_rules,
921
-                $subsection->get_jquery_validation_rules()
922
-            );
923
-        }
924
-        return $jquery_validation_rules;
925
-    }
926
-
927
-
928
-    /**
929
-     * Sanitizes all the data and sets the sanitized value of each field
930
-     *
931
-     * @param array $req_data
932
-     * @return void
933
-     * @throws EE_Error
934
-     */
935
-    protected function _normalize($req_data)
936
-    {
937
-        $this->_received_submission = true;
938
-        $this->_validation_errors   = array();
939
-        foreach ($this->get_validatable_subsections() as $subsection) {
940
-            try {
941
-                $subsection->_normalize($req_data);
942
-            } catch (EE_Validation_Error $e) {
943
-                $subsection->add_validation_error($e);
944
-            }
945
-        }
946
-    }
947
-
948
-
949
-    /**
950
-     * Performs validation on this form section and its subsections.
951
-     * For each subsection,
952
-     * calls _validate_{subsection_name} on THIS form (if the function exists)
953
-     * and passes it the subsection, then calls _validate on that subsection.
954
-     * If you need to perform validation on the form as a whole (considering multiple)
955
-     * you would be best to override this _validate method,
956
-     * calling parent::_validate() first.
957
-     *
958
-     * @throws EE_Error
959
-     */
960
-    protected function _validate()
961
-    {
962
-        // reset the cache of whether this form is valid or not- we're re-validating it now
963
-        $this->is_valid = null;
964
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
965
-            if (method_exists($this, '_validate_' . $subsection_name)) {
966
-                call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
967
-            }
968
-            $subsection->_validate();
969
-        }
970
-    }
971
-
972
-
973
-    /**
974
-     * Gets all the validated inputs for the form section
975
-     *
976
-     * @return array
977
-     * @throws EE_Error
978
-     */
979
-    public function valid_data()
980
-    {
981
-        $inputs = array();
982
-        foreach ($this->subsections() as $subsection_name => $subsection) {
983
-            if ($subsection instanceof EE_Form_Section_Proper) {
984
-                $inputs[ $subsection_name ] = $subsection->valid_data();
985
-            } elseif ($subsection instanceof EE_Form_Input_Base) {
986
-                $inputs[ $subsection_name ] = $subsection->normalized_value();
987
-            }
988
-        }
989
-        return $inputs;
990
-    }
991
-
992
-
993
-    /**
994
-     * Gets all the inputs on this form section
995
-     *
996
-     * @return EE_Form_Input_Base[]
997
-     * @throws EE_Error
998
-     */
999
-    public function inputs()
1000
-    {
1001
-        $inputs = array();
1002
-        foreach ($this->subsections() as $subsection_name => $subsection) {
1003
-            if ($subsection instanceof EE_Form_Input_Base) {
1004
-                $inputs[ $subsection_name ] = $subsection;
1005
-            }
1006
-        }
1007
-        return $inputs;
1008
-    }
1009
-
1010
-
1011
-    /**
1012
-     * Gets all the subsections which are a proper form
1013
-     *
1014
-     * @return EE_Form_Section_Proper[]
1015
-     * @throws EE_Error
1016
-     */
1017
-    public function subforms()
1018
-    {
1019
-        $form_sections = array();
1020
-        foreach ($this->subsections() as $name => $obj) {
1021
-            if ($obj instanceof EE_Form_Section_Proper) {
1022
-                $form_sections[ $name ] = $obj;
1023
-            }
1024
-        }
1025
-        return $form_sections;
1026
-    }
1027
-
1028
-
1029
-    /**
1030
-     * Gets all the subsections (inputs, proper subsections, or html-only sections).
1031
-     * Consider using inputs() or subforms()
1032
-     * if you only want form inputs or proper form sections.
1033
-     *
1034
-     * @param boolean $require_construction_to_be_finalized most client code should
1035
-     *                                                      leave this as TRUE so that the inputs will be properly
1036
-     *                                                      configured. However, some client code may be ok with
1037
-     *                                                      construction finalize being called later
1038
-     *                                                      (realizing that the subsections' html names might not be
1039
-     *                                                      set yet, etc.)
1040
-     * @return EE_Form_Section_Proper[]
1041
-     * @throws EE_Error
1042
-     */
1043
-    public function subsections($require_construction_to_be_finalized = true)
1044
-    {
1045
-        if ($require_construction_to_be_finalized) {
1046
-            $this->ensure_construct_finalized_called();
1047
-        }
1048
-        return $this->_subsections;
1049
-    }
1050
-
1051
-
1052
-    /**
1053
-     * Returns whether this form has any subforms or inputs
1054
-     * @return bool
1055
-     */
1056
-    public function hasSubsections()
1057
-    {
1058
-        return ! empty($this->_subsections);
1059
-    }
1060
-
1061
-
1062
-    /**
1063
-     * Returns a simple array where keys are input names, and values are their normalized
1064
-     * values. (Similar to calling get_input_value on inputs)
1065
-     *
1066
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1067
-     *                                        or just this forms' direct children inputs
1068
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1069
-     *                                        or allow multidimensional array
1070
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
1071
-     *                                        with array keys being input names
1072
-     *                                        (regardless of whether they are from a subsection or not),
1073
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1074
-     *                                        where keys are always subsection names and values are either
1075
-     *                                        the input's normalized value, or an array like the top-level array
1076
-     * @throws EE_Error
1077
-     */
1078
-    public function input_values($include_subform_inputs = false, $flatten = false)
1079
-    {
1080
-        return $this->_input_values(false, $include_subform_inputs, $flatten);
1081
-    }
1082
-
1083
-
1084
-    /**
1085
-     * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
1086
-     * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
1087
-     * is not necessarily the value we want to display to users. This creates an array
1088
-     * where keys are the input names, and values are their display values
1089
-     *
1090
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1091
-     *                                        or just this forms' direct children inputs
1092
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1093
-     *                                        or allow multidimensional array
1094
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
1095
-     *                                        with array keys being input names
1096
-     *                                        (regardless of whether they are from a subsection or not),
1097
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1098
-     *                                        where keys are always subsection names and values are either
1099
-     *                                        the input's normalized value, or an array like the top-level array
1100
-     * @throws EE_Error
1101
-     */
1102
-    public function input_pretty_values($include_subform_inputs = false, $flatten = false)
1103
-    {
1104
-        return $this->_input_values(true, $include_subform_inputs, $flatten);
1105
-    }
1106
-
1107
-
1108
-    /**
1109
-     * Gets the input values from the form
1110
-     *
1111
-     * @param boolean $pretty                 Whether to retrieve the pretty value,
1112
-     *                                        or just the normalized value
1113
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1114
-     *                                        or just this forms' direct children inputs
1115
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1116
-     *                                        or allow multidimensional array
1117
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
1118
-     *                                        input names (regardless of whether they are from a subsection or not),
1119
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1120
-     *                                        where keys are always subsection names and values are either
1121
-     *                                        the input's normalized value, or an array like the top-level array
1122
-     * @throws EE_Error
1123
-     */
1124
-    public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
1125
-    {
1126
-        $input_values = array();
1127
-        foreach ($this->subsections() as $subsection_name => $subsection) {
1128
-            if ($subsection instanceof EE_Form_Input_Base) {
1129
-                $input_values[ $subsection_name ] = $pretty
1130
-                    ? $subsection->pretty_value()
1131
-                    : $subsection->normalized_value();
1132
-            } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1133
-                $subform_input_values = $subsection->_input_values(
1134
-                    $pretty,
1135
-                    $include_subform_inputs,
1136
-                    $flatten
1137
-                );
1138
-                if ($flatten) {
1139
-                    $input_values = array_merge($input_values, $subform_input_values);
1140
-                } else {
1141
-                    $input_values[ $subsection_name ] = $subform_input_values;
1142
-                }
1143
-            }
1144
-        }
1145
-        return $input_values;
1146
-    }
1147
-
1148
-
1149
-    /**
1150
-     * Gets the originally submitted input values from the form
1151
-     *
1152
-     * @param boolean $include_subforms  Whether to include inputs from subforms,
1153
-     *                                   or just this forms' direct children inputs
1154
-     * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1155
-     *                                   with array keys being input names
1156
-     *                                   (regardless of whether they are from a subsection or not),
1157
-     *                                   and if $flatten is FALSE it can be a multidimensional array
1158
-     *                                   where keys are always subsection names and values are either
1159
-     *                                   the input's normalized value, or an array like the top-level array
1160
-     * @throws EE_Error
1161
-     */
1162
-    public function submitted_values($include_subforms = false)
1163
-    {
1164
-        $submitted_values = array();
1165
-        foreach ($this->subsections() as $subsection) {
1166
-            if ($subsection instanceof EE_Form_Input_Base) {
1167
-                // is this input part of an array of inputs?
1168
-                if (strpos($subsection->html_name(), '[') !== false) {
1169
-                    $full_input_name  = EEH_Array::convert_array_values_to_keys(
1170
-                        explode(
1171
-                            '[',
1172
-                            str_replace(']', '', $subsection->html_name())
1173
-                        ),
1174
-                        $subsection->raw_value()
1175
-                    );
1176
-                    $submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1177
-                } else {
1178
-                    $submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1179
-                }
1180
-            } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1181
-                $subform_input_values = $subsection->submitted_values($include_subforms);
1182
-                $submitted_values     = array_replace_recursive($submitted_values, $subform_input_values);
1183
-            }
1184
-        }
1185
-        return $submitted_values;
1186
-    }
1187
-
1188
-
1189
-    /**
1190
-     * Indicates whether or not this form has received a submission yet
1191
-     * (ie, had receive_form_submission called on it yet)
1192
-     *
1193
-     * @return boolean
1194
-     * @throws EE_Error
1195
-     */
1196
-    public function has_received_submission()
1197
-    {
1198
-        $this->ensure_construct_finalized_called();
1199
-        return $this->_received_submission;
1200
-    }
1201
-
1202
-
1203
-    /**
1204
-     * Equivalent to passing 'exclude' in the constructor's options array.
1205
-     * Removes the listed inputs from the form
1206
-     *
1207
-     * @param array $inputs_to_exclude values are the input names
1208
-     * @return void
1209
-     */
1210
-    public function exclude(array $inputs_to_exclude = array())
1211
-    {
1212
-        foreach ($inputs_to_exclude as $input_to_exclude_name) {
1213
-            unset($this->_subsections[ $input_to_exclude_name ]);
1214
-        }
1215
-    }
1216
-
1217
-
1218
-    /**
1219
-     * Changes these inputs' display strategy to be EE_Hidden_Display_Strategy.
1220
-     * @param array $inputs_to_hide
1221
-     * @throws EE_Error
1222
-     */
1223
-    public function hide(array $inputs_to_hide = array())
1224
-    {
1225
-        foreach ($inputs_to_hide as $input_to_hide) {
1226
-            $input = $this->get_input($input_to_hide);
1227
-            $input->set_display_strategy(new EE_Hidden_Display_Strategy());
1228
-        }
1229
-    }
1230
-
1231
-
1232
-    /**
1233
-     * add_subsections
1234
-     * Adds the listed subsections to the form section.
1235
-     * If $subsection_name_to_target is provided,
1236
-     * then new subsections are added before or after that subsection,
1237
-     * otherwise to the start or end of the entire subsections array.
1238
-     *
1239
-     * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1240
-     *                                                          where keys are their names
1241
-     * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1242
-     *                                                          should be added before or after
1243
-     *                                                          IF $subsection_name_to_target is null,
1244
-     *                                                          then $new_subsections will be added to
1245
-     *                                                          the beginning or end of the entire subsections array
1246
-     * @param boolean                $add_before                whether to add $new_subsections, before or after
1247
-     *                                                          $subsection_name_to_target,
1248
-     *                                                          or if $subsection_name_to_target is null,
1249
-     *                                                          before or after entire subsections array
1250
-     * @return void
1251
-     * @throws EE_Error
1252
-     */
1253
-    public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1254
-    {
1255
-        foreach ($new_subsections as $subsection_name => $subsection) {
1256
-            if (! $subsection instanceof EE_Form_Section_Base) {
1257
-                EE_Error::add_error(
1258
-                    sprintf(
1259
-                        esc_html__(
1260
-                            "Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1261
-                            'event_espresso'
1262
-                        ),
1263
-                        get_class($subsection),
1264
-                        $subsection_name,
1265
-                        $this->name()
1266
-                    )
1267
-                );
1268
-                unset($new_subsections[ $subsection_name ]);
1269
-            }
1270
-        }
1271
-        $this->_subsections = EEH_Array::insert_into_array(
1272
-            $this->_subsections,
1273
-            $new_subsections,
1274
-            $subsection_name_to_target,
1275
-            $add_before
1276
-        );
1277
-        if ($this->_construction_finalized) {
1278
-            foreach ($this->_subsections as $name => $subsection) {
1279
-                $subsection->_construct_finalize($this, $name);
1280
-            }
1281
-        }
1282
-    }
1283
-
1284
-
1285
-    /**
1286
-     * @param string $subsection_name
1287
-     * @param bool   $recursive
1288
-     * @return bool
1289
-     */
1290
-    public function has_subsection($subsection_name, $recursive = false)
1291
-    {
1292
-        foreach ($this->_subsections as $name => $subsection) {
1293
-            if (
1294
-                $name === $subsection_name
1295
-                || (
1296
-                    $recursive
1297
-                    && $subsection instanceof EE_Form_Section_Proper
1298
-                    && $subsection->has_subsection($subsection_name, $recursive)
1299
-                )
1300
-            ) {
1301
-                return true;
1302
-            }
1303
-        }
1304
-        return false;
1305
-    }
1306
-
1307
-
1308
-
1309
-    /**
1310
-     * Just gets all validatable subsections to clean their sensitive data
1311
-     *
1312
-     * @throws EE_Error
1313
-     */
1314
-    public function clean_sensitive_data()
1315
-    {
1316
-        foreach ($this->get_validatable_subsections() as $subsection) {
1317
-            $subsection->clean_sensitive_data();
1318
-        }
1319
-    }
1320
-
1321
-
1322
-    /**
1323
-     * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1324
-     * @param string                           $form_submission_error_message
1325
-     * @param EE_Form_Section_Validatable $form_section unused
1326
-     * @throws EE_Error
1327
-     */
1328
-    public function set_submission_error_message(
1329
-        $form_submission_error_message = ''
1330
-    ) {
1331
-        $this->_form_submission_error_message = ! empty($form_submission_error_message)
1332
-            ? $form_submission_error_message
1333
-            : $this->getAllValidationErrorsString();
1334
-    }
1335
-
1336
-
1337
-    /**
1338
-     * Returns the cached error message. A default value is set for this during _validate(),
1339
-     * (called during receive_form_submission) but it can be explicitly set using
1340
-     * set_submission_error_message
1341
-     *
1342
-     * @return string
1343
-     */
1344
-    public function submission_error_message()
1345
-    {
1346
-        return $this->_form_submission_error_message;
1347
-    }
1348
-
1349
-
1350
-    /**
1351
-     * Sets a message to display if the data submitted to the form was valid.
1352
-     * @param string $form_submission_success_message
1353
-     */
1354
-    public function set_submission_success_message($form_submission_success_message = '')
1355
-    {
1356
-        $this->_form_submission_success_message = ! empty($form_submission_success_message)
1357
-            ? $form_submission_success_message
1358
-            : esc_html__('Form submitted successfully', 'event_espresso');
1359
-    }
1360
-
1361
-
1362
-    /**
1363
-     * Gets a message appropriate for display when the form is correctly submitted
1364
-     * @return string
1365
-     */
1366
-    public function submission_success_message()
1367
-    {
1368
-        return $this->_form_submission_success_message;
1369
-    }
1370
-
1371
-
1372
-    /**
1373
-     * Returns the prefix that should be used on child of this form section for
1374
-     * their html names. If this form section itself has a parent, prepends ITS
1375
-     * prefix onto this form section's prefix. Used primarily by
1376
-     * EE_Form_Input_Base::_set_default_html_name_if_empty
1377
-     *
1378
-     * @return string
1379
-     * @throws EE_Error
1380
-     */
1381
-    public function html_name_prefix()
1382
-    {
1383
-        if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1384
-            return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1385
-        }
1386
-        return $this->name();
1387
-    }
1388
-
1389
-
1390
-    /**
1391
-     * Gets the name, but first checks _construct_finalize has been called. If not,
1392
-     * calls it (assumes there is no parent and that we want the name to be whatever
1393
-     * was set, which is probably nothing, or the classname)
1394
-     *
1395
-     * @return string
1396
-     * @throws EE_Error
1397
-     */
1398
-    public function name()
1399
-    {
1400
-        $this->ensure_construct_finalized_called();
1401
-        return parent::name();
1402
-    }
1403
-
1404
-
1405
-    /**
1406
-     * @return EE_Form_Section_Proper
1407
-     * @throws EE_Error
1408
-     */
1409
-    public function parent_section()
1410
-    {
1411
-        $this->ensure_construct_finalized_called();
1412
-        return parent::parent_section();
1413
-    }
1414
-
1415
-
1416
-    /**
1417
-     * make sure construction finalized was called, otherwise children might not be ready
1418
-     *
1419
-     * @return void
1420
-     * @throws EE_Error
1421
-     */
1422
-    public function ensure_construct_finalized_called()
1423
-    {
1424
-        if (! $this->_construction_finalized) {
1425
-            $this->_construct_finalize($this->_parent_section, $this->_name);
1426
-        }
1427
-    }
1428
-
1429
-
1430
-    /**
1431
-     * Checks if any of this form section's inputs, or any of its children's inputs,
1432
-     * are in teh form data. If any are found, returns true. Else false
1433
-     *
1434
-     * @param array $req_data
1435
-     * @return boolean
1436
-     * @throws EE_Error
1437
-     */
1438
-    public function form_data_present_in($req_data = null)
1439
-    {
1440
-        $req_data = $this->getCachedRequest($req_data);
1441
-        foreach ($this->subsections() as $subsection) {
1442
-            if ($subsection instanceof EE_Form_Input_Base) {
1443
-                if ($subsection->form_data_present_in($req_data)) {
1444
-                    return true;
1445
-                }
1446
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
1447
-                if ($subsection->form_data_present_in($req_data)) {
1448
-                    return true;
1449
-                }
1450
-            }
1451
-        }
1452
-        return false;
1453
-    }
1454
-
1455
-
1456
-    /**
1457
-     * Gets validation errors for this form section and subsections
1458
-     * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1459
-     * gets the validation errors for ALL subsection
1460
-     *
1461
-     * @return EE_Validation_Error[]
1462
-     * @throws EE_Error
1463
-     */
1464
-    public function get_validation_errors_accumulated()
1465
-    {
1466
-        $validation_errors = $this->get_validation_errors();
1467
-        foreach ($this->get_validatable_subsections() as $subsection) {
1468
-            if ($subsection instanceof EE_Form_Section_Proper) {
1469
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1470
-            } else {
1471
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors();
1472
-            }
1473
-            if ($validation_errors_on_this_subsection) {
1474
-                $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1475
-            }
1476
-        }
1477
-        return $validation_errors;
1478
-    }
1479
-
1480
-    /**
1481
-     * Fetch validation errors from children and grandchildren and puts them in a single string.
1482
-     * This traverses the form section tree to generate this, but you probably want to instead use
1483
-     * get_form_submission_error_message() which is usually this message cached (or a custom validation error message)
1484
-     *
1485
-     * @return string
1486
-     * @since 4.9.59.p
1487
-     */
1488
-    protected function getAllValidationErrorsString()
1489
-    {
1490
-        $submission_error_messages = array();
1491
-        // bad, bad, bad registrant
1492
-        foreach ($this->get_validation_errors_accumulated() as $validation_error) {
1493
-            if ($validation_error instanceof EE_Validation_Error) {
1494
-                $form_section = $validation_error->get_form_section();
1495
-                if ($form_section instanceof EE_Form_Input_Base) {
1496
-                    $label = $validation_error->get_form_section()->html_label_text();
1497
-                } elseif ($form_section instanceof EE_Form_Section_Validatable) {
1498
-                    $label = $validation_error->get_form_section()->name();
1499
-                } else {
1500
-                    $label = esc_html__('Unknown', 'event_espresso');
1501
-                }
1502
-                $submission_error_messages[] = sprintf(
1503
-                    esc_html__('%s : %s', 'event_espresso'),
1504
-                    $label,
1505
-                    $validation_error->getMessage()
1506
-                );
1507
-            }
1508
-        }
1509
-        return implode('<br>', $submission_error_messages);
1510
-    }
1511
-
1512
-
1513
-    /**
1514
-     * This isn't just the name of an input, it's a path pointing to an input. The
1515
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
1516
-     * dot-dot-slash (../) means to ascend into the parent section.
1517
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1518
-     * which will be returned.
1519
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1520
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1521
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1522
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1523
-     * Etc
1524
-     *
1525
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1526
-     * @return EE_Form_Section_Base
1527
-     * @throws EE_Error
1528
-     */
1529
-    public function find_section_from_path($form_section_path)
1530
-    {
1531
-        // check if we can find the input from purely going straight up the tree
1532
-        $input = parent::find_section_from_path($form_section_path);
1533
-        if ($input instanceof EE_Form_Section_Base) {
1534
-            return $input;
1535
-        }
1536
-        $next_slash_pos = strpos($form_section_path, '/');
1537
-        if ($next_slash_pos !== false) {
1538
-            $child_section_name = substr($form_section_path, 0, $next_slash_pos);
1539
-            $subpath            = substr($form_section_path, $next_slash_pos + 1);
1540
-        } else {
1541
-            $child_section_name = $form_section_path;
1542
-            $subpath            = '';
1543
-        }
1544
-        $child_section = $this->get_subsection($child_section_name);
1545
-        if ($child_section instanceof EE_Form_Section_Base) {
1546
-            return $child_section->find_section_from_path($subpath);
1547
-        }
1548
-        return null;
1549
-    }
18
+	const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
19
+
20
+	/**
21
+	 * Subsections
22
+	 *
23
+	 * @var EE_Form_Section_Validatable[]
24
+	 */
25
+	protected $_subsections = array();
26
+
27
+	/**
28
+	 * Strategy for laying out the form
29
+	 *
30
+	 * @var EE_Form_Section_Layout_Base
31
+	 */
32
+	protected $_layout_strategy;
33
+
34
+	/**
35
+	 * Whether or not this form has received and validated a form submission yet
36
+	 *
37
+	 * @var boolean
38
+	 */
39
+	protected $_received_submission = false;
40
+
41
+	/**
42
+	 * message displayed to users upon successful form submission
43
+	 *
44
+	 * @var string
45
+	 */
46
+	protected $_form_submission_success_message = '';
47
+
48
+	/**
49
+	 * message displayed to users upon unsuccessful form submission
50
+	 *
51
+	 * @var string
52
+	 */
53
+	protected $_form_submission_error_message = '';
54
+
55
+	/**
56
+	 * @var array like post / request
57
+	 */
58
+	protected $cached_request_data;
59
+
60
+	/**
61
+	 * Stores whether this form (and its sub-sections) were found to be valid or not.
62
+	 * Starts off as null, but once the form is validated, it set to either true or false
63
+	 * @var boolean|null
64
+	 */
65
+	protected $is_valid;
66
+
67
+	/**
68
+	 * Stores all the data that will localized for form validation
69
+	 *
70
+	 * @var array
71
+	 */
72
+	protected static $_js_localization = array();
73
+
74
+	/**
75
+	 * whether or not the form's localized validation JS vars have been set
76
+	 *
77
+	 * @type boolean
78
+	 */
79
+	protected static $_scripts_localized = false;
80
+
81
+
82
+	/**
83
+	 * when constructing a proper form section, calls _construct_finalize on children
84
+	 * so that they know who their parent is, and what name they've been given.
85
+	 *
86
+	 * @param array[] $options_array   {
87
+	 * @type          $subsections     EE_Form_Section_Validatable[] where keys are the section's name
88
+	 * @type          $include         string[] numerically-indexed where values are section names to be included,
89
+	 *                                 and in that order. This is handy if you want
90
+	 *                                 the subsections to be ordered differently than the default, and if you override
91
+	 *                                 which fields are shown
92
+	 * @type          $exclude         string[] values are subsections to be excluded. This is handy if you want
93
+	 *                                 to remove certain default subsections (note: if you specify BOTH 'include' AND
94
+	 *                                 'exclude', the inclusions will be applied first, and the exclusions will exclude
95
+	 *                                 items from that list of inclusions)
96
+	 * @type          $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
97
+	 *                                 } @see EE_Form_Section_Validatable::__construct()
98
+	 * @throws EE_Error
99
+	 */
100
+	public function __construct($options_array = array())
101
+	{
102
+		$options_array = (array) apply_filters(
103
+			'FHEE__EE_Form_Section_Proper___construct__options_array',
104
+			$options_array,
105
+			$this
106
+		);
107
+		// call parent first, as it may be setting the name
108
+		parent::__construct($options_array);
109
+		// if they've included subsections in the constructor, add them now
110
+		if (isset($options_array['include'])) {
111
+			// we are going to make sure we ONLY have those subsections to include
112
+			// AND we are going to make sure they're in that specified order
113
+			$reordered_subsections = array();
114
+			foreach ($options_array['include'] as $input_name) {
115
+				if (isset($this->_subsections[ $input_name ])) {
116
+					$reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
117
+				}
118
+			}
119
+			$this->_subsections = $reordered_subsections;
120
+		}
121
+		if (isset($options_array['exclude'])) {
122
+			$exclude            = $options_array['exclude'];
123
+			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
124
+		}
125
+		if (isset($options_array['layout_strategy'])) {
126
+			$this->_layout_strategy = $options_array['layout_strategy'];
127
+		}
128
+		if (! $this->_layout_strategy) {
129
+			$this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
130
+		}
131
+		$this->_layout_strategy->_construct_finalize($this);
132
+		// ok so we are definitely going to want the forms JS,
133
+		// so enqueue it or remember to enqueue it during wp_enqueue_scripts
134
+		if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
135
+			// ok so they've constructed this object after when they should have.
136
+			// just enqueue the generic form scripts and initialize the form immediately in the JS
137
+			EE_Form_Section_Proper::wp_enqueue_scripts(true);
138
+		} else {
139
+			add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
140
+			add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
141
+		}
142
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
143
+		/**
144
+		 * Gives other plugins a chance to hook in before construct finalize is called.
145
+		 * The form probably doesn't yet have a parent form section.
146
+		 * Since 4.9.32, when this action was introduced, this is the best place to add a subsection onto a form,
147
+		 * assuming you don't care what the form section's name, HTML ID, or HTML name etc are.
148
+		 * Also see AHEE__EE_Form_Section_Proper___construct_finalize__end
149
+		 *
150
+		 * @since 4.9.32
151
+		 * @param EE_Form_Section_Proper $this          before __construct is done, but all of its logic,
152
+		 *                                              except maybe calling _construct_finalize has been done
153
+		 * @param array                  $options_array options passed into the constructor
154
+		 */
155
+		do_action(
156
+			'AHEE__EE_Form_Input_Base___construct__before_construct_finalize_called',
157
+			$this,
158
+			$options_array
159
+		);
160
+		if (isset($options_array['name'])) {
161
+			$this->_construct_finalize(null, $options_array['name']);
162
+		}
163
+	}
164
+
165
+
166
+	/**
167
+	 * Finishes construction given the parent form section and this form section's name
168
+	 *
169
+	 * @param EE_Form_Section_Proper $parent_form_section
170
+	 * @param string                 $name
171
+	 * @throws EE_Error
172
+	 */
173
+	public function _construct_finalize($parent_form_section, $name)
174
+	{
175
+		parent::_construct_finalize($parent_form_section, $name);
176
+		$this->_set_default_name_if_empty();
177
+		$this->_set_default_html_id_if_empty();
178
+		foreach ($this->_subsections as $subsection_name => $subsection) {
179
+			if ($subsection instanceof EE_Form_Section_Base) {
180
+				$subsection->_construct_finalize($this, $subsection_name);
181
+			} else {
182
+				throw new EE_Error(
183
+					sprintf(
184
+						esc_html__(
185
+							'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
186
+							'event_espresso'
187
+						),
188
+						$subsection_name,
189
+						get_class($this),
190
+						$subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
191
+					)
192
+				);
193
+			}
194
+		}
195
+		/**
196
+		 * Action performed just after form has been given a name (and HTML ID etc) and is fully constructed.
197
+		 * If you have code that should modify the form and needs it and its subsections to have a name, HTML ID
198
+		 * (or other attributes derived from the name like the HTML label id, etc), this is where it should be done.
199
+		 * This might only happen just before displaying the form, or just before it receives form submission data.
200
+		 * If you need to modify the form or its subsections before _construct_finalize is called on it (and we've
201
+		 * ensured it has a name, HTML IDs, etc
202
+		 *
203
+		 * @param EE_Form_Section_Proper      $this
204
+		 * @param EE_Form_Section_Proper|null $parent_form_section
205
+		 * @param string                      $name
206
+		 */
207
+		do_action(
208
+			'AHEE__EE_Form_Section_Proper___construct_finalize__end',
209
+			$this,
210
+			$parent_form_section,
211
+			$name
212
+		);
213
+	}
214
+
215
+
216
+	/**
217
+	 * Gets the layout strategy for this form section
218
+	 *
219
+	 * @return EE_Form_Section_Layout_Base
220
+	 */
221
+	public function get_layout_strategy()
222
+	{
223
+		return $this->_layout_strategy;
224
+	}
225
+
226
+
227
+	/**
228
+	 * Gets the HTML for a single input for this form section according
229
+	 * to the layout strategy
230
+	 *
231
+	 * @param EE_Form_Input_Base $input
232
+	 * @return string
233
+	 */
234
+	public function get_html_for_input($input)
235
+	{
236
+		return $this->_layout_strategy->layout_input($input);
237
+	}
238
+
239
+
240
+	/**
241
+	 * was_submitted - checks if form inputs are present in request data
242
+	 * Basically an alias for form_data_present_in() (which is used by both
243
+	 * proper form sections and form inputs)
244
+	 *
245
+	 * @param null $form_data
246
+	 * @return boolean
247
+	 * @throws EE_Error
248
+	 */
249
+	public function was_submitted($form_data = null)
250
+	{
251
+		return $this->form_data_present_in($form_data);
252
+	}
253
+
254
+	/**
255
+	 * Gets the cached request data; but if there is none, or $req_data was set with
256
+	 * something different, refresh the cache, and then return it
257
+	 * @param null $req_data
258
+	 * @return array
259
+	 */
260
+	protected function getCachedRequest($req_data = null)
261
+	{
262
+		if (
263
+			$this->cached_request_data === null
264
+			|| (
265
+				$req_data !== null
266
+				&& $req_data !== $this->cached_request_data
267
+			)
268
+		) {
269
+			$req_data = apply_filters(
270
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
271
+				$req_data,
272
+				$this
273
+			);
274
+			if ($req_data === null) {
275
+				/** @var RequestInterface $request */
276
+				$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
277
+				$req_data = $request->requestParams();
278
+			}
279
+			$req_data = apply_filters(
280
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
281
+				$req_data,
282
+				$this
283
+			);
284
+			$this->cached_request_data = (array) $req_data;
285
+		}
286
+		return $this->cached_request_data;
287
+	}
288
+
289
+
290
+	/**
291
+	 * After the form section is initially created, call this to sanitize the data in the submission
292
+	 * which relates to this form section, validate it, and set it as properties on the form.
293
+	 *
294
+	 * @param array|null $req_data should usually be post data (the default).
295
+	 *                             However, you CAN supply a different array.
296
+	 *                             Consider using set_defaults() instead however.
297
+	 *                             (If you rendered the form in the page using $form_x->get_html()
298
+	 *                             the inputs will have the correct name in the request data for this function
299
+	 *                             to find them and populate the form with them.
300
+	 *                             If you have a flat form (with only input subsections),
301
+	 *                             you can supply a flat array where keys
302
+	 *                             are the form input names and values are their values)
303
+	 * @param boolean    $validate whether or not to perform validation on this data. Default is,
304
+	 *                             of course, to validate that data, and set errors on the invalid values.
305
+	 *                             But if the data has already been validated
306
+	 *                             (eg you validated the data then stored it in the DB)
307
+	 *                             you may want to skip this step.
308
+	 * @throws InvalidArgumentException
309
+	 * @throws InvalidInterfaceException
310
+	 * @throws InvalidDataTypeException
311
+	 * @throws EE_Error
312
+	 */
313
+	public function receive_form_submission($req_data = null, $validate = true)
314
+	{
315
+		$req_data = $this->getCachedRequest($req_data);
316
+		$this->_normalize($req_data);
317
+		if ($validate) {
318
+			$this->_validate();
319
+			// if it's invalid, we're going to want to re-display so remember what they submitted
320
+			if (! $this->is_valid()) {
321
+				$this->store_submitted_form_data_in_session();
322
+			}
323
+		}
324
+		if ($this->submission_error_message() === '' && ! $this->is_valid()) {
325
+			$this->set_submission_error_message();
326
+		}
327
+		do_action(
328
+			'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
329
+			$req_data,
330
+			$this,
331
+			$validate
332
+		);
333
+	}
334
+
335
+
336
+	/**
337
+	 * caches the originally submitted input values in the session
338
+	 * so that they can be used to repopulate the form if it failed validation
339
+	 *
340
+	 * @return boolean whether or not the data was successfully stored in the session
341
+	 * @throws InvalidArgumentException
342
+	 * @throws InvalidInterfaceException
343
+	 * @throws InvalidDataTypeException
344
+	 * @throws EE_Error
345
+	 */
346
+	protected function store_submitted_form_data_in_session()
347
+	{
348
+		$session = EE_Registry::instance()->SSN;
349
+		if ($session instanceof EE_Session) {
350
+			return EE_Registry::instance()->SSN->set_session_data(
351
+				[
352
+					EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
353
+				]
354
+			);
355
+		}
356
+		return false;
357
+	}
358
+
359
+
360
+	/**
361
+	 * retrieves the originally submitted input values in the session
362
+	 * so that they can be used to repopulate the form if it failed validation
363
+	 *
364
+	 * @return array
365
+	 * @throws InvalidArgumentException
366
+	 * @throws InvalidInterfaceException
367
+	 * @throws InvalidDataTypeException
368
+	 */
369
+	protected function get_submitted_form_data_from_session()
370
+	{
371
+		$session = EE_Registry::instance()->SSN;
372
+		if ($session instanceof EE_Session) {
373
+			return $session->get_session_data(
374
+				EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
375
+			);
376
+		}
377
+		return array();
378
+	}
379
+
380
+
381
+	/**
382
+	 * flushed the originally submitted input values from the session
383
+	 *
384
+	 * @return boolean whether or not the data was successfully removed from the session
385
+	 * @throws InvalidArgumentException
386
+	 * @throws InvalidInterfaceException
387
+	 * @throws InvalidDataTypeException
388
+	 */
389
+	public static function flush_submitted_form_data_from_session()
390
+	{
391
+		return EE_Registry::instance()->SSN->reset_data(
392
+			array(EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
393
+		);
394
+	}
395
+
396
+
397
+	/**
398
+	 * Populates this form and its subsections with data from the session.
399
+	 * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
400
+	 * validation errors when displaying too)
401
+	 * Returns true if the form was populated from the session, false otherwise
402
+	 *
403
+	 * @return boolean
404
+	 * @throws InvalidArgumentException
405
+	 * @throws InvalidInterfaceException
406
+	 * @throws InvalidDataTypeException
407
+	 * @throws EE_Error
408
+	 */
409
+	public function populate_from_session()
410
+	{
411
+		$form_data_in_session = $this->get_submitted_form_data_from_session();
412
+		if (empty($form_data_in_session)) {
413
+			return false;
414
+		}
415
+		$this->receive_form_submission($form_data_in_session);
416
+		add_action('shutdown', array('EE_Form_Section_Proper', 'flush_submitted_form_data_from_session'));
417
+		if ($this->form_data_present_in($form_data_in_session)) {
418
+			return true;
419
+		}
420
+		return false;
421
+	}
422
+
423
+
424
+	/**
425
+	 * Populates the default data for the form, given an array where keys are
426
+	 * the input names, and values are their values (preferably normalized to be their
427
+	 * proper PHP types, not all strings... although that should be ok too).
428
+	 * Proper subsections are sub-arrays, the key being the subsection's name, and
429
+	 * the value being an array formatted in teh same way
430
+	 *
431
+	 * @param array $default_data
432
+	 * @throws EE_Error
433
+	 */
434
+	public function populate_defaults($default_data)
435
+	{
436
+		foreach ($this->subsections(false) as $subsection_name => $subsection) {
437
+			if (isset($default_data[ $subsection_name ])) {
438
+				if ($subsection instanceof EE_Form_Input_Base) {
439
+					$subsection->set_default($default_data[ $subsection_name ]);
440
+				} elseif ($subsection instanceof EE_Form_Section_Proper) {
441
+					$subsection->populate_defaults($default_data[ $subsection_name ]);
442
+				}
443
+			}
444
+		}
445
+	}
446
+
447
+
448
+	/**
449
+	 * returns true if subsection exists
450
+	 *
451
+	 * @param string $name
452
+	 * @return boolean
453
+	 */
454
+	public function subsection_exists($name)
455
+	{
456
+		return isset($this->_subsections[ $name ]) ? true : false;
457
+	}
458
+
459
+
460
+	/**
461
+	 * Gets the subsection specified by its name
462
+	 *
463
+	 * @param string  $name
464
+	 * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
465
+	 *                                                      so that the inputs will be properly configured.
466
+	 *                                                      However, some client code may be ok
467
+	 *                                                      with construction finalize being called later
468
+	 *                                                      (realizing that the subsections' html names
469
+	 *                                                      might not be set yet, etc.)
470
+	 * @return EE_Form_Section_Base
471
+	 * @throws EE_Error
472
+	 */
473
+	public function get_subsection($name, $require_construction_to_be_finalized = true)
474
+	{
475
+		if ($require_construction_to_be_finalized) {
476
+			$this->ensure_construct_finalized_called();
477
+		}
478
+		return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
479
+	}
480
+
481
+
482
+	/**
483
+	 * Gets all the validatable subsections of this form section
484
+	 *
485
+	 * @return EE_Form_Section_Validatable[]
486
+	 * @throws EE_Error
487
+	 */
488
+	public function get_validatable_subsections()
489
+	{
490
+		$validatable_subsections = array();
491
+		foreach ($this->subsections() as $name => $obj) {
492
+			if ($obj instanceof EE_Form_Section_Validatable) {
493
+				$validatable_subsections[ $name ] = $obj;
494
+			}
495
+		}
496
+		return $validatable_subsections;
497
+	}
498
+
499
+
500
+	/**
501
+	 * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
502
+	 * throw an EE_Error.
503
+	 *
504
+	 * @param string  $name
505
+	 * @param boolean $require_construction_to_be_finalized most client code should
506
+	 *                                                      leave this as TRUE so that the inputs will be properly
507
+	 *                                                      configured. However, some client code may be ok with
508
+	 *                                                      construction finalize being called later
509
+	 *                                                      (realizing that the subsections' html names might not be
510
+	 *                                                      set yet, etc.)
511
+	 * @return EE_Form_Input_Base
512
+	 * @throws EE_Error
513
+	 */
514
+	public function get_input($name, $require_construction_to_be_finalized = true)
515
+	{
516
+		$subsection = $this->get_subsection(
517
+			$name,
518
+			$require_construction_to_be_finalized
519
+		);
520
+		if (! $subsection instanceof EE_Form_Input_Base) {
521
+			throw new EE_Error(
522
+				sprintf(
523
+					esc_html__(
524
+						"Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
525
+						'event_espresso'
526
+					),
527
+					$name,
528
+					get_class($this),
529
+					$subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
530
+				)
531
+			);
532
+		}
533
+		return $subsection;
534
+	}
535
+
536
+
537
+	/**
538
+	 * Like get_input(), gets the proper subsection of the form given the name,
539
+	 * otherwise throws an EE_Error
540
+	 *
541
+	 * @param string  $name
542
+	 * @param boolean $require_construction_to_be_finalized most client code should
543
+	 *                                                      leave this as TRUE so that the inputs will be properly
544
+	 *                                                      configured. However, some client code may be ok with
545
+	 *                                                      construction finalize being called later
546
+	 *                                                      (realizing that the subsections' html names might not be
547
+	 *                                                      set yet, etc.)
548
+	 * @return EE_Form_Section_Proper
549
+	 * @throws EE_Error
550
+	 */
551
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
552
+	{
553
+		$subsection = $this->get_subsection(
554
+			$name,
555
+			$require_construction_to_be_finalized
556
+		);
557
+		if (! $subsection instanceof EE_Form_Section_Proper) {
558
+			throw new EE_Error(
559
+				sprintf(
560
+					esc_html__(
561
+						"Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'",
562
+						'event_espresso'
563
+					),
564
+					$name,
565
+					get_class($this)
566
+				)
567
+			);
568
+		}
569
+		return $subsection;
570
+	}
571
+
572
+
573
+	/**
574
+	 * Gets the value of the specified input. Should be called after receive_form_submission()
575
+	 * or populate_defaults() on the form, where the normalized value on the input is set.
576
+	 *
577
+	 * @param string $name
578
+	 * @return mixed depending on the input's type and its normalization strategy
579
+	 * @throws EE_Error
580
+	 */
581
+	public function get_input_value($name)
582
+	{
583
+		$input = $this->get_input($name);
584
+		return $input->normalized_value();
585
+	}
586
+
587
+
588
+	/**
589
+	 * Checks if this form section itself is valid, and then checks its subsections
590
+	 *
591
+	 * @throws EE_Error
592
+	 * @return boolean
593
+	 */
594
+	public function is_valid()
595
+	{
596
+		if ($this->is_valid === null) {
597
+			if (! $this->has_received_submission()) {
598
+				throw new EE_Error(
599
+					sprintf(
600
+						esc_html__(
601
+							'You cannot check if a form is valid before receiving the form submission using receive_form_submission',
602
+							'event_espresso'
603
+						)
604
+					)
605
+				);
606
+			}
607
+			if (! parent::is_valid()) {
608
+				$this->is_valid = false;
609
+			} else {
610
+				// ok so no general errors to this entire form section.
611
+				// so let's check the subsections, but only set errors if that hasn't been done yet
612
+				$this->is_valid = true;
613
+				foreach ($this->get_validatable_subsections() as $subsection) {
614
+					if (! $subsection->is_valid()) {
615
+						$this->is_valid = false;
616
+					}
617
+				}
618
+			}
619
+		}
620
+		return $this->is_valid;
621
+	}
622
+
623
+
624
+	/**
625
+	 * gets the default name of this form section if none is specified
626
+	 *
627
+	 * @return void
628
+	 */
629
+	protected function _set_default_name_if_empty()
630
+	{
631
+		if (! $this->_name) {
632
+			$classname    = get_class($this);
633
+			$default_name = str_replace('EE_', '', $classname);
634
+			$this->_name  = $default_name;
635
+		}
636
+	}
637
+
638
+
639
+	/**
640
+	 * Returns the HTML for the form, except for the form opening and closing tags
641
+	 * (as the form section doesn't know where you necessarily want to send the information to),
642
+	 * and except for a submit button. Enqueues JS and CSS; if called early enough we will
643
+	 * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
644
+	 * Not doing_it_wrong because theoretically this CAN be used properly,
645
+	 * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
646
+	 * any CSS.
647
+	 *
648
+	 * @throws InvalidArgumentException
649
+	 * @throws InvalidInterfaceException
650
+	 * @throws InvalidDataTypeException
651
+	 * @throws EE_Error
652
+	 */
653
+	public function get_html_and_js()
654
+	{
655
+		$this->enqueue_js();
656
+		return $this->get_html();
657
+	}
658
+
659
+
660
+	/**
661
+	 * returns HTML for displaying this form section. recursively calls display_section() on all subsections
662
+	 *
663
+	 * @param bool $display_previously_submitted_data
664
+	 * @return string
665
+	 * @throws InvalidArgumentException
666
+	 * @throws InvalidInterfaceException
667
+	 * @throws InvalidDataTypeException
668
+	 * @throws EE_Error
669
+	 * @throws EE_Error
670
+	 * @throws EE_Error
671
+	 */
672
+	public function get_html($display_previously_submitted_data = true)
673
+	{
674
+		$this->ensure_construct_finalized_called();
675
+		if ($display_previously_submitted_data) {
676
+			$this->populate_from_session();
677
+		}
678
+		return $this->_form_html_filter
679
+			? $this->_form_html_filter->filterHtml($this->_layout_strategy->layout_form(), $this)
680
+			: $this->_layout_strategy->layout_form();
681
+	}
682
+
683
+
684
+	/**
685
+	 * enqueues JS and CSS for the form.
686
+	 * It is preferred to call this before wp_enqueue_scripts so the
687
+	 * scripts and styles can be put in the header, but if called later
688
+	 * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
689
+	 * only be in the header; but in HTML5 its ok in the body.
690
+	 * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
691
+	 * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
692
+	 *
693
+	 * @return void
694
+	 * @throws EE_Error
695
+	 */
696
+	public function enqueue_js()
697
+	{
698
+		$this->_enqueue_and_localize_form_js();
699
+		foreach ($this->subsections() as $subsection) {
700
+			$subsection->enqueue_js();
701
+		}
702
+	}
703
+
704
+
705
+	/**
706
+	 * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
707
+	 * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
708
+	 * the wp_enqueue_scripts hook.
709
+	 * However, registering the form js and localizing it can happen when we
710
+	 * actually output the form (which is preferred, seeing how teh form's fields
711
+	 * could change until it's actually outputted)
712
+	 *
713
+	 * @param boolean $init_form_validation_automatically whether or not we want the form validation
714
+	 *                                                    to be triggered automatically or not
715
+	 * @return void
716
+	 */
717
+	public static function wp_enqueue_scripts($init_form_validation_automatically = true)
718
+	{
719
+		wp_register_script(
720
+			'ee_form_section_validation',
721
+			EE_GLOBAL_ASSETS_URL . 'scripts' . '/form_section_validation.js',
722
+			array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
723
+			EVENT_ESPRESSO_VERSION,
724
+			true
725
+		);
726
+		wp_localize_script(
727
+			'ee_form_section_validation',
728
+			'ee_form_section_validation_init',
729
+			array('init' => $init_form_validation_automatically ? '1' : '0')
730
+		);
731
+	}
732
+
733
+
734
+	/**
735
+	 * gets the variables used by form_section_validation.js.
736
+	 * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
737
+	 * but before the wordpress hook wp_loaded
738
+	 *
739
+	 * @throws EE_Error
740
+	 */
741
+	public function _enqueue_and_localize_form_js()
742
+	{
743
+		$this->ensure_construct_finalized_called();
744
+		// actually, we don't want to localize just yet. There may be other forms on the page.
745
+		// so we need to add our form section data to a static variable accessible by all form sections
746
+		// and localize it just before the footer
747
+		$this->localize_validation_rules();
748
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
749
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
750
+	}
751
+
752
+
753
+	/**
754
+	 * add our form section data to a static variable accessible by all form sections
755
+	 *
756
+	 * @param bool $return_for_subsection
757
+	 * @return void
758
+	 * @throws EE_Error
759
+	 */
760
+	public function localize_validation_rules($return_for_subsection = false)
761
+	{
762
+		// we only want to localize vars ONCE for the entire form,
763
+		// so if the form section doesn't have a parent, then it must be the top dog
764
+		if ($return_for_subsection || ! $this->parent_section()) {
765
+			EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
766
+				'form_section_id'  => $this->html_id(true),
767
+				'validation_rules' => $this->get_jquery_validation_rules(),
768
+				'other_data'       => $this->get_other_js_data(),
769
+				'errors'           => $this->subsection_validation_errors_by_html_name(),
770
+			);
771
+			EE_Form_Section_Proper::$_scripts_localized                                = true;
772
+		}
773
+	}
774
+
775
+
776
+	/**
777
+	 * Gets an array of extra data that will be useful for client-side javascript.
778
+	 * This is primarily data added by inputs and forms in addition to any
779
+	 * scripts they might enqueue
780
+	 *
781
+	 * @param array $form_other_js_data
782
+	 * @return array
783
+	 * @throws EE_Error
784
+	 */
785
+	public function get_other_js_data($form_other_js_data = array())
786
+	{
787
+		foreach ($this->subsections() as $subsection) {
788
+			$form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
789
+		}
790
+		return $form_other_js_data;
791
+	}
792
+
793
+
794
+	/**
795
+	 * Gets a flat array of inputs for this form section and its subsections.
796
+	 * Keys are their form names, and values are the inputs themselves
797
+	 *
798
+	 * @return EE_Form_Input_Base
799
+	 * @throws EE_Error
800
+	 */
801
+	public function inputs_in_subsections()
802
+	{
803
+		$inputs = array();
804
+		foreach ($this->subsections() as $subsection) {
805
+			if ($subsection instanceof EE_Form_Input_Base) {
806
+				$inputs[ $subsection->html_name() ] = $subsection;
807
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
808
+				$inputs += $subsection->inputs_in_subsections();
809
+			}
810
+		}
811
+		return $inputs;
812
+	}
813
+
814
+
815
+	/**
816
+	 * Gets a flat array of all the validation errors.
817
+	 * Keys are html names (because those should be unique)
818
+	 * and values are a string of all their validation errors
819
+	 *
820
+	 * @return string[]
821
+	 * @throws EE_Error
822
+	 */
823
+	public function subsection_validation_errors_by_html_name()
824
+	{
825
+		$inputs = $this->inputs();
826
+		$errors = array();
827
+		foreach ($inputs as $form_input) {
828
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
829
+				$errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
830
+			}
831
+		}
832
+		return $errors;
833
+	}
834
+
835
+
836
+	/**
837
+	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
838
+	 * Should be setup by each form during the _enqueues_and_localize_form_js
839
+	 *
840
+	 * @throws InvalidArgumentException
841
+	 * @throws InvalidInterfaceException
842
+	 * @throws InvalidDataTypeException
843
+	 */
844
+	public static function localize_script_for_all_forms()
845
+	{
846
+		// allow inputs and stuff to hook in their JS and stuff here
847
+		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
848
+		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
849
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
850
+			? EE_Registry::instance()->CFG->registration->email_validation_level
851
+			: 'wp_default';
852
+		EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
853
+		wp_enqueue_script('ee_form_section_validation');
854
+		wp_localize_script(
855
+			'ee_form_section_validation',
856
+			'ee_form_section_vars',
857
+			EE_Form_Section_Proper::$_js_localization
858
+		);
859
+	}
860
+
861
+
862
+	/**
863
+	 * ensure_scripts_localized
864
+	 *
865
+	 * @throws EE_Error
866
+	 */
867
+	public function ensure_scripts_localized()
868
+	{
869
+		if (! EE_Form_Section_Proper::$_scripts_localized) {
870
+			$this->_enqueue_and_localize_form_js();
871
+		}
872
+	}
873
+
874
+
875
+	/**
876
+	 * Gets the hard-coded validation error messages to be used in the JS. The convention
877
+	 * is that the key here should be the same as the custom validation rule put in the JS file
878
+	 *
879
+	 * @return array keys are custom validation rules, and values are internationalized strings
880
+	 */
881
+	private static function _get_localized_error_messages()
882
+	{
883
+		return array(
884
+			'validUrl' => wp_strip_all_tags(__('This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg', 'event_espresso')),
885
+			'regex'    => wp_strip_all_tags(__('Please check your input', 'event_espresso'))
886
+		);
887
+	}
888
+
889
+
890
+	/**
891
+	 * @return array
892
+	 */
893
+	public static function js_localization()
894
+	{
895
+		return self::$_js_localization;
896
+	}
897
+
898
+
899
+	/**
900
+	 * @return void
901
+	 */
902
+	public static function reset_js_localization()
903
+	{
904
+		self::$_js_localization = array();
905
+	}
906
+
907
+
908
+	/**
909
+	 * Gets the JS to put inside the jquery validation rules for subsection of this form section.
910
+	 * See parent function for more...
911
+	 *
912
+	 * @return array
913
+	 * @throws EE_Error
914
+	 */
915
+	public function get_jquery_validation_rules()
916
+	{
917
+		$jquery_validation_rules = array();
918
+		foreach ($this->get_validatable_subsections() as $subsection) {
919
+			$jquery_validation_rules = array_merge(
920
+				$jquery_validation_rules,
921
+				$subsection->get_jquery_validation_rules()
922
+			);
923
+		}
924
+		return $jquery_validation_rules;
925
+	}
926
+
927
+
928
+	/**
929
+	 * Sanitizes all the data and sets the sanitized value of each field
930
+	 *
931
+	 * @param array $req_data
932
+	 * @return void
933
+	 * @throws EE_Error
934
+	 */
935
+	protected function _normalize($req_data)
936
+	{
937
+		$this->_received_submission = true;
938
+		$this->_validation_errors   = array();
939
+		foreach ($this->get_validatable_subsections() as $subsection) {
940
+			try {
941
+				$subsection->_normalize($req_data);
942
+			} catch (EE_Validation_Error $e) {
943
+				$subsection->add_validation_error($e);
944
+			}
945
+		}
946
+	}
947
+
948
+
949
+	/**
950
+	 * Performs validation on this form section and its subsections.
951
+	 * For each subsection,
952
+	 * calls _validate_{subsection_name} on THIS form (if the function exists)
953
+	 * and passes it the subsection, then calls _validate on that subsection.
954
+	 * If you need to perform validation on the form as a whole (considering multiple)
955
+	 * you would be best to override this _validate method,
956
+	 * calling parent::_validate() first.
957
+	 *
958
+	 * @throws EE_Error
959
+	 */
960
+	protected function _validate()
961
+	{
962
+		// reset the cache of whether this form is valid or not- we're re-validating it now
963
+		$this->is_valid = null;
964
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
965
+			if (method_exists($this, '_validate_' . $subsection_name)) {
966
+				call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
967
+			}
968
+			$subsection->_validate();
969
+		}
970
+	}
971
+
972
+
973
+	/**
974
+	 * Gets all the validated inputs for the form section
975
+	 *
976
+	 * @return array
977
+	 * @throws EE_Error
978
+	 */
979
+	public function valid_data()
980
+	{
981
+		$inputs = array();
982
+		foreach ($this->subsections() as $subsection_name => $subsection) {
983
+			if ($subsection instanceof EE_Form_Section_Proper) {
984
+				$inputs[ $subsection_name ] = $subsection->valid_data();
985
+			} elseif ($subsection instanceof EE_Form_Input_Base) {
986
+				$inputs[ $subsection_name ] = $subsection->normalized_value();
987
+			}
988
+		}
989
+		return $inputs;
990
+	}
991
+
992
+
993
+	/**
994
+	 * Gets all the inputs on this form section
995
+	 *
996
+	 * @return EE_Form_Input_Base[]
997
+	 * @throws EE_Error
998
+	 */
999
+	public function inputs()
1000
+	{
1001
+		$inputs = array();
1002
+		foreach ($this->subsections() as $subsection_name => $subsection) {
1003
+			if ($subsection instanceof EE_Form_Input_Base) {
1004
+				$inputs[ $subsection_name ] = $subsection;
1005
+			}
1006
+		}
1007
+		return $inputs;
1008
+	}
1009
+
1010
+
1011
+	/**
1012
+	 * Gets all the subsections which are a proper form
1013
+	 *
1014
+	 * @return EE_Form_Section_Proper[]
1015
+	 * @throws EE_Error
1016
+	 */
1017
+	public function subforms()
1018
+	{
1019
+		$form_sections = array();
1020
+		foreach ($this->subsections() as $name => $obj) {
1021
+			if ($obj instanceof EE_Form_Section_Proper) {
1022
+				$form_sections[ $name ] = $obj;
1023
+			}
1024
+		}
1025
+		return $form_sections;
1026
+	}
1027
+
1028
+
1029
+	/**
1030
+	 * Gets all the subsections (inputs, proper subsections, or html-only sections).
1031
+	 * Consider using inputs() or subforms()
1032
+	 * if you only want form inputs or proper form sections.
1033
+	 *
1034
+	 * @param boolean $require_construction_to_be_finalized most client code should
1035
+	 *                                                      leave this as TRUE so that the inputs will be properly
1036
+	 *                                                      configured. However, some client code may be ok with
1037
+	 *                                                      construction finalize being called later
1038
+	 *                                                      (realizing that the subsections' html names might not be
1039
+	 *                                                      set yet, etc.)
1040
+	 * @return EE_Form_Section_Proper[]
1041
+	 * @throws EE_Error
1042
+	 */
1043
+	public function subsections($require_construction_to_be_finalized = true)
1044
+	{
1045
+		if ($require_construction_to_be_finalized) {
1046
+			$this->ensure_construct_finalized_called();
1047
+		}
1048
+		return $this->_subsections;
1049
+	}
1050
+
1051
+
1052
+	/**
1053
+	 * Returns whether this form has any subforms or inputs
1054
+	 * @return bool
1055
+	 */
1056
+	public function hasSubsections()
1057
+	{
1058
+		return ! empty($this->_subsections);
1059
+	}
1060
+
1061
+
1062
+	/**
1063
+	 * Returns a simple array where keys are input names, and values are their normalized
1064
+	 * values. (Similar to calling get_input_value on inputs)
1065
+	 *
1066
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1067
+	 *                                        or just this forms' direct children inputs
1068
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1069
+	 *                                        or allow multidimensional array
1070
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
1071
+	 *                                        with array keys being input names
1072
+	 *                                        (regardless of whether they are from a subsection or not),
1073
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1074
+	 *                                        where keys are always subsection names and values are either
1075
+	 *                                        the input's normalized value, or an array like the top-level array
1076
+	 * @throws EE_Error
1077
+	 */
1078
+	public function input_values($include_subform_inputs = false, $flatten = false)
1079
+	{
1080
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
1081
+	}
1082
+
1083
+
1084
+	/**
1085
+	 * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
1086
+	 * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
1087
+	 * is not necessarily the value we want to display to users. This creates an array
1088
+	 * where keys are the input names, and values are their display values
1089
+	 *
1090
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1091
+	 *                                        or just this forms' direct children inputs
1092
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1093
+	 *                                        or allow multidimensional array
1094
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
1095
+	 *                                        with array keys being input names
1096
+	 *                                        (regardless of whether they are from a subsection or not),
1097
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1098
+	 *                                        where keys are always subsection names and values are either
1099
+	 *                                        the input's normalized value, or an array like the top-level array
1100
+	 * @throws EE_Error
1101
+	 */
1102
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false)
1103
+	{
1104
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
1105
+	}
1106
+
1107
+
1108
+	/**
1109
+	 * Gets the input values from the form
1110
+	 *
1111
+	 * @param boolean $pretty                 Whether to retrieve the pretty value,
1112
+	 *                                        or just the normalized value
1113
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1114
+	 *                                        or just this forms' direct children inputs
1115
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1116
+	 *                                        or allow multidimensional array
1117
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
1118
+	 *                                        input names (regardless of whether they are from a subsection or not),
1119
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1120
+	 *                                        where keys are always subsection names and values are either
1121
+	 *                                        the input's normalized value, or an array like the top-level array
1122
+	 * @throws EE_Error
1123
+	 */
1124
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
1125
+	{
1126
+		$input_values = array();
1127
+		foreach ($this->subsections() as $subsection_name => $subsection) {
1128
+			if ($subsection instanceof EE_Form_Input_Base) {
1129
+				$input_values[ $subsection_name ] = $pretty
1130
+					? $subsection->pretty_value()
1131
+					: $subsection->normalized_value();
1132
+			} elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1133
+				$subform_input_values = $subsection->_input_values(
1134
+					$pretty,
1135
+					$include_subform_inputs,
1136
+					$flatten
1137
+				);
1138
+				if ($flatten) {
1139
+					$input_values = array_merge($input_values, $subform_input_values);
1140
+				} else {
1141
+					$input_values[ $subsection_name ] = $subform_input_values;
1142
+				}
1143
+			}
1144
+		}
1145
+		return $input_values;
1146
+	}
1147
+
1148
+
1149
+	/**
1150
+	 * Gets the originally submitted input values from the form
1151
+	 *
1152
+	 * @param boolean $include_subforms  Whether to include inputs from subforms,
1153
+	 *                                   or just this forms' direct children inputs
1154
+	 * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1155
+	 *                                   with array keys being input names
1156
+	 *                                   (regardless of whether they are from a subsection or not),
1157
+	 *                                   and if $flatten is FALSE it can be a multidimensional array
1158
+	 *                                   where keys are always subsection names and values are either
1159
+	 *                                   the input's normalized value, or an array like the top-level array
1160
+	 * @throws EE_Error
1161
+	 */
1162
+	public function submitted_values($include_subforms = false)
1163
+	{
1164
+		$submitted_values = array();
1165
+		foreach ($this->subsections() as $subsection) {
1166
+			if ($subsection instanceof EE_Form_Input_Base) {
1167
+				// is this input part of an array of inputs?
1168
+				if (strpos($subsection->html_name(), '[') !== false) {
1169
+					$full_input_name  = EEH_Array::convert_array_values_to_keys(
1170
+						explode(
1171
+							'[',
1172
+							str_replace(']', '', $subsection->html_name())
1173
+						),
1174
+						$subsection->raw_value()
1175
+					);
1176
+					$submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1177
+				} else {
1178
+					$submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1179
+				}
1180
+			} elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1181
+				$subform_input_values = $subsection->submitted_values($include_subforms);
1182
+				$submitted_values     = array_replace_recursive($submitted_values, $subform_input_values);
1183
+			}
1184
+		}
1185
+		return $submitted_values;
1186
+	}
1187
+
1188
+
1189
+	/**
1190
+	 * Indicates whether or not this form has received a submission yet
1191
+	 * (ie, had receive_form_submission called on it yet)
1192
+	 *
1193
+	 * @return boolean
1194
+	 * @throws EE_Error
1195
+	 */
1196
+	public function has_received_submission()
1197
+	{
1198
+		$this->ensure_construct_finalized_called();
1199
+		return $this->_received_submission;
1200
+	}
1201
+
1202
+
1203
+	/**
1204
+	 * Equivalent to passing 'exclude' in the constructor's options array.
1205
+	 * Removes the listed inputs from the form
1206
+	 *
1207
+	 * @param array $inputs_to_exclude values are the input names
1208
+	 * @return void
1209
+	 */
1210
+	public function exclude(array $inputs_to_exclude = array())
1211
+	{
1212
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
1213
+			unset($this->_subsections[ $input_to_exclude_name ]);
1214
+		}
1215
+	}
1216
+
1217
+
1218
+	/**
1219
+	 * Changes these inputs' display strategy to be EE_Hidden_Display_Strategy.
1220
+	 * @param array $inputs_to_hide
1221
+	 * @throws EE_Error
1222
+	 */
1223
+	public function hide(array $inputs_to_hide = array())
1224
+	{
1225
+		foreach ($inputs_to_hide as $input_to_hide) {
1226
+			$input = $this->get_input($input_to_hide);
1227
+			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
1228
+		}
1229
+	}
1230
+
1231
+
1232
+	/**
1233
+	 * add_subsections
1234
+	 * Adds the listed subsections to the form section.
1235
+	 * If $subsection_name_to_target is provided,
1236
+	 * then new subsections are added before or after that subsection,
1237
+	 * otherwise to the start or end of the entire subsections array.
1238
+	 *
1239
+	 * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1240
+	 *                                                          where keys are their names
1241
+	 * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1242
+	 *                                                          should be added before or after
1243
+	 *                                                          IF $subsection_name_to_target is null,
1244
+	 *                                                          then $new_subsections will be added to
1245
+	 *                                                          the beginning or end of the entire subsections array
1246
+	 * @param boolean                $add_before                whether to add $new_subsections, before or after
1247
+	 *                                                          $subsection_name_to_target,
1248
+	 *                                                          or if $subsection_name_to_target is null,
1249
+	 *                                                          before or after entire subsections array
1250
+	 * @return void
1251
+	 * @throws EE_Error
1252
+	 */
1253
+	public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1254
+	{
1255
+		foreach ($new_subsections as $subsection_name => $subsection) {
1256
+			if (! $subsection instanceof EE_Form_Section_Base) {
1257
+				EE_Error::add_error(
1258
+					sprintf(
1259
+						esc_html__(
1260
+							"Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1261
+							'event_espresso'
1262
+						),
1263
+						get_class($subsection),
1264
+						$subsection_name,
1265
+						$this->name()
1266
+					)
1267
+				);
1268
+				unset($new_subsections[ $subsection_name ]);
1269
+			}
1270
+		}
1271
+		$this->_subsections = EEH_Array::insert_into_array(
1272
+			$this->_subsections,
1273
+			$new_subsections,
1274
+			$subsection_name_to_target,
1275
+			$add_before
1276
+		);
1277
+		if ($this->_construction_finalized) {
1278
+			foreach ($this->_subsections as $name => $subsection) {
1279
+				$subsection->_construct_finalize($this, $name);
1280
+			}
1281
+		}
1282
+	}
1283
+
1284
+
1285
+	/**
1286
+	 * @param string $subsection_name
1287
+	 * @param bool   $recursive
1288
+	 * @return bool
1289
+	 */
1290
+	public function has_subsection($subsection_name, $recursive = false)
1291
+	{
1292
+		foreach ($this->_subsections as $name => $subsection) {
1293
+			if (
1294
+				$name === $subsection_name
1295
+				|| (
1296
+					$recursive
1297
+					&& $subsection instanceof EE_Form_Section_Proper
1298
+					&& $subsection->has_subsection($subsection_name, $recursive)
1299
+				)
1300
+			) {
1301
+				return true;
1302
+			}
1303
+		}
1304
+		return false;
1305
+	}
1306
+
1307
+
1308
+
1309
+	/**
1310
+	 * Just gets all validatable subsections to clean their sensitive data
1311
+	 *
1312
+	 * @throws EE_Error
1313
+	 */
1314
+	public function clean_sensitive_data()
1315
+	{
1316
+		foreach ($this->get_validatable_subsections() as $subsection) {
1317
+			$subsection->clean_sensitive_data();
1318
+		}
1319
+	}
1320
+
1321
+
1322
+	/**
1323
+	 * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1324
+	 * @param string                           $form_submission_error_message
1325
+	 * @param EE_Form_Section_Validatable $form_section unused
1326
+	 * @throws EE_Error
1327
+	 */
1328
+	public function set_submission_error_message(
1329
+		$form_submission_error_message = ''
1330
+	) {
1331
+		$this->_form_submission_error_message = ! empty($form_submission_error_message)
1332
+			? $form_submission_error_message
1333
+			: $this->getAllValidationErrorsString();
1334
+	}
1335
+
1336
+
1337
+	/**
1338
+	 * Returns the cached error message. A default value is set for this during _validate(),
1339
+	 * (called during receive_form_submission) but it can be explicitly set using
1340
+	 * set_submission_error_message
1341
+	 *
1342
+	 * @return string
1343
+	 */
1344
+	public function submission_error_message()
1345
+	{
1346
+		return $this->_form_submission_error_message;
1347
+	}
1348
+
1349
+
1350
+	/**
1351
+	 * Sets a message to display if the data submitted to the form was valid.
1352
+	 * @param string $form_submission_success_message
1353
+	 */
1354
+	public function set_submission_success_message($form_submission_success_message = '')
1355
+	{
1356
+		$this->_form_submission_success_message = ! empty($form_submission_success_message)
1357
+			? $form_submission_success_message
1358
+			: esc_html__('Form submitted successfully', 'event_espresso');
1359
+	}
1360
+
1361
+
1362
+	/**
1363
+	 * Gets a message appropriate for display when the form is correctly submitted
1364
+	 * @return string
1365
+	 */
1366
+	public function submission_success_message()
1367
+	{
1368
+		return $this->_form_submission_success_message;
1369
+	}
1370
+
1371
+
1372
+	/**
1373
+	 * Returns the prefix that should be used on child of this form section for
1374
+	 * their html names. If this form section itself has a parent, prepends ITS
1375
+	 * prefix onto this form section's prefix. Used primarily by
1376
+	 * EE_Form_Input_Base::_set_default_html_name_if_empty
1377
+	 *
1378
+	 * @return string
1379
+	 * @throws EE_Error
1380
+	 */
1381
+	public function html_name_prefix()
1382
+	{
1383
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1384
+			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1385
+		}
1386
+		return $this->name();
1387
+	}
1388
+
1389
+
1390
+	/**
1391
+	 * Gets the name, but first checks _construct_finalize has been called. If not,
1392
+	 * calls it (assumes there is no parent and that we want the name to be whatever
1393
+	 * was set, which is probably nothing, or the classname)
1394
+	 *
1395
+	 * @return string
1396
+	 * @throws EE_Error
1397
+	 */
1398
+	public function name()
1399
+	{
1400
+		$this->ensure_construct_finalized_called();
1401
+		return parent::name();
1402
+	}
1403
+
1404
+
1405
+	/**
1406
+	 * @return EE_Form_Section_Proper
1407
+	 * @throws EE_Error
1408
+	 */
1409
+	public function parent_section()
1410
+	{
1411
+		$this->ensure_construct_finalized_called();
1412
+		return parent::parent_section();
1413
+	}
1414
+
1415
+
1416
+	/**
1417
+	 * make sure construction finalized was called, otherwise children might not be ready
1418
+	 *
1419
+	 * @return void
1420
+	 * @throws EE_Error
1421
+	 */
1422
+	public function ensure_construct_finalized_called()
1423
+	{
1424
+		if (! $this->_construction_finalized) {
1425
+			$this->_construct_finalize($this->_parent_section, $this->_name);
1426
+		}
1427
+	}
1428
+
1429
+
1430
+	/**
1431
+	 * Checks if any of this form section's inputs, or any of its children's inputs,
1432
+	 * are in teh form data. If any are found, returns true. Else false
1433
+	 *
1434
+	 * @param array $req_data
1435
+	 * @return boolean
1436
+	 * @throws EE_Error
1437
+	 */
1438
+	public function form_data_present_in($req_data = null)
1439
+	{
1440
+		$req_data = $this->getCachedRequest($req_data);
1441
+		foreach ($this->subsections() as $subsection) {
1442
+			if ($subsection instanceof EE_Form_Input_Base) {
1443
+				if ($subsection->form_data_present_in($req_data)) {
1444
+					return true;
1445
+				}
1446
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
1447
+				if ($subsection->form_data_present_in($req_data)) {
1448
+					return true;
1449
+				}
1450
+			}
1451
+		}
1452
+		return false;
1453
+	}
1454
+
1455
+
1456
+	/**
1457
+	 * Gets validation errors for this form section and subsections
1458
+	 * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1459
+	 * gets the validation errors for ALL subsection
1460
+	 *
1461
+	 * @return EE_Validation_Error[]
1462
+	 * @throws EE_Error
1463
+	 */
1464
+	public function get_validation_errors_accumulated()
1465
+	{
1466
+		$validation_errors = $this->get_validation_errors();
1467
+		foreach ($this->get_validatable_subsections() as $subsection) {
1468
+			if ($subsection instanceof EE_Form_Section_Proper) {
1469
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1470
+			} else {
1471
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
1472
+			}
1473
+			if ($validation_errors_on_this_subsection) {
1474
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1475
+			}
1476
+		}
1477
+		return $validation_errors;
1478
+	}
1479
+
1480
+	/**
1481
+	 * Fetch validation errors from children and grandchildren and puts them in a single string.
1482
+	 * This traverses the form section tree to generate this, but you probably want to instead use
1483
+	 * get_form_submission_error_message() which is usually this message cached (or a custom validation error message)
1484
+	 *
1485
+	 * @return string
1486
+	 * @since 4.9.59.p
1487
+	 */
1488
+	protected function getAllValidationErrorsString()
1489
+	{
1490
+		$submission_error_messages = array();
1491
+		// bad, bad, bad registrant
1492
+		foreach ($this->get_validation_errors_accumulated() as $validation_error) {
1493
+			if ($validation_error instanceof EE_Validation_Error) {
1494
+				$form_section = $validation_error->get_form_section();
1495
+				if ($form_section instanceof EE_Form_Input_Base) {
1496
+					$label = $validation_error->get_form_section()->html_label_text();
1497
+				} elseif ($form_section instanceof EE_Form_Section_Validatable) {
1498
+					$label = $validation_error->get_form_section()->name();
1499
+				} else {
1500
+					$label = esc_html__('Unknown', 'event_espresso');
1501
+				}
1502
+				$submission_error_messages[] = sprintf(
1503
+					esc_html__('%s : %s', 'event_espresso'),
1504
+					$label,
1505
+					$validation_error->getMessage()
1506
+				);
1507
+			}
1508
+		}
1509
+		return implode('<br>', $submission_error_messages);
1510
+	}
1511
+
1512
+
1513
+	/**
1514
+	 * This isn't just the name of an input, it's a path pointing to an input. The
1515
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
1516
+	 * dot-dot-slash (../) means to ascend into the parent section.
1517
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1518
+	 * which will be returned.
1519
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1520
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1521
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1522
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1523
+	 * Etc
1524
+	 *
1525
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1526
+	 * @return EE_Form_Section_Base
1527
+	 * @throws EE_Error
1528
+	 */
1529
+	public function find_section_from_path($form_section_path)
1530
+	{
1531
+		// check if we can find the input from purely going straight up the tree
1532
+		$input = parent::find_section_from_path($form_section_path);
1533
+		if ($input instanceof EE_Form_Section_Base) {
1534
+			return $input;
1535
+		}
1536
+		$next_slash_pos = strpos($form_section_path, '/');
1537
+		if ($next_slash_pos !== false) {
1538
+			$child_section_name = substr($form_section_path, 0, $next_slash_pos);
1539
+			$subpath            = substr($form_section_path, $next_slash_pos + 1);
1540
+		} else {
1541
+			$child_section_name = $form_section_path;
1542
+			$subpath            = '';
1543
+		}
1544
+		$child_section = $this->get_subsection($child_section_name);
1545
+		if ($child_section instanceof EE_Form_Section_Base) {
1546
+			return $child_section->find_section_from_path($subpath);
1547
+		}
1548
+		return null;
1549
+	}
1550 1550
 }
Please login to merge, or discard this patch.
modules/venue_single/EED_Venue_Single.module.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function venue_location($content)
164 164
     {
165
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
165
+        return $content.EEH_Template::locate_template('content-espresso_venues-location.php');
166 166
     }
167 167
 
168 168
 
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
         // get some style
178 178
         if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
179 179
             // first check theme folder
180
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
180
+            if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
181 181
                 wp_register_style(
182 182
                     $this->theme,
183
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
183
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
184 184
                     array('dashicons', 'espresso_default')
185 185
                 );
186
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
186
+            } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) {
187 187
                 wp_register_style(
188 188
                     $this->theme,
189
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
189
+                    EE_TEMPLATES_URL.$this->theme.'/style.css',
190 190
                     array('dashicons', 'espresso_default')
191 191
                 );
192 192
             }
Please login to merge, or discard this patch.
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -28,173 +28,173 @@
 block discarded – undo
28 28
  */
29 29
 class EED_Venue_Single extends EED_Module
30 30
 {
31
-    /**
32
-     * @return EED_Venue_Single
33
-     */
34
-    public static function instance()
35
-    {
36
-        return parent::get_instance(__CLASS__);
37
-    }
38
-
39
-
40
-    /**
41
-     * set_hooks - for hooking into EE Core, other modules, etc
42
-     *
43
-     * @return void
44
-     * @throws InvalidArgumentException
45
-     * @throws InvalidDataTypeException
46
-     * @throws InvalidInterfaceException
47
-     */
48
-    public static function set_hooks()
49
-    {
50
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
51
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
52
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
53
-        );
54
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
55
-        EE_Config::register_route(
56
-            $custom_post_types['espresso_venues']['singular_slug'],
57
-            'Venue_Single',
58
-            'run'
59
-        );
60
-    }
61
-
62
-    /**
63
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
64
-     *
65
-     * @access    public
66
-     * @return    void
67
-     */
68
-    public static function set_hooks_admin()
69
-    {
70
-    }
71
-
72
-
73
-    /**
74
-     * run - initial module setup
75
-     *
76
-     * @access    public
77
-     * @param \WP $WP
78
-     */
79
-    public function run($WP)
80
-    {
81
-        // check what template is loaded
82
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
83
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
84
-    }
85
-
86
-
87
-    /**
88
-     * template_include
89
-     *
90
-     * @access public
91
-     * @param  string $template
92
-     * @return string
93
-     */
94
-    public function template_include($template)
95
-    {
96
-        // not a custom template?
97
-        if (
98
-            EE_Registry::instance()
99
-                       ->load_core('Front_Controller', array(), false, true)
100
-                       ->get_selected_template() != 'single-espresso_venues.php'
101
-        ) {
102
-            EEH_Template::load_espresso_theme_functions();
103
-            // then add extra event data via hooks
104
-            add_filter('the_title', array($this, 'the_title'), 100, 1);
105
-            add_filter('the_content', array($this, 'venue_details'), 100);
106
-            // don't display entry meta because the existing theme will take car of that
107
-            add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
108
-        }
109
-        return $template;
110
-    }
111
-
112
-
113
-    /**
114
-     * the_title
115
-     *
116
-     * @access public
117
-     * @param  string $title
118
-     * @return string
119
-     */
120
-    public function the_title($title = '')
121
-    {
122
-        return $title;
123
-    }
124
-
125
-
126
-    /**
127
-     *    venue_details
128
-     *
129
-     * @access public
130
-     * @param  string $content
131
-     * @return string
132
-     */
133
-    public function venue_details($content)
134
-    {
135
-        global $post;
136
-        if (
137
-            $post->post_type == 'espresso_venues'
138
-            && ! post_password_required()
139
-        ) {
140
-            // since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
141
-            // it uses the_content() for displaying the $post->post_content
142
-            // so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
143
-            // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
144
-            remove_filter('the_content', array($this, 'venue_details'), 100);
145
-            // add filters we want
146
-            add_filter('the_content', array($this, 'venue_location'), 110);
147
-            // now load our template
148
-            $template = EEH_Template::locate_template('content-espresso_venues-details.php');
149
-            // remove other filters we added so they won't get applied to the next post
150
-            remove_filter('the_content', array($this, 'venue_location'), 110);
151
-        }
152
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
153
-        return ! empty($template) ? $template : $content;
154
-    }
155
-
156
-
157
-    /**
158
-     * venue_location
159
-     *
160
-     * @access public
161
-     * @param  string $content
162
-     * @return string
163
-     */
164
-    public function venue_location($content)
165
-    {
166
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
167
-    }
168
-
169
-
170
-    /**
171
-     *    wp_enqueue_scripts
172
-     *
173
-     * @access public
174
-     * @return void
175
-     */
176
-    public function wp_enqueue_scripts()
177
-    {
178
-        // get some style
179
-        if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
180
-            // first check theme folder
181
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
182
-                wp_register_style(
183
-                    $this->theme,
184
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
185
-                    array('dashicons', 'espresso_default')
186
-                );
187
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
188
-                wp_register_style(
189
-                    $this->theme,
190
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
191
-                    array('dashicons', 'espresso_default')
192
-                );
193
-            }
194
-            wp_enqueue_style($this->theme);
195
-            if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
196
-                add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
197
-            }
198
-        }
199
-    }
31
+	/**
32
+	 * @return EED_Venue_Single
33
+	 */
34
+	public static function instance()
35
+	{
36
+		return parent::get_instance(__CLASS__);
37
+	}
38
+
39
+
40
+	/**
41
+	 * set_hooks - for hooking into EE Core, other modules, etc
42
+	 *
43
+	 * @return void
44
+	 * @throws InvalidArgumentException
45
+	 * @throws InvalidDataTypeException
46
+	 * @throws InvalidInterfaceException
47
+	 */
48
+	public static function set_hooks()
49
+	{
50
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
51
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
52
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
53
+		);
54
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
55
+		EE_Config::register_route(
56
+			$custom_post_types['espresso_venues']['singular_slug'],
57
+			'Venue_Single',
58
+			'run'
59
+		);
60
+	}
61
+
62
+	/**
63
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
64
+	 *
65
+	 * @access    public
66
+	 * @return    void
67
+	 */
68
+	public static function set_hooks_admin()
69
+	{
70
+	}
71
+
72
+
73
+	/**
74
+	 * run - initial module setup
75
+	 *
76
+	 * @access    public
77
+	 * @param \WP $WP
78
+	 */
79
+	public function run($WP)
80
+	{
81
+		// check what template is loaded
82
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
83
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
84
+	}
85
+
86
+
87
+	/**
88
+	 * template_include
89
+	 *
90
+	 * @access public
91
+	 * @param  string $template
92
+	 * @return string
93
+	 */
94
+	public function template_include($template)
95
+	{
96
+		// not a custom template?
97
+		if (
98
+			EE_Registry::instance()
99
+					   ->load_core('Front_Controller', array(), false, true)
100
+					   ->get_selected_template() != 'single-espresso_venues.php'
101
+		) {
102
+			EEH_Template::load_espresso_theme_functions();
103
+			// then add extra event data via hooks
104
+			add_filter('the_title', array($this, 'the_title'), 100, 1);
105
+			add_filter('the_content', array($this, 'venue_details'), 100);
106
+			// don't display entry meta because the existing theme will take car of that
107
+			add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
108
+		}
109
+		return $template;
110
+	}
111
+
112
+
113
+	/**
114
+	 * the_title
115
+	 *
116
+	 * @access public
117
+	 * @param  string $title
118
+	 * @return string
119
+	 */
120
+	public function the_title($title = '')
121
+	{
122
+		return $title;
123
+	}
124
+
125
+
126
+	/**
127
+	 *    venue_details
128
+	 *
129
+	 * @access public
130
+	 * @param  string $content
131
+	 * @return string
132
+	 */
133
+	public function venue_details($content)
134
+	{
135
+		global $post;
136
+		if (
137
+			$post->post_type == 'espresso_venues'
138
+			&& ! post_password_required()
139
+		) {
140
+			// since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
141
+			// it uses the_content() for displaying the $post->post_content
142
+			// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
143
+			// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
144
+			remove_filter('the_content', array($this, 'venue_details'), 100);
145
+			// add filters we want
146
+			add_filter('the_content', array($this, 'venue_location'), 110);
147
+			// now load our template
148
+			$template = EEH_Template::locate_template('content-espresso_venues-details.php');
149
+			// remove other filters we added so they won't get applied to the next post
150
+			remove_filter('the_content', array($this, 'venue_location'), 110);
151
+		}
152
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
153
+		return ! empty($template) ? $template : $content;
154
+	}
155
+
156
+
157
+	/**
158
+	 * venue_location
159
+	 *
160
+	 * @access public
161
+	 * @param  string $content
162
+	 * @return string
163
+	 */
164
+	public function venue_location($content)
165
+	{
166
+		return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
167
+	}
168
+
169
+
170
+	/**
171
+	 *    wp_enqueue_scripts
172
+	 *
173
+	 * @access public
174
+	 * @return void
175
+	 */
176
+	public function wp_enqueue_scripts()
177
+	{
178
+		// get some style
179
+		if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
180
+			// first check theme folder
181
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
182
+				wp_register_style(
183
+					$this->theme,
184
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
185
+					array('dashicons', 'espresso_default')
186
+				);
187
+			} elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
188
+				wp_register_style(
189
+					$this->theme,
190
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
191
+					array('dashicons', 'espresso_default')
192
+				);
193
+			}
194
+			wp_enqueue_style($this->theme);
195
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
196
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
197
+			}
198
+		}
199
+	}
200 200
 }
Please login to merge, or discard this patch.
modules/venues_archive/EED_Venues_Archive.module.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function venue_location($content)
172 172
     {
173
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
173
+        return $content.EEH_Template::locate_template('content-espresso_venues-location.php');
174 174
     }
175 175
 
176 176
 
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
         // get some style
186 186
         if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
187 187
             // first check theme folder
188
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
188
+            if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
189 189
                 wp_register_style(
190 190
                     $this->theme,
191
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
191
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
192 192
                     array('dashicons', 'espresso_default')
193 193
                 );
194
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
194
+            } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) {
195 195
                 wp_register_style(
196 196
                     $this->theme,
197
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
197
+                    EE_TEMPLATES_URL.$this->theme.'/style.css',
198 198
                     array('dashicons', 'espresso_default')
199 199
                 );
200 200
             }
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -28,178 +28,178 @@
 block discarded – undo
28 28
  */
29 29
 class EED_Venues_Archive extends EED_Module
30 30
 {
31
-    /**
32
-     * @return EED_Venues_Archive
33
-     */
34
-    public static function instance()
35
-    {
36
-        return parent::get_instance(__CLASS__);
37
-    }
38
-
39
-
40
-    /**
41
-     * set_hooks - for hooking into EE Core, other modules, etc
42
-     *
43
-     * @return void
44
-     * @throws InvalidArgumentException
45
-     * @throws InvalidDataTypeException
46
-     * @throws InvalidInterfaceException
47
-     */
48
-    public static function set_hooks()
49
-    {
50
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
51
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
52
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
53
-        );
54
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
55
-        EE_Config::register_route(
56
-            $custom_post_types['espresso_venues']['plural_slug'],
57
-            'Venues_Archive',
58
-            'run'
59
-        );
60
-    }
61
-
62
-    /**
63
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
64
-     *
65
-     * @access    public
66
-     * @return    void
67
-     */
68
-    public static function set_hooks_admin()
69
-    {
70
-    }
71
-
72
-
73
-    /**
74
-     * run - initial module setup
75
-     *
76
-     * @access    public
77
-     * @param \WP $WP
78
-     */
79
-    public function run($WP)
80
-    {
81
-        // check what template is loaded
82
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
83
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
84
-    }
85
-
86
-
87
-    /**
88
-     * template_include
89
-     *
90
-     * @access public
91
-     * @param  string $template
92
-     * @return string
93
-     */
94
-    public function template_include($template)
95
-    {
96
-        // not a custom template?
97
-        if (
98
-            EE_Registry::instance()->load_core('Front_Controller', array(), false, true)
99
-                                   ->get_selected_template() != 'archive-espresso_venues.php'
100
-        ) {
101
-            EEH_Template::load_espresso_theme_functions();
102
-            // then add extra event data via hooks
103
-            add_filter('the_title', array($this, 'the_title'), 100, 1);
104
-            // don't know if theme uses the_excerpt
105
-            add_filter('the_excerpt', array($this, 'venue_details'), 100);
106
-            // or the_content
107
-            add_filter('the_content', array($this, 'venue_details'), 100);
108
-            // don't display entry meta because the existing theme will take care of that
109
-            add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
110
-        }
111
-        return $template;
112
-    }
113
-
114
-
115
-    /**
116
-     * the_title
117
-     *
118
-     * @access public
119
-     * @param  string $title
120
-     * @return string
121
-     */
122
-    public function the_title($title = '')
123
-    {
124
-        return $title;
125
-    }
126
-
127
-
128
-    /**
129
-     *    venue_details
130
-     *
131
-     * @access public
132
-     * @param  string $content
133
-     * @return string
134
-     */
135
-    public function venue_details($content)
136
-    {
137
-        global $post;
138
-        if (
139
-            $post->post_type == 'espresso_venues'
140
-            && ! post_password_required()
141
-        ) {
142
-            // since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
143
-            // it uses the_content() for displaying the $post->post_content
144
-            // so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
145
-            // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
146
-            remove_filter('the_excerpt', array($this, 'venue_details'), 100);
147
-            remove_filter('the_content', array($this, 'venue_details'), 100);
148
-            // add filters we want
149
-            add_filter('the_content', array($this, 'venue_location'), 110);
150
-            add_filter('the_excerpt', array($this, 'venue_location'), 110);
151
-            // now load our template
152
-            $template = EEH_Template::locate_template('content-espresso_venues-details.php');
153
-            // now add our filter back in, plus some others
154
-            add_filter('the_excerpt', array($this, 'venue_details'), 100);
155
-            add_filter('the_content', array($this, 'venue_details'), 100);
156
-            // remove other filters we added so they won't get applied to the next post
157
-            remove_filter('the_content', array($this, 'venue_location'), 110);
158
-            remove_filter('the_excerpt', array($this, 'venue_location'), 110);
159
-            // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
160
-        }
161
-        return ! empty($template) ? $template : $content;
162
-    }
163
-
164
-
165
-    /**
166
-     * venue_location
167
-     *
168
-     * @access public
169
-     * @param  string $content
170
-     * @return string
171
-     */
172
-    public function venue_location($content)
173
-    {
174
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
175
-    }
176
-
177
-
178
-    /**
179
-     *    wp_enqueue_scripts
180
-     *
181
-     * @access    public
182
-     * @return    void
183
-     */
184
-    public function wp_enqueue_scripts()
185
-    {
186
-        // get some style
187
-        if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
188
-            // first check theme folder
189
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
190
-                wp_register_style(
191
-                    $this->theme,
192
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
193
-                    array('dashicons', 'espresso_default')
194
-                );
195
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
196
-                wp_register_style(
197
-                    $this->theme,
198
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
199
-                    array('dashicons', 'espresso_default')
200
-                );
201
-            }
202
-            wp_enqueue_style($this->theme);
203
-        }
204
-    }
31
+	/**
32
+	 * @return EED_Venues_Archive
33
+	 */
34
+	public static function instance()
35
+	{
36
+		return parent::get_instance(__CLASS__);
37
+	}
38
+
39
+
40
+	/**
41
+	 * set_hooks - for hooking into EE Core, other modules, etc
42
+	 *
43
+	 * @return void
44
+	 * @throws InvalidArgumentException
45
+	 * @throws InvalidDataTypeException
46
+	 * @throws InvalidInterfaceException
47
+	 */
48
+	public static function set_hooks()
49
+	{
50
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
51
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
52
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
53
+		);
54
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
55
+		EE_Config::register_route(
56
+			$custom_post_types['espresso_venues']['plural_slug'],
57
+			'Venues_Archive',
58
+			'run'
59
+		);
60
+	}
61
+
62
+	/**
63
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
64
+	 *
65
+	 * @access    public
66
+	 * @return    void
67
+	 */
68
+	public static function set_hooks_admin()
69
+	{
70
+	}
71
+
72
+
73
+	/**
74
+	 * run - initial module setup
75
+	 *
76
+	 * @access    public
77
+	 * @param \WP $WP
78
+	 */
79
+	public function run($WP)
80
+	{
81
+		// check what template is loaded
82
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
83
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
84
+	}
85
+
86
+
87
+	/**
88
+	 * template_include
89
+	 *
90
+	 * @access public
91
+	 * @param  string $template
92
+	 * @return string
93
+	 */
94
+	public function template_include($template)
95
+	{
96
+		// not a custom template?
97
+		if (
98
+			EE_Registry::instance()->load_core('Front_Controller', array(), false, true)
99
+								   ->get_selected_template() != 'archive-espresso_venues.php'
100
+		) {
101
+			EEH_Template::load_espresso_theme_functions();
102
+			// then add extra event data via hooks
103
+			add_filter('the_title', array($this, 'the_title'), 100, 1);
104
+			// don't know if theme uses the_excerpt
105
+			add_filter('the_excerpt', array($this, 'venue_details'), 100);
106
+			// or the_content
107
+			add_filter('the_content', array($this, 'venue_details'), 100);
108
+			// don't display entry meta because the existing theme will take care of that
109
+			add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
110
+		}
111
+		return $template;
112
+	}
113
+
114
+
115
+	/**
116
+	 * the_title
117
+	 *
118
+	 * @access public
119
+	 * @param  string $title
120
+	 * @return string
121
+	 */
122
+	public function the_title($title = '')
123
+	{
124
+		return $title;
125
+	}
126
+
127
+
128
+	/**
129
+	 *    venue_details
130
+	 *
131
+	 * @access public
132
+	 * @param  string $content
133
+	 * @return string
134
+	 */
135
+	public function venue_details($content)
136
+	{
137
+		global $post;
138
+		if (
139
+			$post->post_type == 'espresso_venues'
140
+			&& ! post_password_required()
141
+		) {
142
+			// since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
143
+			// it uses the_content() for displaying the $post->post_content
144
+			// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
145
+			// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
146
+			remove_filter('the_excerpt', array($this, 'venue_details'), 100);
147
+			remove_filter('the_content', array($this, 'venue_details'), 100);
148
+			// add filters we want
149
+			add_filter('the_content', array($this, 'venue_location'), 110);
150
+			add_filter('the_excerpt', array($this, 'venue_location'), 110);
151
+			// now load our template
152
+			$template = EEH_Template::locate_template('content-espresso_venues-details.php');
153
+			// now add our filter back in, plus some others
154
+			add_filter('the_excerpt', array($this, 'venue_details'), 100);
155
+			add_filter('the_content', array($this, 'venue_details'), 100);
156
+			// remove other filters we added so they won't get applied to the next post
157
+			remove_filter('the_content', array($this, 'venue_location'), 110);
158
+			remove_filter('the_excerpt', array($this, 'venue_location'), 110);
159
+			// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
160
+		}
161
+		return ! empty($template) ? $template : $content;
162
+	}
163
+
164
+
165
+	/**
166
+	 * venue_location
167
+	 *
168
+	 * @access public
169
+	 * @param  string $content
170
+	 * @return string
171
+	 */
172
+	public function venue_location($content)
173
+	{
174
+		return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
175
+	}
176
+
177
+
178
+	/**
179
+	 *    wp_enqueue_scripts
180
+	 *
181
+	 * @access    public
182
+	 * @return    void
183
+	 */
184
+	public function wp_enqueue_scripts()
185
+	{
186
+		// get some style
187
+		if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
188
+			// first check theme folder
189
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
190
+				wp_register_style(
191
+					$this->theme,
192
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
193
+					array('dashicons', 'espresso_default')
194
+				);
195
+			} elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
196
+				wp_register_style(
197
+					$this->theme,
198
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
199
+					array('dashicons', 'espresso_default')
200
+				);
201
+			}
202
+			wp_enqueue_style($this->theme);
203
+		}
204
+	}
205 205
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_8_0.dms.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 // unfortunately, this needs to be done upon INCLUSION of this file,
15 15
 // instead of construction, because it only gets constructed on first page load
16 16
 // (all other times it gets resurrected from a wordpress option)
17
-$stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*');
17
+$stages = glob(EE_CORE.'data_migration_scripts/4_8_0_stages/*');
18 18
 $class_to_filepath = array();
19 19
 foreach ($stages as $filepath) {
20 20
     $matches = array();
21 21
     preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
-    $class_to_filepath[ $matches[1] ] = $filepath;
22
+    $class_to_filepath[$matches[1]] = $filepath;
23 23
 }
24 24
 // give addons a chance to autoload their stages too
25 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
         if (version_compare($version_string, '4.8.0.decaf', '<') && version_compare($version_string, '4.7.0.decaf', '>=')) {
73 73
 //          echo "$version_string can be migrated from";
74 74
             return true;
75
-        } elseif (! $version_string) {
75
+        } elseif ( ! $version_string) {
76 76
 //          echo "no version string provided: $version_string";
77 77
             // no version string provided... this must be pre 4.3
78
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
78
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
79 79
         } else {
80 80
 //          echo "$version_string doesnt apply";
81 81
             return false;
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function schema_changes_before_migration()
91 91
     {
92
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
93 93
         $now_in_mysql = current_time('mysql', true);
94
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
94
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
95 95
         $table_name = 'esp_answer';
96 96
         $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
97 97
 					REG_ID int(10) unsigned NOT NULL,
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
             ),
686 686
         );
687 687
         global $wpdb;
688
-        $country_table = $wpdb->prefix . "esp_country";
688
+        $country_table = $wpdb->prefix."esp_country";
689 689
         $country_format = array(
690 690
             "CNT_ISO"         => '%s',
691 691
             "CNT_ISO3"        => '%s',
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
             foreach ($newer_countries as $country) {
706 706
                 $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
707 707
                 $countries = $wpdb->get_var($SQL);
708
-                if (! $countries) {
708
+                if ( ! $countries) {
709 709
                     $wpdb->insert(
710 710
                         $country_table,
711 711
                         array_combine(array_keys($country_format), $country),
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
             array('RSD', 'Dinar', 'Dinars', '', 3, 1),
733 733
         );
734 734
         global $wpdb;
735
-        $currency_table = $wpdb->prefix . "esp_currency";
735
+        $currency_table = $wpdb->prefix."esp_currency";
736 736
         $currency_format = array(
737 737
             "CUR_code"    => '%s',
738 738
             "CUR_single"  => '%s',
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
             foreach ($newer_currencies as $currency) {
746 746
                 $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
747 747
                 $countries = $wpdb->get_var($SQL);
748
-                if (! $countries) {
748
+                if ( ! $countries) {
749 749
                     $wpdb->insert(
750 750
                         $currency_table,
751 751
                         array_combine(array_keys($currency_format), $currency),
Please login to merge, or discard this patch.
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
 $stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*');
11 11
 $class_to_filepath = array();
12 12
 foreach ($stages as $filepath) {
13
-    $matches = array();
14
-    preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
15
-    $class_to_filepath[ $matches[1] ] = $filepath;
13
+	$matches = array();
14
+	preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
15
+	$class_to_filepath[ $matches[1] ] = $filepath;
16 16
 }
17 17
 // give addons a chance to autoload their stages too
18 18
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
@@ -34,71 +34,71 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base
36 36
 {
37
-    /**
38
-     * return EE_DMS_Core_4_8_0
39
-     *
40
-     * @param TableManager  $table_manager
41
-     * @param TableAnalysis $table_analysis
42
-     */
43
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
44
-    {
45
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso");
46
-        $this->_priority = 10;
47
-        $this->_migration_stages = array(
48
-            new EE_DMS_4_8_0_pretax_totals(),
49
-            new EE_DMS_4_8_0_event_subtotals(),
50
-        );
51
-        parent::__construct($table_manager, $table_analysis);
52
-    }
37
+	/**
38
+	 * return EE_DMS_Core_4_8_0
39
+	 *
40
+	 * @param TableManager  $table_manager
41
+	 * @param TableAnalysis $table_analysis
42
+	 */
43
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
44
+	{
45
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso");
46
+		$this->_priority = 10;
47
+		$this->_migration_stages = array(
48
+			new EE_DMS_4_8_0_pretax_totals(),
49
+			new EE_DMS_4_8_0_event_subtotals(),
50
+		);
51
+		parent::__construct($table_manager, $table_analysis);
52
+	}
53 53
 
54 54
 
55 55
 
56
-    /**
57
-     * Because this is being done at basically the same time as the MER-ready branch
58
-     * of core, it's possible people might have installed MEr-ready branch first,
59
-     * and then this one, in which case we still want to perform this migration,
60
-     * even though the version might not have increased
61
-     *
62
-     * @param array $version_array
63
-     * @return bool
64
-     */
65
-    public function can_migrate_from_version($version_array)
66
-    {
67
-        $version_string = $version_array['Core'];
68
-        if (version_compare($version_string, '4.8.0.decaf', '<') && version_compare($version_string, '4.7.0.decaf', '>=')) {
56
+	/**
57
+	 * Because this is being done at basically the same time as the MER-ready branch
58
+	 * of core, it's possible people might have installed MEr-ready branch first,
59
+	 * and then this one, in which case we still want to perform this migration,
60
+	 * even though the version might not have increased
61
+	 *
62
+	 * @param array $version_array
63
+	 * @return bool
64
+	 */
65
+	public function can_migrate_from_version($version_array)
66
+	{
67
+		$version_string = $version_array['Core'];
68
+		if (version_compare($version_string, '4.8.0.decaf', '<') && version_compare($version_string, '4.7.0.decaf', '>=')) {
69 69
 //          echo "$version_string can be migrated from";
70
-            return true;
71
-        } elseif (! $version_string) {
70
+			return true;
71
+		} elseif (! $version_string) {
72 72
 //          echo "no version string provided: $version_string";
73
-            // no version string provided... this must be pre 4.3
74
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
75
-        } else {
73
+			// no version string provided... this must be pre 4.3
74
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
75
+		} else {
76 76
 //          echo "$version_string doesnt apply";
77
-            return false;
78
-        }
79
-    }
77
+			return false;
78
+		}
79
+	}
80 80
 
81 81
 
82 82
 
83
-    /**
84
-     * @return bool
85
-     */
86
-    public function schema_changes_before_migration()
87
-    {
88
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
89
-        $now_in_mysql = current_time('mysql', true);
90
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
91
-        $table_name = 'esp_answer';
92
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
83
+	/**
84
+	 * @return bool
85
+	 */
86
+	public function schema_changes_before_migration()
87
+	{
88
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
89
+		$now_in_mysql = current_time('mysql', true);
90
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
91
+		$table_name = 'esp_answer';
92
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
93 93
 					REG_ID int(10) unsigned NOT NULL,
94 94
 					QST_ID int(10) unsigned NOT NULL,
95 95
 					ANS_value text NOT NULL,
96 96
 					PRIMARY KEY  (ANS_ID),
97 97
 					KEY REG_ID (REG_ID),
98 98
 					KEY QST_ID (QST_ID)";
99
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
100
-        $table_name = 'esp_attendee_meta';
101
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
99
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
100
+		$table_name = 'esp_attendee_meta';
101
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
102 102
 						ATT_ID bigint(20) unsigned NOT NULL,
103 103
 						ATT_fname varchar(45) NOT NULL,
104 104
 						ATT_lname varchar(45) NOT	NULL,
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 							PRIMARY KEY  (ATTM_ID),
114 114
 								KEY ATT_ID (ATT_ID),
115 115
 								KEY ATT_email (ATT_email(191))";
116
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
117
-        $table_name = 'esp_country';
118
-        $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL,
116
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
117
+		$table_name = 'esp_country';
118
+		$sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL,
119 119
 					  CNT_ISO3 varchar(3) collate utf8_bin NOT NULL,
120 120
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
121 121
 					  CNT_name varchar(45) collate utf8_bin NOT NULL,
@@ -131,18 +131,18 @@  discard block
 block discarded – undo
131 131
 					  CNT_is_EU tinyint(1) DEFAULT '0',
132 132
 					  CNT_active tinyint(1) DEFAULT '0',
133 133
 					  PRIMARY KEY  (CNT_ISO)";
134
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
135
-        $table_name = 'esp_currency';
136
-        $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
134
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
135
+		$table_name = 'esp_currency';
136
+		$sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
137 137
 				CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar',
138 138
 				CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars',
139 139
 				CUR_sign varchar(45) collate utf8_bin DEFAULT '$',
140 140
 				CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2',
141 141
 				CUR_active tinyint(1) DEFAULT '0',
142 142
 				PRIMARY KEY  (CUR_code)";
143
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
144
-        $table_name = 'esp_datetime';
145
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
143
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
144
+		$table_name = 'esp_datetime';
145
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
146 146
 				  EVT_ID bigint(20) unsigned NOT NULL,
147 147
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
148 148
 				  DTT_description text NOT NULL,
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
 						KEY DTT_EVT_start (DTT_EVT_start),
159 159
 						KEY EVT_ID (EVT_ID),
160 160
 						KEY DTT_is_primary (DTT_is_primary)";
161
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
162
-        $table_name = 'esp_event_meta';
163
-        $sql = "
161
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
162
+		$table_name = 'esp_event_meta';
163
+		$sql = "
164 164
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
165 165
 			EVT_ID bigint(20) unsigned NOT NULL,
166 166
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -176,34 +176,34 @@  discard block
 block discarded – undo
176 176
 			EVT_donations tinyint(1) NULL,
177 177
 			PRIMARY KEY  (EVTM_ID),
178 178
 			KEY EVT_ID (EVT_ID)";
179
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
180
-        $table_name = 'esp_event_question_group';
181
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
179
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
180
+		$table_name = 'esp_event_question_group';
181
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
182 182
 					EVT_ID bigint(20) unsigned NOT NULL,
183 183
 					QSG_ID int(10) unsigned NOT NULL,
184 184
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
185 185
 					PRIMARY KEY  (EQG_ID),
186 186
 					KEY EVT_ID (EVT_ID),
187 187
 					KEY QSG_ID (QSG_ID)";
188
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
189
-        $table_name = 'esp_event_venue';
190
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
188
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
189
+		$table_name = 'esp_event_venue';
190
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
191 191
 				EVT_ID bigint(20) unsigned NOT NULL,
192 192
 				VNU_ID bigint(20) unsigned NOT NULL,
193 193
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
194 194
 				PRIMARY KEY  (EVV_ID)";
195
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
196
-        $table_name = 'esp_extra_meta';
197
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
195
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
196
+		$table_name = 'esp_extra_meta';
197
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
198 198
 				OBJ_ID int(11) DEFAULT NULL,
199 199
 				EXM_type varchar(45) DEFAULT NULL,
200 200
 				EXM_key varchar(45) DEFAULT NULL,
201 201
 				EXM_value text,
202 202
 				PRIMARY KEY  (EXM_ID),
203 203
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
204
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205
-        $table_name = 'esp_extra_join';
206
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
204
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205
+		$table_name = 'esp_extra_join';
206
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
207 207
 				EXJ_first_model_id varchar(6) NOT NULL,
208 208
 				EXJ_first_model_name varchar(20) NOT NULL,
209 209
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 				PRIMARY KEY  (EXJ_ID),
212 212
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
213 213
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
214
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
215
-        $table_name = 'esp_line_item';
216
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
214
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
215
+		$table_name = 'esp_line_item';
216
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
217 217
 				LIN_code varchar(245) NOT NULL DEFAULT '',
218 218
 				TXN_ID int(11) DEFAULT NULL,
219 219
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 				PRIMARY KEY  (LIN_ID),
233 233
 				KEY LIN_code (LIN_code(191)),
234 234
 				KEY TXN_ID (TXN_ID)";
235
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
236
-        $table_name = 'esp_log';
237
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
235
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
236
+		$table_name = 'esp_log';
237
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
238 238
 				LOG_time datetime DEFAULT NULL,
239 239
 				OBJ_ID varchar(45) DEFAULT NULL,
240 240
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -245,18 +245,18 @@  discard block
 block discarded – undo
245 245
 				KEY LOG_time (LOG_time),
246 246
 				KEY OBJ (OBJ_type,OBJ_ID),
247 247
 				KEY LOG_type (LOG_type)";
248
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
249
-        $table_name = 'esp_message_template';
250
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
248
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
249
+		$table_name = 'esp_message_template';
250
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
251 251
 					GRP_ID int(10) unsigned NOT NULL,
252 252
 					MTP_context varchar(50) NOT NULL,
253 253
 					MTP_template_field varchar(30) NOT NULL,
254 254
 					MTP_content text NOT NULL,
255 255
 					PRIMARY KEY  (MTP_ID),
256 256
 					KEY GRP_ID (GRP_ID)";
257
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
258
-        $table_name = 'esp_message_template_group';
259
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
257
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
258
+		$table_name = 'esp_message_template_group';
259
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
260 260
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
261 261
 					MTP_name varchar(245) NOT NULL DEFAULT '',
262 262
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -268,17 +268,17 @@  discard block
 block discarded – undo
268 268
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
269 269
 					PRIMARY KEY  (GRP_ID),
270 270
 					KEY MTP_user_id (MTP_user_id)";
271
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
272
-        $table_name = 'esp_event_message_template';
273
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
271
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
272
+		$table_name = 'esp_event_message_template';
273
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
274 274
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
275 275
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
276 276
 					PRIMARY KEY  (EMT_ID),
277 277
 					KEY EVT_ID (EVT_ID),
278 278
 					KEY GRP_ID (GRP_ID)";
279
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
280
-        $table_name = 'esp_payment';
281
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
279
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
280
+		$table_name = 'esp_payment';
281
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
282 282
 					TXN_ID int(10) unsigned DEFAULT NULL,
283 283
 					STS_ID varchar(3) collate utf8_bin DEFAULT NULL,
284 284
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 					PRIMARY KEY  (PAY_ID),
296 296
 					KEY PAY_timestamp (PAY_timestamp),
297 297
 					KEY TXN_ID (TXN_ID)";
298
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
299
-        $table_name = 'esp_payment_method';
300
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
298
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
299
+		$table_name = 'esp_payment_method';
300
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
301 301
 				PMD_type varchar(124) DEFAULT NULL,
302 302
 				PMD_name varchar(255) DEFAULT NULL,
303 303
 				PMD_desc text,
@@ -313,32 +313,32 @@  discard block
 block discarded – undo
313 313
 				PRIMARY KEY  (PMD_ID),
314 314
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
315 315
 				KEY PMD_type (PMD_type)";
316
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
317
-        $table_name = "esp_ticket_price";
318
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
316
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
317
+		$table_name = "esp_ticket_price";
318
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
319 319
 					  TKT_ID int(10) unsigned NOT NULL,
320 320
 					  PRC_ID int(10) unsigned NOT NULL,
321 321
 					  PRIMARY KEY  (TKP_ID),
322 322
 					  KEY TKT_ID (TKT_ID),
323 323
 					  KEY PRC_ID (PRC_ID)";
324
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
325
-        $table_name = "esp_datetime_ticket";
326
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
324
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
325
+		$table_name = "esp_datetime_ticket";
326
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
327 327
 					  DTT_ID int(10) unsigned NOT NULL,
328 328
 					  TKT_ID int(10) unsigned NOT NULL,
329 329
 					  PRIMARY KEY  (DTK_ID),
330 330
 					  KEY DTT_ID (DTT_ID),
331 331
 					  KEY TKT_ID (TKT_ID)";
332
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
333
-        $table_name = "esp_ticket_template";
334
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
332
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
333
+		$table_name = "esp_ticket_template";
334
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
335 335
 					  TTM_name varchar(45) NOT NULL,
336 336
 					  TTM_description text,
337 337
 					  TTM_file varchar(45),
338 338
 					  PRIMARY KEY  (TTM_ID)";
339
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
340
-        $table_name = 'esp_question';
341
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
339
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
340
+		$table_name = 'esp_question';
341
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
342 342
 					QST_display_text text NOT NULL,
343 343
 					QST_admin_label varchar(255) NOT NULL,
344 344
 					QST_system varchar(25) NOT NULL DEFAULT "",
@@ -352,18 +352,18 @@  discard block
 block discarded – undo
352 352
 					QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
353 353
 					PRIMARY KEY  (QST_ID),
354 354
 					KEY QST_order (QST_order)';
355
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
356
-        $table_name = 'esp_question_group_question';
357
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
355
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
356
+		$table_name = 'esp_question_group_question';
357
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
358 358
 					QSG_ID int(10) unsigned NOT NULL,
359 359
 					QST_ID int(10) unsigned NOT NULL,
360 360
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
361 361
 					PRIMARY KEY  (QGQ_ID),
362 362
 					KEY QST_ID (QST_ID),
363 363
 					KEY QSG_ID_order (QSG_ID,QGQ_order)";
364
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
365
-        $table_name = 'esp_question_option';
366
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
364
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
365
+		$table_name = 'esp_question_option';
366
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
367 367
 					QSO_value varchar(255) NOT NULL,
368 368
 					QSO_desc text NOT NULL,
369 369
 					QST_ID int(10) unsigned NOT NULL,
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
 					PRIMARY KEY  (QSO_ID),
374 374
 					KEY QST_ID (QST_ID),
375 375
 					KEY QSO_order (QSO_order)";
376
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
377
-        $table_name = 'esp_registration';
378
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
376
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
377
+		$table_name = 'esp_registration';
378
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
379 379
 					  EVT_ID bigint(20) unsigned NOT NULL,
380 380
 					  ATT_ID bigint(20) unsigned NOT NULL,
381 381
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -399,18 +399,18 @@  discard block
 block discarded – undo
399 399
 					  KEY TKT_ID (TKT_ID),
400 400
 					  KEY EVT_ID (EVT_ID),
401 401
 					  KEY STS_ID (STS_ID)";
402
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
403
-        $table_name = 'esp_registration_payment';
404
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
402
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
403
+		$table_name = 'esp_registration_payment';
404
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
405 405
 					  REG_ID int(10) unsigned NOT NULL,
406 406
 					  PAY_ID int(10) unsigned NULL,
407 407
 					  RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00',
408 408
 					  PRIMARY KEY  (RPY_ID),
409 409
 					  KEY REG_ID (REG_ID),
410 410
 					  KEY PAY_ID (PAY_ID)";
411
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
412
-        $table_name = 'esp_checkin';
413
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
411
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
412
+		$table_name = 'esp_checkin';
413
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
414 414
 					REG_ID int(10) unsigned NOT NULL,
415 415
 					DTT_ID int(10) unsigned NOT NULL,
416 416
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 					PRIMARY KEY  (CHK_ID),
419 419
 					KEY REG_ID (REG_ID),
420 420
 					KEY DTT_ID (DTT_ID)";
421
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
422
-        $table_name = 'esp_state';
423
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
421
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
422
+		$table_name = 'esp_state';
423
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
424 424
 					  CNT_ISO varchar(2) collate utf8_bin NOT NULL,
425 425
 					  STA_abbrev varchar(24) collate utf8_bin NOT NULL,
426 426
 					  STA_name varchar(100) collate utf8_bin NOT NULL,
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
 					  PRIMARY KEY  (STA_ID),
429 429
 					  KEY STA_abbrev (STA_abbrev),
430 430
 					  KEY CNT_ISO (CNT_ISO)";
431
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
432
-        $table_name = 'esp_status';
433
-        $sql = "STS_ID varchar(3) NOT NULL,
431
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
432
+		$table_name = 'esp_status';
433
+		$sql = "STS_ID varchar(3) NOT NULL,
434 434
 					  STS_code varchar(45) NOT NULL,
435 435
 					  STS_type varchar(45) NOT NULL,
436 436
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
439 439
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
440 440
 					  KEY STS_type (STS_type)";
441
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
442
-        $table_name = 'esp_transaction';
443
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
441
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
442
+		$table_name = 'esp_transaction';
443
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
444 444
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
445 445
 					  TXN_total decimal(10,3) DEFAULT '0.00',
446 446
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -452,9 +452,9 @@  discard block
 block discarded – undo
452 452
 					  PRIMARY KEY  (TXN_ID),
453 453
 					  KEY TXN_timestamp (TXN_timestamp),
454 454
 					  KEY STS_ID (STS_ID)";
455
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
456
-        $table_name = 'esp_venue_meta';
457
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
455
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
456
+		$table_name = 'esp_venue_meta';
457
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
458 458
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
459 459
 			VNU_address varchar(255) DEFAULT NULL,
460 460
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
 			KEY VNU_ID (VNU_ID),
474 474
 			KEY STA_ID (STA_ID),
475 475
 			KEY CNT_ISO (CNT_ISO)";
476
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
477
-        // modified tables
478
-        $table_name = "esp_price";
479
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
476
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
477
+		// modified tables
478
+		$table_name = "esp_price";
479
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
480 480
 					  PRT_ID tinyint(3) unsigned NOT NULL,
481 481
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
482 482
 					  PRC_name varchar(245) NOT NULL,
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
 					  PRC_parent int(10) unsigned DEFAULT 0,
490 490
 					  PRIMARY KEY  (PRC_ID),
491 491
 					  KEY PRT_ID (PRT_ID)";
492
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
493
-        $table_name = "esp_price_type";
494
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
492
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
493
+		$table_name = "esp_price_type";
494
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
495 495
 				  PRT_name varchar(45) NOT NULL,
496 496
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
497 497
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
501 501
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
502 502
 				  PRIMARY KEY  (PRT_ID)";
503
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
504
-        $table_name = "esp_ticket";
505
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
503
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
504
+		$table_name = "esp_ticket";
505
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
506 506
 					  TTM_ID int(10) unsigned NOT NULL,
507 507
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
508 508
 					  TKT_description text NOT NULL,
@@ -524,9 +524,9 @@  discard block
 block discarded – undo
524 524
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
525 525
 					  PRIMARY KEY  (TKT_ID),
526 526
 					  KEY TKT_start_date (TKT_start_date)";
527
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
528
-        $table_name = 'esp_question_group';
529
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
527
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
528
+		$table_name = 'esp_question_group';
529
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
530 530
 					QSG_name varchar(255) NOT NULL,
531 531
 					QSG_identifier varchar(100) NOT NULL,
532 532
 					QSG_desc text NULL,
@@ -539,223 +539,223 @@  discard block
 block discarded – undo
539 539
 					PRIMARY KEY  (QSG_ID),
540 540
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
541 541
 					KEY QSG_order (QSG_order)';
542
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
543
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
544
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
545
-        // (because many need to convert old string states to foreign keys into the states table)
546
-        $script_4_1_defaults->insert_default_states();
547
-        $script_4_1_defaults->insert_default_countries();
548
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
549
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
550
-        $script_4_5_defaults->insert_default_price_types();
551
-        $script_4_5_defaults->insert_default_prices();
552
-        $script_4_5_defaults->insert_default_tickets();
553
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
554
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
555
-        $script_4_6_defaults->add_default_admin_only_payments();
556
-        $script_4_6_defaults->insert_default_currencies();
557
-        $this->verify_new_countries();
558
-        $this->verify_new_currencies();
559
-        return true;
560
-    }
542
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
543
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
544
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
545
+		// (because many need to convert old string states to foreign keys into the states table)
546
+		$script_4_1_defaults->insert_default_states();
547
+		$script_4_1_defaults->insert_default_countries();
548
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
549
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
550
+		$script_4_5_defaults->insert_default_price_types();
551
+		$script_4_5_defaults->insert_default_prices();
552
+		$script_4_5_defaults->insert_default_tickets();
553
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
554
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
555
+		$script_4_6_defaults->add_default_admin_only_payments();
556
+		$script_4_6_defaults->insert_default_currencies();
557
+		$this->verify_new_countries();
558
+		$this->verify_new_currencies();
559
+		return true;
560
+	}
561 561
 
562 562
 
563 563
 
564
-    /**
565
-     * @return boolean
566
-     */
567
-    public function schema_changes_after_migration()
568
-    {
569
-        $this->fix_non_default_taxes();
570
-        // this is actually the same as the last DMS
571
-        /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */
572
-        $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0');
573
-        return $script_4_7_defaults->schema_changes_after_migration();
574
-    }
564
+	/**
565
+	 * @return boolean
566
+	 */
567
+	public function schema_changes_after_migration()
568
+	{
569
+		$this->fix_non_default_taxes();
570
+		// this is actually the same as the last DMS
571
+		/** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */
572
+		$script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0');
573
+		return $script_4_7_defaults->schema_changes_after_migration();
574
+	}
575 575
 
576 576
 
577 577
 
578
-    public function migration_page_hooks()
579
-    {
580
-    }
578
+	public function migration_page_hooks()
579
+	{
580
+	}
581 581
 
582 582
 
583 583
 
584
-    /**
585
-     * verifies each of the new countries exists that somehow we missed in 4.1
586
-     */
587
-    public function verify_new_countries()
588
-    {
589
-        // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
590
-        // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
591
-        // currency symbols: http://www.xe.com/symbols.php
592
-        // CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active
593
-        // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
594
-        $newer_countries = array(
595
-            array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
596
-            array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
597
-            array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
598
-            array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
599
-            array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
600
-            array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
601
-            array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
602
-            array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
603
-            array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
604
-            array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
605
-            array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
606
-            array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
607
-            array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
608
-            array(
609
-                'BQ',
610
-                'BES',
611
-                0,
612
-                'Bonaire, Saint Eustatius and Saba',
613
-                'USD',
614
-                'Dollar',
615
-                'Dollars',
616
-                '$',
617
-                1,
618
-                2,
619
-                '+599',
620
-                0,
621
-                0,
622
-            ),
623
-            array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
624
-            array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
625
-            array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
626
-            array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
627
-            array(
628
-                'HM',
629
-                'HMD',
630
-                0,
631
-                'Heard Island and McDonald Islands',
632
-                'AUD',
633
-                'Dollar',
634
-                'Dollars',
635
-                '$',
636
-                1,
637
-                2,
638
-                '+891',
639
-                0,
640
-                0,
641
-            ),
642
-            array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
643
-            array(
644
-                'GS',
645
-                'SGS',
646
-                0,
647
-                'South Georgia and the South Sandwich Islands',
648
-                'GBP',
649
-                'Pound',
650
-                'Pounds',
651
-                '£',
652
-                1,
653
-                2,
654
-                '+500',
655
-                0,
656
-                0,
657
-            ),
658
-            array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
659
-            array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
660
-            array(
661
-                'UM',
662
-                'UMI',
663
-                0,
664
-                'United States Minor Outlying Islands',
665
-                'USD',
666
-                'Dollar',
667
-                'Dollars',
668
-                '$',
669
-                1,
670
-                2,
671
-                '+1',
672
-                0,
673
-                0,
674
-            ),
675
-        );
676
-        global $wpdb;
677
-        $country_table = $wpdb->prefix . "esp_country";
678
-        $country_format = array(
679
-            "CNT_ISO"         => '%s',
680
-            "CNT_ISO3"        => '%s',
681
-            "RGN_ID"          => '%d',
682
-            "CNT_name"        => '%s',
683
-            "CNT_cur_code"    => '%s',
684
-            "CNT_cur_single"  => '%s',
685
-            "CNT_cur_plural"  => '%s',
686
-            "CNT_cur_sign"    => '%s',
687
-            "CNT_cur_sign_b4" => '%d',
688
-            "CNT_cur_dec_plc" => '%d',
689
-            "CNT_tel_code"    => '%s',
690
-            "CNT_is_EU"       => '%d',
691
-            "CNT_active"      => '%d',
692
-        );
693
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
694
-            foreach ($newer_countries as $country) {
695
-                $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
696
-                $countries = $wpdb->get_var($SQL);
697
-                if (! $countries) {
698
-                    $wpdb->insert(
699
-                        $country_table,
700
-                        array_combine(array_keys($country_format), $country),
701
-                        $country_format
702
-                    );
703
-                }
704
-            }
705
-        }
706
-    }
584
+	/**
585
+	 * verifies each of the new countries exists that somehow we missed in 4.1
586
+	 */
587
+	public function verify_new_countries()
588
+	{
589
+		// a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
590
+		// how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
591
+		// currency symbols: http://www.xe.com/symbols.php
592
+		// CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active
593
+		// ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
594
+		$newer_countries = array(
595
+			array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
596
+			array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
597
+			array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
598
+			array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
599
+			array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
600
+			array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
601
+			array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
602
+			array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
603
+			array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
604
+			array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
605
+			array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
606
+			array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
607
+			array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
608
+			array(
609
+				'BQ',
610
+				'BES',
611
+				0,
612
+				'Bonaire, Saint Eustatius and Saba',
613
+				'USD',
614
+				'Dollar',
615
+				'Dollars',
616
+				'$',
617
+				1,
618
+				2,
619
+				'+599',
620
+				0,
621
+				0,
622
+			),
623
+			array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
624
+			array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
625
+			array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
626
+			array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
627
+			array(
628
+				'HM',
629
+				'HMD',
630
+				0,
631
+				'Heard Island and McDonald Islands',
632
+				'AUD',
633
+				'Dollar',
634
+				'Dollars',
635
+				'$',
636
+				1,
637
+				2,
638
+				'+891',
639
+				0,
640
+				0,
641
+			),
642
+			array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
643
+			array(
644
+				'GS',
645
+				'SGS',
646
+				0,
647
+				'South Georgia and the South Sandwich Islands',
648
+				'GBP',
649
+				'Pound',
650
+				'Pounds',
651
+				'£',
652
+				1,
653
+				2,
654
+				'+500',
655
+				0,
656
+				0,
657
+			),
658
+			array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
659
+			array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
660
+			array(
661
+				'UM',
662
+				'UMI',
663
+				0,
664
+				'United States Minor Outlying Islands',
665
+				'USD',
666
+				'Dollar',
667
+				'Dollars',
668
+				'$',
669
+				1,
670
+				2,
671
+				'+1',
672
+				0,
673
+				0,
674
+			),
675
+		);
676
+		global $wpdb;
677
+		$country_table = $wpdb->prefix . "esp_country";
678
+		$country_format = array(
679
+			"CNT_ISO"         => '%s',
680
+			"CNT_ISO3"        => '%s',
681
+			"RGN_ID"          => '%d',
682
+			"CNT_name"        => '%s',
683
+			"CNT_cur_code"    => '%s',
684
+			"CNT_cur_single"  => '%s',
685
+			"CNT_cur_plural"  => '%s',
686
+			"CNT_cur_sign"    => '%s',
687
+			"CNT_cur_sign_b4" => '%d',
688
+			"CNT_cur_dec_plc" => '%d',
689
+			"CNT_tel_code"    => '%s',
690
+			"CNT_is_EU"       => '%d',
691
+			"CNT_active"      => '%d',
692
+		);
693
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
694
+			foreach ($newer_countries as $country) {
695
+				$SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
696
+				$countries = $wpdb->get_var($SQL);
697
+				if (! $countries) {
698
+					$wpdb->insert(
699
+						$country_table,
700
+						array_combine(array_keys($country_format), $country),
701
+						$country_format
702
+					);
703
+				}
704
+			}
705
+		}
706
+	}
707 707
 
708 708
 
709 709
 
710
-    /**
711
-     * verifies each of the new currencies exists that somehow we missed in 4.6
712
-     */
713
-    public function verify_new_currencies()
714
-    {
715
-        // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
716
-        // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
717
-        // currency symbols: http://www.xe.com/symbols.php
718
-        // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
719
-        // ( 'EUR',  'Euro',  'Euros',  '€',  2,1),
720
-        $newer_currencies = array(
721
-            array('RSD', 'Dinar', 'Dinars', '', 3, 1),
722
-        );
723
-        global $wpdb;
724
-        $currency_table = $wpdb->prefix . "esp_currency";
725
-        $currency_format = array(
726
-            "CUR_code"    => '%s',
727
-            "CUR_single"  => '%s',
728
-            "CUR_plural"  => '%s',
729
-            "CUR_sign"    => '%s',
730
-            "CUR_dec_plc" => '%d',
731
-            "CUR_active"  => '%d',
732
-        );
733
-        if ($this->_get_table_analysis()->tableExists($currency_table)) {
734
-            foreach ($newer_currencies as $currency) {
735
-                $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
736
-                $countries = $wpdb->get_var($SQL);
737
-                if (! $countries) {
738
-                    $wpdb->insert(
739
-                        $currency_table,
740
-                        array_combine(array_keys($currency_format), $currency),
741
-                        $currency_format
742
-                    );
743
-                }
744
-            }
745
-        }
746
-    }
710
+	/**
711
+	 * verifies each of the new currencies exists that somehow we missed in 4.6
712
+	 */
713
+	public function verify_new_currencies()
714
+	{
715
+		// a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028
716
+		// how many decimal places? https://en.wikipedia.org/wiki/ISO_4217
717
+		// currency symbols: http://www.xe.com/symbols.php
718
+		// CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
719
+		// ( 'EUR',  'Euro',  'Euros',  '€',  2,1),
720
+		$newer_currencies = array(
721
+			array('RSD', 'Dinar', 'Dinars', '', 3, 1),
722
+		);
723
+		global $wpdb;
724
+		$currency_table = $wpdb->prefix . "esp_currency";
725
+		$currency_format = array(
726
+			"CUR_code"    => '%s',
727
+			"CUR_single"  => '%s',
728
+			"CUR_plural"  => '%s',
729
+			"CUR_sign"    => '%s',
730
+			"CUR_dec_plc" => '%d',
731
+			"CUR_active"  => '%d',
732
+		);
733
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
734
+			foreach ($newer_currencies as $currency) {
735
+				$SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
736
+				$countries = $wpdb->get_var($SQL);
737
+				if (! $countries) {
738
+					$wpdb->insert(
739
+						$currency_table,
740
+						array_combine(array_keys($currency_format), $currency),
741
+						$currency_format
742
+					);
743
+				}
744
+			}
745
+		}
746
+	}
747 747
 
748 748
 
749 749
 
750
-    /**
751
-     * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
752
-     * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
753
-     * we should be able to stop doing this in 4.9
754
-     */
755
-    public function fix_non_default_taxes()
756
-    {
757
-        global $wpdb;
758
-        $query = $wpdb->prepare("UPDATE
750
+	/**
751
+	 * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
752
+	 * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
753
+	 * we should be able to stop doing this in 4.9
754
+	 */
755
+	public function fix_non_default_taxes()
756
+	{
757
+		global $wpdb;
758
+		$query = $wpdb->prepare("UPDATE
759 759
 				{$wpdb->prefix}esp_price p INNER JOIN
760 760
 				{$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID
761 761
 			SET
@@ -764,6 +764,6 @@  discard block
 block discarded – undo
764 764
 				p.PRC_is_default = 0 AND
765 765
 				pt.PBT_ID = %d
766 766
 					", EEM_Price_Type::base_type_tax);
767
-        $wpdb->query($query);
768
-    }
767
+		$wpdb->query($query);
768
+	}
769 769
 }
Please login to merge, or discard this patch.