Completed
Branch 973/fix-visible-recaptcha (0580c7)
by
unknown
03:03 queued 30s
created
payment_methods/Paypal_Express/EE_PMT_Paypal_Express.pm.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -15,89 +15,89 @@
 block discarded – undo
15 15
 class EE_PMT_Paypal_Express extends EE_PMT_Base
16 16
 {
17 17
 
18
-    /**
19
-     * EE_PMT_Paypal_Express constructor.
20
-     */
21
-    public function __construct($pm_instance = null)
22
-    {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
24
-        $this->_gateway = new EEG_Paypal_Express();
18
+	/**
19
+	 * EE_PMT_Paypal_Express constructor.
20
+	 */
21
+	public function __construct($pm_instance = null)
22
+	{
23
+		require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
24
+		$this->_gateway = new EEG_Paypal_Express();
25 25
 
26
-        $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
-        $this->_template_path = $this->file_folder() . 'templates/';
28
-        $this->_default_description = esc_html__(
29
-            // @codingStandardsIgnoreStart
30
-            'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31
-            // @codingStandardsIgnoreEnd
32
-            'event_espresso'
33
-        );
34
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
26
+		$this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
+		$this->_template_path = $this->file_folder() . 'templates/';
28
+		$this->_default_description = esc_html__(
29
+			// @codingStandardsIgnoreStart
30
+			'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31
+			// @codingStandardsIgnoreEnd
32
+			'event_espresso'
33
+		);
34
+		$this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
35 35
 
36
-        parent::__construct($pm_instance);
37
-    }
36
+		parent::__construct($pm_instance);
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * Adds the help tab.
42
-     *
43
-     * @see EE_PMT_Base::help_tabs_config()
44
-     * @return array
45
-     */
46
-    public function help_tabs_config()
47
-    {
48
-        return array(
49
-            $this->get_help_tab_name() => array(
50
-                'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
51
-                'filename' => 'payment_methods_overview_paypal_express'
52
-            )
53
-        );
54
-    }
40
+	/**
41
+	 * Adds the help tab.
42
+	 *
43
+	 * @see EE_PMT_Base::help_tabs_config()
44
+	 * @return array
45
+	 */
46
+	public function help_tabs_config()
47
+	{
48
+		return array(
49
+			$this->get_help_tab_name() => array(
50
+				'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
51
+				'filename' => 'payment_methods_overview_paypal_express'
52
+			)
53
+		);
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * Gets the form for all the settings related to this payment method type.
59
-     *
60
-     * @return EE_Payment_Method_Form
61
-     */
62
-    public function generate_new_settings_form()
63
-    {
64
-        return new SettingsForm(array(), $this->get_help_tab_link());
65
-    }
57
+	/**
58
+	 * Gets the form for all the settings related to this payment method type.
59
+	 *
60
+	 * @return EE_Payment_Method_Form
61
+	 */
62
+	public function generate_new_settings_form()
63
+	{
64
+		return new SettingsForm(array(), $this->get_help_tab_link());
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * Creates a billing form for this payment method type.
70
-     *
71
-     * @param \EE_Transaction $transaction
72
-     * @return \EE_Billing_Info_Form
73
-     */
74
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
75
-    {
76
-        if ($this->_pm_instance->debug_mode()) {
77
-            $form = new EE_Billing_Info_Form(
78
-                $this->_pm_instance,
79
-                array(
80
-                    'name' => 'paypal_express_Info_Form',
81
-                    'subsections' => array(
82
-                        'paypal_express_debug_info' => new EE_Form_Section_Proper(
83
-                            array(
84
-                                'layout_strategy' => new EE_Template_Layout(
85
-                                    array(
86
-                                        'layout_template_file' => $this->_template_path
87
-                                                                    . 'paypal_express_debug_info.template.php',
88
-                                        'template_args'        => array(
89
-                                            'debug_mode' => $this->_pm_instance->debug_mode()
90
-                                        )
91
-                                    )
92
-                                )
93
-                            )
94
-                        )
95
-                    )
96
-                )
97
-            );
98
-            return $form;
99
-        }
68
+	/**
69
+	 * Creates a billing form for this payment method type.
70
+	 *
71
+	 * @param \EE_Transaction $transaction
72
+	 * @return \EE_Billing_Info_Form
73
+	 */
74
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
75
+	{
76
+		if ($this->_pm_instance->debug_mode()) {
77
+			$form = new EE_Billing_Info_Form(
78
+				$this->_pm_instance,
79
+				array(
80
+					'name' => 'paypal_express_Info_Form',
81
+					'subsections' => array(
82
+						'paypal_express_debug_info' => new EE_Form_Section_Proper(
83
+							array(
84
+								'layout_strategy' => new EE_Template_Layout(
85
+									array(
86
+										'layout_template_file' => $this->_template_path
87
+																	. 'paypal_express_debug_info.template.php',
88
+										'template_args'        => array(
89
+											'debug_mode' => $this->_pm_instance->debug_mode()
90
+										)
91
+									)
92
+								)
93
+							)
94
+						)
95
+					)
96
+				)
97
+			);
98
+			return $form;
99
+		}
100 100
 
101
-        return false;
102
-    }
101
+		return false;
102
+	}
103 103
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@
 block discarded – undo
20 20
      */
21 21
     public function __construct($pm_instance = null)
22 22
     {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
23
+        require_once($this->file_folder().'EEG_Paypal_Express.gateway.php');
24 24
         $this->_gateway = new EEG_Paypal_Express();
25 25
 
26 26
         $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
-        $this->_template_path = $this->file_folder() . 'templates/';
27
+        $this->_template_path = $this->file_folder().'templates/';
28 28
         $this->_default_description = esc_html__(
29 29
             // @codingStandardsIgnoreStart
30 30
             'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31 31
             // @codingStandardsIgnoreEnd
32 32
             'event_espresso'
33 33
         );
34
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
34
+        $this->_default_button_url = $this->file_url().'lib/paypal-express-checkout-logo-gold-160.png';
35 35
 
36 36
         parent::__construct($pm_instance);
37 37
     }
Please login to merge, or discard this patch.
core/services/locators/FqcnLocator.php 2 patches
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -18,156 +18,156 @@
 block discarded – undo
18 18
 class FqcnLocator extends Locator
19 19
 {
20 20
 
21
-    /**
22
-     * @var array $FQCNs
23
-     */
24
-    protected $FQCNs = array();
25
-
26
-    /**
27
-     * @var array $namespaces
28
-     */
29
-    protected $namespaces = array();
30
-
31
-
32
-    /**
33
-     * @access protected
34
-     * @param string $namespace
35
-     * @param string $namespace_base_dir
36
-     * @throws InvalidDataTypeException
37
-     */
38
-    protected function setNamespace($namespace, $namespace_base_dir)
39
-    {
40
-        if (! is_string($namespace)) {
41
-            throw new InvalidDataTypeException('$namespace', $namespace, 'string');
42
-        }
43
-        if (! is_string($namespace_base_dir)) {
44
-            throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
45
-        }
46
-        $this->namespaces[ $namespace ] = $namespace_base_dir;
47
-    }
48
-
49
-
50
-    /**
51
-     * @access public
52
-     * @return array
53
-     */
54
-    public function getFQCNs()
55
-    {
56
-        return $this->FQCNs;
57
-    }
58
-
59
-
60
-    /**
61
-     * @access public
62
-     * @return int
63
-     */
64
-    public function count()
65
-    {
66
-        return count($this->FQCNs);
67
-    }
68
-
69
-
70
-    /**
71
-     * given a valid namespace, will find all files that match the provided mask
72
-     *
73
-     * @access public
74
-     * @param string|array $namespaces
75
-     * @return array
76
-     * @throws InvalidClassException
77
-     * @throws InvalidDataTypeException
78
-     */
79
-    public function locate($namespaces)
80
-    {
81
-        if (! (is_string($namespaces) || is_array($namespaces))) {
82
-            throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
83
-        }
84
-        foreach ((array) $namespaces as $namespace) {
85
-            foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
86
-                $this->FQCNs[ $key ] = $file;
87
-            }
88
-        }
89
-        return $this->FQCNs;
90
-    }
91
-
92
-
93
-    /**
94
-     * given a partial namespace, will find all files in that folder
95
-     * ** PLZ NOTE **
96
-     * This assumes that all files within the specified folder should be loaded
97
-     *
98
-     * @access protected
99
-     * @param string $partial_namespace
100
-     * @return array
101
-     * @throws InvalidClassException
102
-     * @throws InvalidDataTypeException
103
-     */
104
-    protected function findFQCNsByNamespace($partial_namespace)
105
-    {
106
-        $iterator = new FilesystemIterator(
107
-            $this->getDirectoryFromPartialNamespace($partial_namespace)
108
-        );
109
-        $iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO);
110
-        $iterator->setFlags(FilesystemIterator::UNIX_PATHS);
111
-        if (iterator_count($iterator) === 0) {
112
-            return array();
113
-        }
114
-        foreach ($iterator as $file) {
115
-            if ($file->isFile() && $file->getExtension() === 'php') {
116
-                $file = $file->getPath() . '/' . $file->getBasename('.php');
117
-                foreach ($this->namespaces as $namespace => $base_dir) {
118
-                    $namespace .= Psr4Autoloader::NS;
119
-                    if (strpos($file, $base_dir) === 0) {
120
-                        $this->FQCNs[] = Psr4Autoloader::NS . str_replace(
121
-                            array($base_dir, '/'),
122
-                            array($namespace, Psr4Autoloader::NS),
123
-                            $file
124
-                        );
125
-                    }
126
-                }
127
-            }
128
-        }
129
-        return $this->FQCNs;
130
-    }
131
-
132
-
133
-    /**
134
-     * getDirectoryFromPartialNamespace
135
-     *
136
-     * @access protected
137
-     * @param  string $partial_namespace almost fully qualified class name ?
138
-     * @return string
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidClassException
141
-     */
142
-    protected function getDirectoryFromPartialNamespace($partial_namespace)
143
-    {
144
-        if (empty($partial_namespace)) {
145
-            throw new InvalidClassException($partial_namespace);
146
-        }
147
-        // load our PSR-4 Autoloader so we can get the list of registered namespaces from it
148
-        $psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader();
149
-        // breakup the incoming namespace into segments so we can loop thru them
150
-        $namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS));
151
-        // we're only interested in the Vendor and secondary base, so pull those from the array
152
-        $vendor_base = array_slice($namespace_segments, 0, 2);
153
-        $namespace = $prefix = null;
154
-        while (! empty($vendor_base)) {
155
-            $namespace = implode(Psr4Autoloader::NS, $vendor_base);
156
-            // check if there's a base directory registered for that namespace
157
-            $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
158
-            if (! empty($prefix) && ! empty($prefix[0])) {
159
-                // found one!
160
-                break;
161
-            }
162
-            // remove base and try vendor only portion of namespace
163
-            array_pop($vendor_base);
164
-        }
165
-        // nope? then the incoming namespace is invalid
166
-        if (empty($prefix) || empty($prefix[0])) {
167
-            throw new InvalidClassException($partial_namespace);
168
-        }
169
-        $this->setNamespace($namespace, $prefix[0]);
170
-        // but if it's good, add that base directory to the rest of the path, and return it
171
-        return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
172
-    }
21
+	/**
22
+	 * @var array $FQCNs
23
+	 */
24
+	protected $FQCNs = array();
25
+
26
+	/**
27
+	 * @var array $namespaces
28
+	 */
29
+	protected $namespaces = array();
30
+
31
+
32
+	/**
33
+	 * @access protected
34
+	 * @param string $namespace
35
+	 * @param string $namespace_base_dir
36
+	 * @throws InvalidDataTypeException
37
+	 */
38
+	protected function setNamespace($namespace, $namespace_base_dir)
39
+	{
40
+		if (! is_string($namespace)) {
41
+			throw new InvalidDataTypeException('$namespace', $namespace, 'string');
42
+		}
43
+		if (! is_string($namespace_base_dir)) {
44
+			throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
45
+		}
46
+		$this->namespaces[ $namespace ] = $namespace_base_dir;
47
+	}
48
+
49
+
50
+	/**
51
+	 * @access public
52
+	 * @return array
53
+	 */
54
+	public function getFQCNs()
55
+	{
56
+		return $this->FQCNs;
57
+	}
58
+
59
+
60
+	/**
61
+	 * @access public
62
+	 * @return int
63
+	 */
64
+	public function count()
65
+	{
66
+		return count($this->FQCNs);
67
+	}
68
+
69
+
70
+	/**
71
+	 * given a valid namespace, will find all files that match the provided mask
72
+	 *
73
+	 * @access public
74
+	 * @param string|array $namespaces
75
+	 * @return array
76
+	 * @throws InvalidClassException
77
+	 * @throws InvalidDataTypeException
78
+	 */
79
+	public function locate($namespaces)
80
+	{
81
+		if (! (is_string($namespaces) || is_array($namespaces))) {
82
+			throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
83
+		}
84
+		foreach ((array) $namespaces as $namespace) {
85
+			foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
86
+				$this->FQCNs[ $key ] = $file;
87
+			}
88
+		}
89
+		return $this->FQCNs;
90
+	}
91
+
92
+
93
+	/**
94
+	 * given a partial namespace, will find all files in that folder
95
+	 * ** PLZ NOTE **
96
+	 * This assumes that all files within the specified folder should be loaded
97
+	 *
98
+	 * @access protected
99
+	 * @param string $partial_namespace
100
+	 * @return array
101
+	 * @throws InvalidClassException
102
+	 * @throws InvalidDataTypeException
103
+	 */
104
+	protected function findFQCNsByNamespace($partial_namespace)
105
+	{
106
+		$iterator = new FilesystemIterator(
107
+			$this->getDirectoryFromPartialNamespace($partial_namespace)
108
+		);
109
+		$iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO);
110
+		$iterator->setFlags(FilesystemIterator::UNIX_PATHS);
111
+		if (iterator_count($iterator) === 0) {
112
+			return array();
113
+		}
114
+		foreach ($iterator as $file) {
115
+			if ($file->isFile() && $file->getExtension() === 'php') {
116
+				$file = $file->getPath() . '/' . $file->getBasename('.php');
117
+				foreach ($this->namespaces as $namespace => $base_dir) {
118
+					$namespace .= Psr4Autoloader::NS;
119
+					if (strpos($file, $base_dir) === 0) {
120
+						$this->FQCNs[] = Psr4Autoloader::NS . str_replace(
121
+							array($base_dir, '/'),
122
+							array($namespace, Psr4Autoloader::NS),
123
+							$file
124
+						);
125
+					}
126
+				}
127
+			}
128
+		}
129
+		return $this->FQCNs;
130
+	}
131
+
132
+
133
+	/**
134
+	 * getDirectoryFromPartialNamespace
135
+	 *
136
+	 * @access protected
137
+	 * @param  string $partial_namespace almost fully qualified class name ?
138
+	 * @return string
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidClassException
141
+	 */
142
+	protected function getDirectoryFromPartialNamespace($partial_namespace)
143
+	{
144
+		if (empty($partial_namespace)) {
145
+			throw new InvalidClassException($partial_namespace);
146
+		}
147
+		// load our PSR-4 Autoloader so we can get the list of registered namespaces from it
148
+		$psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader();
149
+		// breakup the incoming namespace into segments so we can loop thru them
150
+		$namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS));
151
+		// we're only interested in the Vendor and secondary base, so pull those from the array
152
+		$vendor_base = array_slice($namespace_segments, 0, 2);
153
+		$namespace = $prefix = null;
154
+		while (! empty($vendor_base)) {
155
+			$namespace = implode(Psr4Autoloader::NS, $vendor_base);
156
+			// check if there's a base directory registered for that namespace
157
+			$prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
158
+			if (! empty($prefix) && ! empty($prefix[0])) {
159
+				// found one!
160
+				break;
161
+			}
162
+			// remove base and try vendor only portion of namespace
163
+			array_pop($vendor_base);
164
+		}
165
+		// nope? then the incoming namespace is invalid
166
+		if (empty($prefix) || empty($prefix[0])) {
167
+			throw new InvalidClassException($partial_namespace);
168
+		}
169
+		$this->setNamespace($namespace, $prefix[0]);
170
+		// but if it's good, add that base directory to the rest of the path, and return it
171
+		return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
172
+	}
173 173
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
      */
38 38
     protected function setNamespace($namespace, $namespace_base_dir)
39 39
     {
40
-        if (! is_string($namespace)) {
40
+        if ( ! is_string($namespace)) {
41 41
             throw new InvalidDataTypeException('$namespace', $namespace, 'string');
42 42
         }
43
-        if (! is_string($namespace_base_dir)) {
43
+        if ( ! is_string($namespace_base_dir)) {
44 44
             throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
45 45
         }
46
-        $this->namespaces[ $namespace ] = $namespace_base_dir;
46
+        $this->namespaces[$namespace] = $namespace_base_dir;
47 47
     }
48 48
 
49 49
 
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function locate($namespaces)
80 80
     {
81
-        if (! (is_string($namespaces) || is_array($namespaces))) {
81
+        if ( ! (is_string($namespaces) || is_array($namespaces))) {
82 82
             throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
83 83
         }
84 84
         foreach ((array) $namespaces as $namespace) {
85 85
             foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
86
-                $this->FQCNs[ $key ] = $file;
86
+                $this->FQCNs[$key] = $file;
87 87
             }
88 88
         }
89 89
         return $this->FQCNs;
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
         }
114 114
         foreach ($iterator as $file) {
115 115
             if ($file->isFile() && $file->getExtension() === 'php') {
116
-                $file = $file->getPath() . '/' . $file->getBasename('.php');
116
+                $file = $file->getPath().'/'.$file->getBasename('.php');
117 117
                 foreach ($this->namespaces as $namespace => $base_dir) {
118 118
                     $namespace .= Psr4Autoloader::NS;
119 119
                     if (strpos($file, $base_dir) === 0) {
120
-                        $this->FQCNs[] = Psr4Autoloader::NS . str_replace(
120
+                        $this->FQCNs[] = Psr4Autoloader::NS.str_replace(
121 121
                             array($base_dir, '/'),
122 122
                             array($namespace, Psr4Autoloader::NS),
123 123
                             $file
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
         // we're only interested in the Vendor and secondary base, so pull those from the array
152 152
         $vendor_base = array_slice($namespace_segments, 0, 2);
153 153
         $namespace = $prefix = null;
154
-        while (! empty($vendor_base)) {
154
+        while ( ! empty($vendor_base)) {
155 155
             $namespace = implode(Psr4Autoloader::NS, $vendor_base);
156 156
             // check if there's a base directory registered for that namespace
157
-            $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
158
-            if (! empty($prefix) && ! empty($prefix[0])) {
157
+            $prefix = $psr4_loader->prefixes($namespace.Psr4Autoloader::NS);
158
+            if ( ! empty($prefix) && ! empty($prefix[0])) {
159 159
                 // found one!
160 160
                 break;
161 161
             }
@@ -168,6 +168,6 @@  discard block
 block discarded – undo
168 168
         }
169 169
         $this->setNamespace($namespace, $prefix[0]);
170 170
         // but if it's good, add that base directory to the rest of the path, and return it
171
-        return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
171
+        return $prefix[0].implode('/', array_diff($namespace_segments, $vendor_base)).'/';
172 172
     }
173 173
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapRequestResponseObjects.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
     {
91 91
         espresso_load_required(
92 92
             'EE_Request',
93
-            EE_CORE . 'request_stack/EE_Request.core.php'
93
+            EE_CORE.'request_stack/EE_Request.core.php'
94 94
         );
95 95
         $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96 96
         $this->legacy_request->setRequest($this->request);
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -29,84 +29,84 @@
 block discarded – undo
29 29
 class BootstrapRequestResponseObjects
30 30
 {
31 31
 
32
-    /**
33
-     * @type LegacyRequestInterface $legacy_request
34
-     */
35
-    protected $legacy_request;
32
+	/**
33
+	 * @type LegacyRequestInterface $legacy_request
34
+	 */
35
+	protected $legacy_request;
36 36
 
37
-    /**
38
-     * @type LoaderInterface $loader
39
-     */
40
-    protected $loader;
37
+	/**
38
+	 * @type LoaderInterface $loader
39
+	 */
40
+	protected $loader;
41 41
 
42
-    /**
43
-     * @var RequestInterface $request
44
-     */
45
-    protected $request;
42
+	/**
43
+	 * @var RequestInterface $request
44
+	 */
45
+	protected $request;
46 46
 
47
-    /**
48
-     * @var ResponseInterface $response
49
-     */
50
-    protected $response;
47
+	/**
48
+	 * @var ResponseInterface $response
49
+	 */
50
+	protected $response;
51 51
 
52 52
 
53
-    /**
54
-     * BootstrapRequestResponseObjects constructor.
55
-     *
56
-     * @param LoaderInterface $loader
57
-     */
58
-    public function __construct(LoaderInterface $loader)
59
-    {
60
-        $this->loader = $loader;
61
-    }
53
+	/**
54
+	 * BootstrapRequestResponseObjects constructor.
55
+	 *
56
+	 * @param LoaderInterface $loader
57
+	 */
58
+	public function __construct(LoaderInterface $loader)
59
+	{
60
+		$this->loader = $loader;
61
+	}
62 62
 
63 63
 
64
-    /**
65
-     * @return void
66
-     */
67
-    public function buildRequestResponse()
68
-    {
69
-        $request_params = new RequestParams(new RequestSanitizer());
70
-        $server_params = new ServerParams(new ServerSanitizer());
71
-        // load our Request and Response objects
72
-        $this->request = new Request($request_params, $server_params);
73
-        $this->response = new Response();
74
-        $this->loader->share(RequestParams::class, $request_params);
75
-        $this->loader->share(ServerParams::class, $server_params);
76
-    }
64
+	/**
65
+	 * @return void
66
+	 */
67
+	public function buildRequestResponse()
68
+	{
69
+		$request_params = new RequestParams(new RequestSanitizer());
70
+		$server_params = new ServerParams(new ServerSanitizer());
71
+		// load our Request and Response objects
72
+		$this->request = new Request($request_params, $server_params);
73
+		$this->response = new Response();
74
+		$this->loader->share(RequestParams::class, $request_params);
75
+		$this->loader->share(ServerParams::class, $server_params);
76
+	}
77 77
 
78 78
 
79
-    /**
80
-     * @return void
81
-     * @throws InvalidArgumentException
82
-     */
83
-    public function shareRequestResponse()
84
-    {
85
-        $this->loader->share('EventEspresso\core\services\request\Request', $this->request);
86
-        $this->loader->share('EventEspresso\core\services\request\Response', $this->response);
87
-        EE_Dependency_Map::instance()->setRequest($this->request);
88
-        EE_Dependency_Map::instance()->setResponse($this->response);
89
-    }
79
+	/**
80
+	 * @return void
81
+	 * @throws InvalidArgumentException
82
+	 */
83
+	public function shareRequestResponse()
84
+	{
85
+		$this->loader->share('EventEspresso\core\services\request\Request', $this->request);
86
+		$this->loader->share('EventEspresso\core\services\request\Response', $this->response);
87
+		EE_Dependency_Map::instance()->setRequest($this->request);
88
+		EE_Dependency_Map::instance()->setResponse($this->response);
89
+	}
90 90
 
91 91
 
92
-    /**
93
-     * @return void
94
-     * @throws InvalidArgumentException
95
-     * @throws EE_Error
96
-     */
97
-    public function setupLegacyRequest()
98
-    {
99
-        espresso_load_required(
100
-            'EE_Request',
101
-            EE_CORE . 'request_stack/EE_Request.core.php'
102
-        );
103
-        $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
104
-        $this->legacy_request->setRequest($this->request);
105
-        $this->legacy_request->admin = $this->request->isAdmin();
106
-        $this->legacy_request->ajax = $this->request->isAjax();
107
-        $this->legacy_request->front_ajax = $this->request->isFrontAjax();
108
-        EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
109
-        $this->loader->share('EE_Request', $this->legacy_request);
110
-        $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
111
-    }
92
+	/**
93
+	 * @return void
94
+	 * @throws InvalidArgumentException
95
+	 * @throws EE_Error
96
+	 */
97
+	public function setupLegacyRequest()
98
+	{
99
+		espresso_load_required(
100
+			'EE_Request',
101
+			EE_CORE . 'request_stack/EE_Request.core.php'
102
+		);
103
+		$this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
104
+		$this->legacy_request->setRequest($this->request);
105
+		$this->legacy_request->admin = $this->request->isAdmin();
106
+		$this->legacy_request->ajax = $this->request->isAjax();
107
+		$this->legacy_request->front_ajax = $this->request->isFrontAjax();
108
+		EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
109
+		$this->loader->share('EE_Request', $this->legacy_request);
110
+		$this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
111
+	}
112 112
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapCore.php 2 patches
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -47,225 +47,225 @@
 block discarded – undo
47 47
 class BootstrapCore
48 48
 {
49 49
 
50
-    /**
51
-     * @type LoaderInterface $loader
52
-     */
53
-    private $loader;
50
+	/**
51
+	 * @type LoaderInterface $loader
52
+	 */
53
+	private $loader;
54 54
 
55
-    /**
56
-     * @var RequestInterface $request
57
-     */
58
-    protected $request;
55
+	/**
56
+	 * @var RequestInterface $request
57
+	 */
58
+	protected $request;
59 59
 
60
-    /**
61
-     * @var ResponseInterface $response
62
-     */
63
-    protected $response;
60
+	/**
61
+	 * @var ResponseInterface $response
62
+	 */
63
+	protected $response;
64 64
 
65
-    /**
66
-     * @var RequestStackBuilder $request_stack_builder
67
-     */
68
-    protected $request_stack_builder;
65
+	/**
66
+	 * @var RequestStackBuilder $request_stack_builder
67
+	 */
68
+	protected $request_stack_builder;
69 69
 
70
-    /**
71
-     * @var RequestStack $request_stack
72
-     */
73
-    protected $request_stack;
70
+	/**
71
+	 * @var RequestStack $request_stack
72
+	 */
73
+	protected $request_stack;
74 74
 
75 75
 
76
-    /**
77
-     * BootstrapCore constructor.
78
-     */
79
-    public function __construct()
80
-    {
81
-        do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
82
-        // construct request stack and run middleware apps as soon as all WP plugins are loaded
83
-        add_action('plugins_loaded', array($this, 'initialize'), 0);
84
-    }
76
+	/**
77
+	 * BootstrapCore constructor.
78
+	 */
79
+	public function __construct()
80
+	{
81
+		do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
82
+		// construct request stack and run middleware apps as soon as all WP plugins are loaded
83
+		add_action('plugins_loaded', array($this, 'initialize'), 0);
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * @throws DomainException
89
-     * @throws EE_Error
90
-     * @throws Exception
91
-     * @throws InvalidArgumentException
92
-     * @throws InvalidClassException
93
-     * @throws InvalidDataTypeException
94
-     * @throws InvalidFilePathException
95
-     * @throws InvalidInterfaceException
96
-     * @throws InvalidRequestStackMiddlewareException
97
-     * @throws OutOfBoundsException
98
-     * @throws ReflectionException
99
-     */
100
-    public function initialize()
101
-    {
102
-        $this->bootstrapDependencyInjectionContainer();
103
-        $this->bootstrapDomain();
104
-        $bootstrap_request = $this->bootstrapRequestResponseObjects();
105
-        add_action(
106
-            'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
107
-            array($bootstrap_request, 'setupLegacyRequest')
108
-        );
109
-        $this->runRequestStack();
110
-    }
87
+	/**
88
+	 * @throws DomainException
89
+	 * @throws EE_Error
90
+	 * @throws Exception
91
+	 * @throws InvalidArgumentException
92
+	 * @throws InvalidClassException
93
+	 * @throws InvalidDataTypeException
94
+	 * @throws InvalidFilePathException
95
+	 * @throws InvalidInterfaceException
96
+	 * @throws InvalidRequestStackMiddlewareException
97
+	 * @throws OutOfBoundsException
98
+	 * @throws ReflectionException
99
+	 */
100
+	public function initialize()
101
+	{
102
+		$this->bootstrapDependencyInjectionContainer();
103
+		$this->bootstrapDomain();
104
+		$bootstrap_request = $this->bootstrapRequestResponseObjects();
105
+		add_action(
106
+			'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
107
+			array($bootstrap_request, 'setupLegacyRequest')
108
+		);
109
+		$this->runRequestStack();
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * @throws ReflectionException
115
-     * @throws EE_Error
116
-     * @throws InvalidArgumentException
117
-     * @throws InvalidDataTypeException
118
-     * @throws InvalidInterfaceException
119
-     * @throws OutOfBoundsException
120
-     */
121
-    private function bootstrapDependencyInjectionContainer()
122
-    {
123
-        $bootstrap_di = new BootstrapDependencyInjectionContainer();
124
-        $bootstrap_di->buildLegacyDependencyInjectionContainer();
125
-        $bootstrap_di->buildLoader();
126
-        $registry = $bootstrap_di->getRegistry();
127
-        $dependency_map = $bootstrap_di->getDependencyMap();
128
-        $dependency_map->initialize();
129
-        $registry->initialize();
130
-        $this->loader = $bootstrap_di->getLoader();
131
-    }
113
+	/**
114
+	 * @throws ReflectionException
115
+	 * @throws EE_Error
116
+	 * @throws InvalidArgumentException
117
+	 * @throws InvalidDataTypeException
118
+	 * @throws InvalidInterfaceException
119
+	 * @throws OutOfBoundsException
120
+	 */
121
+	private function bootstrapDependencyInjectionContainer()
122
+	{
123
+		$bootstrap_di = new BootstrapDependencyInjectionContainer();
124
+		$bootstrap_di->buildLegacyDependencyInjectionContainer();
125
+		$bootstrap_di->buildLoader();
126
+		$registry = $bootstrap_di->getRegistry();
127
+		$dependency_map = $bootstrap_di->getDependencyMap();
128
+		$dependency_map->initialize();
129
+		$registry->initialize();
130
+		$this->loader = $bootstrap_di->getLoader();
131
+	}
132 132
 
133 133
 
134
-    /**
135
-     * configures the Domain object for core
136
-     *
137
-     * @return void
138
-     * @throws DomainException
139
-     * @throws InvalidArgumentException
140
-     * @throws InvalidDataTypeException
141
-     * @throws InvalidClassException
142
-     * @throws InvalidFilePathException
143
-     * @throws InvalidInterfaceException
144
-     */
145
-    private function bootstrapDomain()
146
-    {
147
-        DomainFactory::getEventEspressoCoreDomain();
148
-    }
134
+	/**
135
+	 * configures the Domain object for core
136
+	 *
137
+	 * @return void
138
+	 * @throws DomainException
139
+	 * @throws InvalidArgumentException
140
+	 * @throws InvalidDataTypeException
141
+	 * @throws InvalidClassException
142
+	 * @throws InvalidFilePathException
143
+	 * @throws InvalidInterfaceException
144
+	 */
145
+	private function bootstrapDomain()
146
+	{
147
+		DomainFactory::getEventEspressoCoreDomain();
148
+	}
149 149
 
150 150
 
151
-    /**
152
-     * sets up the request and response objects
153
-     *
154
-     * @return BootstrapRequestResponseObjects
155
-     * @throws InvalidArgumentException
156
-     */
157
-    private function bootstrapRequestResponseObjects()
158
-    {
159
-        /** @var BootstrapRequestResponseObjects $bootstrap_request */
160
-        $bootstrap_request = $this->loader->getShared(
161
-            'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
162
-            array($this->loader)
163
-        );
164
-        $bootstrap_request->buildRequestResponse();
165
-        $bootstrap_request->shareRequestResponse();
166
-        $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request');
167
-        $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
168
-        return $bootstrap_request;
169
-    }
151
+	/**
152
+	 * sets up the request and response objects
153
+	 *
154
+	 * @return BootstrapRequestResponseObjects
155
+	 * @throws InvalidArgumentException
156
+	 */
157
+	private function bootstrapRequestResponseObjects()
158
+	{
159
+		/** @var BootstrapRequestResponseObjects $bootstrap_request */
160
+		$bootstrap_request = $this->loader->getShared(
161
+			'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
162
+			array($this->loader)
163
+		);
164
+		$bootstrap_request->buildRequestResponse();
165
+		$bootstrap_request->shareRequestResponse();
166
+		$this->request = $this->loader->getShared('EventEspresso\core\services\request\Request');
167
+		$this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
168
+		return $bootstrap_request;
169
+	}
170 170
 
171 171
 
172
-    /**
173
-     * run_request_stack
174
-     * construct request stack and run middleware apps
175
-     *
176
-     * @throws EE_Error
177
-     * @throws Exception
178
-     */
179
-    public function runRequestStack()
180
-    {
181
-        $this->loadAutoloader();
182
-        $this->setAutoloadersForRequiredFiles();
183
-        $this->request_stack_builder = $this->buildRequestStack();
184
-        $this->request_stack = $this->request_stack_builder->resolve(
185
-            new RequestStackCoreApp()
186
-        );
187
-        $this->request_stack->handleRequest($this->request, $this->response);
188
-        $this->request_stack->handleResponse();
189
-    }
172
+	/**
173
+	 * run_request_stack
174
+	 * construct request stack and run middleware apps
175
+	 *
176
+	 * @throws EE_Error
177
+	 * @throws Exception
178
+	 */
179
+	public function runRequestStack()
180
+	{
181
+		$this->loadAutoloader();
182
+		$this->setAutoloadersForRequiredFiles();
183
+		$this->request_stack_builder = $this->buildRequestStack();
184
+		$this->request_stack = $this->request_stack_builder->resolve(
185
+			new RequestStackCoreApp()
186
+		);
187
+		$this->request_stack->handleRequest($this->request, $this->response);
188
+		$this->request_stack->handleResponse();
189
+	}
190 190
 
191 191
 
192
-    /**
193
-     * load_autoloader
194
-     *
195
-     * @throws EE_Error
196
-     */
197
-    protected function loadAutoloader()
198
-    {
199
-        // load interfaces
200
-        espresso_load_required(
201
-            'EEH_Autoloader',
202
-            EE_CORE . 'helpers/EEH_Autoloader.helper.php'
203
-        );
204
-        EEH_Autoloader::instance();
205
-    }
192
+	/**
193
+	 * load_autoloader
194
+	 *
195
+	 * @throws EE_Error
196
+	 */
197
+	protected function loadAutoloader()
198
+	{
199
+		// load interfaces
200
+		espresso_load_required(
201
+			'EEH_Autoloader',
202
+			EE_CORE . 'helpers/EEH_Autoloader.helper.php'
203
+		);
204
+		EEH_Autoloader::instance();
205
+	}
206 206
 
207 207
 
208
-    /**
209
-     * load_required_files
210
-     *
211
-     * @throws EE_Error
212
-     */
213
-    protected function setAutoloadersForRequiredFiles()
214
-    {
215
-        // load interfaces
216
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
217
-        // load helpers
218
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219
-        // register legacy request stack classes just in case
220
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
221
-        // register legacy middleware classes just in case
222
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
223
-    }
208
+	/**
209
+	 * load_required_files
210
+	 *
211
+	 * @throws EE_Error
212
+	 */
213
+	protected function setAutoloadersForRequiredFiles()
214
+	{
215
+		// load interfaces
216
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
217
+		// load helpers
218
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219
+		// register legacy request stack classes just in case
220
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
221
+		// register legacy middleware classes just in case
222
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
223
+	}
224 224
 
225 225
 
226
-    /**
227
-     * build_request_stack
228
-     *
229
-     * @return RequestStackBuilder
230
-     */
231
-    public function buildRequestStack()
232
-    {
233
-        $request_stack_builder = new RequestStackBuilder($this->loader);
234
-        /**
235
-         * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
236
-         * so items at the beginning of the final middleware stack will run last.
237
-         * First parameter is the middleware classname, second is an array of arguments
238
-         */
239
-        $stack_apps = apply_filters(
240
-            'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
241
-            array(
242
-                // first in last out
243
-                'EventEspresso\core\services\request\middleware\BotDetector'                 => array(),
244
-                'EventEspresso\core\services\request\middleware\DetectFileEditorRequest'     => array(),
245
-                'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(),
246
-                'EventEspresso\core\services\request\middleware\RecommendedVersions'         => array(),
247
-                // last in first out
248
-                'EventEspresso\core\services\request\middleware\DetectLogin'                 => array(),
249
-            )
250
-        );
251
-        // legacy filter for backwards compatibility
252
-        $stack_apps = apply_filters(
253
-            'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
254
-            $stack_apps
255
-        );
256
-        // load middleware onto stack : FILO (First In Last Out)
257
-        // items at the beginning of the $stack_apps array will run last
258
-        foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
259
-            $request_stack_builder->push(array($stack_app, $stack_app_args));
260
-        }
261
-        // finally, we'll add this on its own because we need it to always be part of the stack
262
-        // and we also need it to always run first because the rest of the system relies on it
263
-        $request_stack_builder->push(
264
-            array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array())
265
-        );
266
-        return apply_filters(
267
-            'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
268
-            $request_stack_builder
269
-        );
270
-    }
226
+	/**
227
+	 * build_request_stack
228
+	 *
229
+	 * @return RequestStackBuilder
230
+	 */
231
+	public function buildRequestStack()
232
+	{
233
+		$request_stack_builder = new RequestStackBuilder($this->loader);
234
+		/**
235
+		 * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
236
+		 * so items at the beginning of the final middleware stack will run last.
237
+		 * First parameter is the middleware classname, second is an array of arguments
238
+		 */
239
+		$stack_apps = apply_filters(
240
+			'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
241
+			array(
242
+				// first in last out
243
+				'EventEspresso\core\services\request\middleware\BotDetector'                 => array(),
244
+				'EventEspresso\core\services\request\middleware\DetectFileEditorRequest'     => array(),
245
+				'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(),
246
+				'EventEspresso\core\services\request\middleware\RecommendedVersions'         => array(),
247
+				// last in first out
248
+				'EventEspresso\core\services\request\middleware\DetectLogin'                 => array(),
249
+			)
250
+		);
251
+		// legacy filter for backwards compatibility
252
+		$stack_apps = apply_filters(
253
+			'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
254
+			$stack_apps
255
+		);
256
+		// load middleware onto stack : FILO (First In Last Out)
257
+		// items at the beginning of the $stack_apps array will run last
258
+		foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
259
+			$request_stack_builder->push(array($stack_app, $stack_app_args));
260
+		}
261
+		// finally, we'll add this on its own because we need it to always be part of the stack
262
+		// and we also need it to always run first because the rest of the system relies on it
263
+		$request_stack_builder->push(
264
+			array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array())
265
+		);
266
+		return apply_filters(
267
+			'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
268
+			$request_stack_builder
269
+		);
270
+	}
271 271
 }
Please login to merge, or discard this patch.
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.
core/services/container/OpenCoffeeShop.php 2 patches
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -20,192 +20,192 @@
 block discarded – undo
20 20
 class OpenCoffeeShop
21 21
 {
22 22
 
23
-    /**
24
-     * @var CoffeeShop $CoffeeShop
25
-     */
26
-    private $CoffeeShop;
23
+	/**
24
+	 * @var CoffeeShop $CoffeeShop
25
+	 */
26
+	private $CoffeeShop;
27 27
 
28 28
 
29
-    /**
30
-     * OpenCoffeeShop constructor
31
-     *
32
-     * @throws InvalidInterfaceException
33
-     */
34
-    public function __construct()
35
-    {
36
-        // instantiate the DI container
37
-        $this->CoffeeShop = new CoffeeShop();
38
-    }
29
+	/**
30
+	 * OpenCoffeeShop constructor
31
+	 *
32
+	 * @throws InvalidInterfaceException
33
+	 */
34
+	public function __construct()
35
+	{
36
+		// instantiate the DI container
37
+		$this->CoffeeShop = new CoffeeShop();
38
+	}
39 39
 
40 40
 
41
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
42
-    /**
43
-     * @return CoffeeShop
44
-     */
45
-    public function CoffeeShop()
46
-    {
47
-        return $this->CoffeeShop;
48
-    }
41
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
42
+	/**
43
+	 * @return CoffeeShop
44
+	 */
45
+	public function CoffeeShop()
46
+	{
47
+		return $this->CoffeeShop;
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * configure coffee makers which control the different kinds of brews
53
-     * ( shared services, new factory objects, etc )
54
-     *
55
-     * @throws InvalidEntityException
56
-     */
57
-    public function setupCoffeeMakers()
58
-    {
59
-        // create a dependency injector class for resolving class constructor arguments
60
-        $DependencyInjector = new DependencyInjector(
61
-            $this->CoffeeShop,
62
-            new \EEH_Array()
63
-        );
64
-        // and some coffeemakers, one for creating new instances
65
-        $this->CoffeeShop->addCoffeeMaker(
66
-            new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector),
67
-            CoffeeMaker::BREW_NEW
68
-        );
69
-        // one for shared services
70
-        $this->CoffeeShop->addCoffeeMaker(
71
-            new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector),
72
-            CoffeeMaker::BREW_SHARED
73
-        );
74
-        // and one for classes that only get loaded
75
-        $this->CoffeeShop->addCoffeeMaker(
76
-            new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector),
77
-            CoffeeMaker::BREW_LOAD_ONLY
78
-        );
79
-    }
51
+	/**
52
+	 * configure coffee makers which control the different kinds of brews
53
+	 * ( shared services, new factory objects, etc )
54
+	 *
55
+	 * @throws InvalidEntityException
56
+	 */
57
+	public function setupCoffeeMakers()
58
+	{
59
+		// create a dependency injector class for resolving class constructor arguments
60
+		$DependencyInjector = new DependencyInjector(
61
+			$this->CoffeeShop,
62
+			new \EEH_Array()
63
+		);
64
+		// and some coffeemakers, one for creating new instances
65
+		$this->CoffeeShop->addCoffeeMaker(
66
+			new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector),
67
+			CoffeeMaker::BREW_NEW
68
+		);
69
+		// one for shared services
70
+		$this->CoffeeShop->addCoffeeMaker(
71
+			new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector),
72
+			CoffeeMaker::BREW_SHARED
73
+		);
74
+		// and one for classes that only get loaded
75
+		$this->CoffeeShop->addCoffeeMaker(
76
+			new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector),
77
+			CoffeeMaker::BREW_LOAD_ONLY
78
+		);
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * Recipes define how to load legacy classes
84
-     *
85
-     * @throws InvalidIdentifierException
86
-     */
87
-    public function addRecipes()
88
-    {
89
-        // add default recipe, which should handle loading for most PSR-4 compatible classes
90
-        // as long as they are not type hinting for interfaces
91
-        $this->CoffeeShop->addRecipe(
92
-            new Recipe(
93
-                Recipe::DEFAULT_ID
94
-            )
95
-        );
96
-        // PSR-4 compatible class with aliases
97
-        $this->CoffeeShop->addRecipe(
98
-            new Recipe(
99
-                'CommandHandlerManager',
100
-                'EventEspresso\core\services\commands\CommandHandlerManager',
101
-                array(
102
-                    'CommandHandlerManagerInterface',
103
-                    'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
104
-                ),
105
-                array(),
106
-                CoffeeMaker::BREW_SHARED
107
-            )
108
-        );
109
-        // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager
110
-        $this->CoffeeShop->addRecipe(
111
-            new Recipe(
112
-                'CommandBus',
113
-                'EventEspresso\core\services\commands\CommandBus',
114
-                array(
115
-                    'CommandBusInterface',
116
-                    'EventEspresso\core\services\commands\CommandBusInterface',
117
-                ),
118
-                array(),
119
-                CoffeeMaker::BREW_SHARED
120
-            )
121
-        );
122
-        // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath
123
-        // add a wildcard recipe for loading legacy core interfaces
124
-        $this->CoffeeShop->addRecipe(
125
-            new Recipe(
126
-                'EEI_*',
127
-                '',
128
-                array(),
129
-                array(),
130
-                CoffeeMaker::BREW_LOAD_ONLY,
131
-                array(
132
-                    EE_INTERFACES . '*.php',
133
-                    EE_INTERFACES . '*.interfaces.php',
134
-                )
135
-            )
136
-        );
137
-        // add a wildcard recipe for loading models
138
-        $this->CoffeeShop->addRecipe(
139
-            new Recipe(
140
-                'EEM_*',
141
-                '',
142
-                array(),
143
-                array(),
144
-                CoffeeMaker::BREW_SHARED,
145
-                EE_MODELS . '*.model.php'
146
-            )
147
-        );
148
-        // add a wildcard recipe for loading core classes
149
-        $this->CoffeeShop->addRecipe(
150
-            new Recipe(
151
-                'EE_*',
152
-                '',
153
-                array(),
154
-                array(),
155
-                CoffeeMaker::BREW_SHARED,
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',
161
-                )
162
-            )
163
-        );
164
-        // load admin page parent class
165
-        $this->CoffeeShop->addRecipe(
166
-            new Recipe(
167
-                'EE_Admin_Page*',
168
-                '',
169
-                array(),
170
-                array(),
171
-                CoffeeMaker::BREW_LOAD_ONLY,
172
-                array(EE_ADMIN . '*.core.php')
173
-            )
174
-        );
175
-        // add a wildcard recipe for loading core classes
176
-        // $this->CoffeeShop->addRecipe(
177
-        //     new Recipe(
178
-        //         '*_Admin_Page',
179
-        //         '',
180
-        //         array(),
181
-        //         array(),
182
-        //         CoffeeMaker::BREW_SHARED,
183
-        //         array(
184
-        //             EE_ADMIN_PAGES . 'transactions/*.core.php',
185
-        //         )
186
-        //     )
187
-        // );
188
-    }
82
+	/**
83
+	 * Recipes define how to load legacy classes
84
+	 *
85
+	 * @throws InvalidIdentifierException
86
+	 */
87
+	public function addRecipes()
88
+	{
89
+		// add default recipe, which should handle loading for most PSR-4 compatible classes
90
+		// as long as they are not type hinting for interfaces
91
+		$this->CoffeeShop->addRecipe(
92
+			new Recipe(
93
+				Recipe::DEFAULT_ID
94
+			)
95
+		);
96
+		// PSR-4 compatible class with aliases
97
+		$this->CoffeeShop->addRecipe(
98
+			new Recipe(
99
+				'CommandHandlerManager',
100
+				'EventEspresso\core\services\commands\CommandHandlerManager',
101
+				array(
102
+					'CommandHandlerManagerInterface',
103
+					'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
104
+				),
105
+				array(),
106
+				CoffeeMaker::BREW_SHARED
107
+			)
108
+		);
109
+		// PSR-4 compatible class with aliases, which dependency on CommandHandlerManager
110
+		$this->CoffeeShop->addRecipe(
111
+			new Recipe(
112
+				'CommandBus',
113
+				'EventEspresso\core\services\commands\CommandBus',
114
+				array(
115
+					'CommandBusInterface',
116
+					'EventEspresso\core\services\commands\CommandBusInterface',
117
+				),
118
+				array(),
119
+				CoffeeMaker::BREW_SHARED
120
+			)
121
+		);
122
+		// LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath
123
+		// add a wildcard recipe for loading legacy core interfaces
124
+		$this->CoffeeShop->addRecipe(
125
+			new Recipe(
126
+				'EEI_*',
127
+				'',
128
+				array(),
129
+				array(),
130
+				CoffeeMaker::BREW_LOAD_ONLY,
131
+				array(
132
+					EE_INTERFACES . '*.php',
133
+					EE_INTERFACES . '*.interfaces.php',
134
+				)
135
+			)
136
+		);
137
+		// add a wildcard recipe for loading models
138
+		$this->CoffeeShop->addRecipe(
139
+			new Recipe(
140
+				'EEM_*',
141
+				'',
142
+				array(),
143
+				array(),
144
+				CoffeeMaker::BREW_SHARED,
145
+				EE_MODELS . '*.model.php'
146
+			)
147
+		);
148
+		// add a wildcard recipe for loading core classes
149
+		$this->CoffeeShop->addRecipe(
150
+			new Recipe(
151
+				'EE_*',
152
+				'',
153
+				array(),
154
+				array(),
155
+				CoffeeMaker::BREW_SHARED,
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',
161
+				)
162
+			)
163
+		);
164
+		// load admin page parent class
165
+		$this->CoffeeShop->addRecipe(
166
+			new Recipe(
167
+				'EE_Admin_Page*',
168
+				'',
169
+				array(),
170
+				array(),
171
+				CoffeeMaker::BREW_LOAD_ONLY,
172
+				array(EE_ADMIN . '*.core.php')
173
+			)
174
+		);
175
+		// add a wildcard recipe for loading core classes
176
+		// $this->CoffeeShop->addRecipe(
177
+		//     new Recipe(
178
+		//         '*_Admin_Page',
179
+		//         '',
180
+		//         array(),
181
+		//         array(),
182
+		//         CoffeeMaker::BREW_SHARED,
183
+		//         array(
184
+		//             EE_ADMIN_PAGES . 'transactions/*.core.php',
185
+		//         )
186
+		//     )
187
+		// );
188
+	}
189 189
 
190 190
 
191
-    /**
192
-     * bootstrap EE and the request stack
193
-     *
194
-     * @throws ServiceNotFoundException
195
-     * @throws InvalidClassException
196
-     * @throws InvalidDataTypeException
197
-     * @throws InvalidIdentifierException
198
-     * @throws exceptions\ServiceExistsException
199
-     * @throws OutOfBoundsException
200
-     * @throws exceptions\InstantiationException
201
-     */
202
-    public function firstBrew()
203
-    {
204
-        $this->CoffeeShop->brew(
205
-            'EventEspresso\core\services\request\Request',
206
-            array($_GET, $_POST, $_COOKIE, $_SERVER)
207
-        );
208
-        $this->CoffeeShop->brew('EventEspresso\core\services\request\Response');
209
-        $this->CoffeeShop->brew('EE_Bootstrap');
210
-    }
191
+	/**
192
+	 * bootstrap EE and the request stack
193
+	 *
194
+	 * @throws ServiceNotFoundException
195
+	 * @throws InvalidClassException
196
+	 * @throws InvalidDataTypeException
197
+	 * @throws InvalidIdentifierException
198
+	 * @throws exceptions\ServiceExistsException
199
+	 * @throws OutOfBoundsException
200
+	 * @throws exceptions\InstantiationException
201
+	 */
202
+	public function firstBrew()
203
+	{
204
+		$this->CoffeeShop->brew(
205
+			'EventEspresso\core\services\request\Request',
206
+			array($_GET, $_POST, $_COOKIE, $_SERVER)
207
+		);
208
+		$this->CoffeeShop->brew('EventEspresso\core\services\request\Response');
209
+		$this->CoffeeShop->brew('EE_Bootstrap');
210
+	}
211 211
 }
Please login to merge, or discard this patch.
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.
core/services/licensing/LicenseService.php 2 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -15,94 +15,94 @@
 block discarded – undo
15 15
  */
16 16
 class LicenseService
17 17
 {
18
-    /**
19
-     * @var Config
20
-     */
21
-    private $config;
22
-
23
-
24
-    /**
25
-     * @var Stats
26
-     */
27
-    private $stats_collection;
28
-
29
-    public function __construct(Stats $stats_collection, Config $config)
30
-    {
31
-        $this->config = $config;
32
-        $this->stats_collection = $stats_collection;
33
-        $this->loadPueClient();
34
-    }
35
-
36
-    private function loadPueClient()
37
-    {
38
-        // PUE Auto Upgrades stuff
39
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
40
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
41
-
42
-            // $options needs to be an array with the included keys as listed.
43
-            $options = array(
44
-                // 'optionName' => '', //(optional) - used as the reference for saving update information in the
45
-                // clients options table.  Will be automatically set if left blank.
46
-                'apikey'                => $this->config->siteLicenseKey(),
47
-                // (required), you will need to obtain the apikey that the client gets from your site and
48
-                // then saves in their sites options table (see 'getting an api-key' below)
49
-                'lang_domain'           => $this->config->i18nDomain(),
50
-                // (optional) - put here whatever reference you are using for the localization of your plugin (if it's
51
-                // localized).  That way strings in this file will be included in the translation for your plugin.
52
-                'checkPeriod'           => $this->config->checkPeriod(),
53
-                // (optional) - use this parameter to indicate how often you want the client's install to ping your
54
-                // server for update checks.  The integer indicates hours.  If you don't include this parameter it will
55
-                // default to 12 hours.
56
-                'option_key'            => $this->config->optionKey(),
57
-                // this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
58
-                // updating your information message whenever this option_key is modified.
59
-                'options_page_slug'     => $this->config->optionsPageSlug(),
60
-                'plugin_basename'       => EE_PLUGIN_BASENAME,
61
-                'use_wp_update'         => true,
62
-                // if TRUE then you want FREE versions of the plugin to be updated from WP
63
-                'extra_stats'           => $this->stats_collection->statsCallback(),
64
-                'turn_on_notices_saved' => true,
65
-            );
66
-            // initiate the class and start the plugin update engine!
67
-            new PluginUpdateEngineChecker(
68
-                $this->config->hostServerUrl(),
69
-                $this->config->pluginSlug(),
70
-                $options
71
-            );
72
-        }
73
-    }
74
-
75
-
76
-    /**
77
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
78
-     *
79
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
80
-     *                          identify plugins. Defaults to core update
81
-     * @return boolean           True if update available, false if not.
82
-     */
83
-    public static function isUpdateAvailable($basename = '')
84
-    {
85
-        $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
86
-
87
-        $update = false;
88
-
89
-        // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
90
-        $folder = '/' . dirname($basename);
91
-
92
-        $plugins = get_plugins($folder);
93
-        $current = get_site_transient('update_plugins');
94
-
95
-        foreach ((array) $plugins as $plugin_file => $plugin_data) {
96
-            if (isset($current->response['plugin_file'])) {
97
-                $update = true;
98
-            }
99
-        }
100
-
101
-        // it's possible that there is an update but an invalid site-license-key is in use
102
-        if (get_site_option('pue_json_error_' . $basename)) {
103
-            $update = true;
104
-        }
105
-
106
-        return $update;
107
-    }
18
+	/**
19
+	 * @var Config
20
+	 */
21
+	private $config;
22
+
23
+
24
+	/**
25
+	 * @var Stats
26
+	 */
27
+	private $stats_collection;
28
+
29
+	public function __construct(Stats $stats_collection, Config $config)
30
+	{
31
+		$this->config = $config;
32
+		$this->stats_collection = $stats_collection;
33
+		$this->loadPueClient();
34
+	}
35
+
36
+	private function loadPueClient()
37
+	{
38
+		// PUE Auto Upgrades stuff
39
+		if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
40
+			require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
41
+
42
+			// $options needs to be an array with the included keys as listed.
43
+			$options = array(
44
+				// 'optionName' => '', //(optional) - used as the reference for saving update information in the
45
+				// clients options table.  Will be automatically set if left blank.
46
+				'apikey'                => $this->config->siteLicenseKey(),
47
+				// (required), you will need to obtain the apikey that the client gets from your site and
48
+				// then saves in their sites options table (see 'getting an api-key' below)
49
+				'lang_domain'           => $this->config->i18nDomain(),
50
+				// (optional) - put here whatever reference you are using for the localization of your plugin (if it's
51
+				// localized).  That way strings in this file will be included in the translation for your plugin.
52
+				'checkPeriod'           => $this->config->checkPeriod(),
53
+				// (optional) - use this parameter to indicate how often you want the client's install to ping your
54
+				// server for update checks.  The integer indicates hours.  If you don't include this parameter it will
55
+				// default to 12 hours.
56
+				'option_key'            => $this->config->optionKey(),
57
+				// this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
58
+				// updating your information message whenever this option_key is modified.
59
+				'options_page_slug'     => $this->config->optionsPageSlug(),
60
+				'plugin_basename'       => EE_PLUGIN_BASENAME,
61
+				'use_wp_update'         => true,
62
+				// if TRUE then you want FREE versions of the plugin to be updated from WP
63
+				'extra_stats'           => $this->stats_collection->statsCallback(),
64
+				'turn_on_notices_saved' => true,
65
+			);
66
+			// initiate the class and start the plugin update engine!
67
+			new PluginUpdateEngineChecker(
68
+				$this->config->hostServerUrl(),
69
+				$this->config->pluginSlug(),
70
+				$options
71
+			);
72
+		}
73
+	}
74
+
75
+
76
+	/**
77
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
78
+	 *
79
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
80
+	 *                          identify plugins. Defaults to core update
81
+	 * @return boolean           True if update available, false if not.
82
+	 */
83
+	public static function isUpdateAvailable($basename = '')
84
+	{
85
+		$basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
86
+
87
+		$update = false;
88
+
89
+		// should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
90
+		$folder = '/' . dirname($basename);
91
+
92
+		$plugins = get_plugins($folder);
93
+		$current = get_site_transient('update_plugins');
94
+
95
+		foreach ((array) $plugins as $plugin_file => $plugin_data) {
96
+			if (isset($current->response['plugin_file'])) {
97
+				$update = true;
98
+			}
99
+		}
100
+
101
+		// it's possible that there is an update but an invalid site-license-key is in use
102
+		if (get_site_option('pue_json_error_' . $basename)) {
103
+			$update = true;
104
+		}
105
+
106
+		return $update;
107
+	}
108 108
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
     private function loadPueClient()
37 37
     {
38 38
         // PUE Auto Upgrades stuff
39
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
40
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
39
+        if (is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) { // include the file
40
+            require_once(EE_THIRD_PARTY.'pue/pue-client.php');
41 41
 
42 42
             // $options needs to be an array with the included keys as listed.
43 43
             $options = array(
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $update = false;
88 88
 
89 89
         // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
90
-        $folder = '/' . dirname($basename);
90
+        $folder = '/'.dirname($basename);
91 91
 
92 92
         $plugins = get_plugins($folder);
93 93
         $current = get_site_transient('update_plugins');
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         }
100 100
 
101 101
         // it's possible that there is an update but an invalid site-license-key is in use
102
-        if (get_site_option('pue_json_error_' . $basename)) {
102
+        if (get_site_option('pue_json_error_'.$basename)) {
103 103
             $update = true;
104 104
         }
105 105
 
Please login to merge, or discard this patch.
display_strategies/number_bubbles/NumberBubblesProgressStepsDisplay.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -16,29 +16,29 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * used for setting up css and js required for the display strategy
21
-     *
22
-     * @return void
23
-     */
24
-    public function enqueueStylesAndScripts()
25
-    {
26
-        // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
27
-        wp_enqueue_style(
28
-            'ee_progress_steps_display_number_bubbles',
29
-            plugin_dir_url(__FILE__) . 'number_bubbles.css'
30
-        );
31
-    }
19
+	/**
20
+	 * used for setting up css and js required for the display strategy
21
+	 *
22
+	 * @return void
23
+	 */
24
+	public function enqueueStylesAndScripts()
25
+	{
26
+		// core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css
27
+		wp_enqueue_style(
28
+			'ee_progress_steps_display_number_bubbles',
29
+			plugin_dir_url(__FILE__) . 'number_bubbles.css'
30
+		);
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * loads and returns a full server path to the template used for the display strategy
36
-     *
37
-     * @return string
38
-     */
39
-    public function getTemplate()
40
-    {
41
-        // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
42
-        return __DIR__ . '/number_bubbles.template.php';
43
-    }
34
+	/**
35
+	 * loads and returns a full server path to the template used for the display strategy
36
+	 *
37
+	 * @return string
38
+	 */
39
+	public function getTemplate()
40
+	{
41
+		// return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php';
42
+		return __DIR__ . '/number_bubbles.template.php';
43
+	}
44 44
 }
Please login to merge, or discard this patch.
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.
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   +1528 added lines, -1528 removed lines patch added patch discarded remove patch
@@ -16,1532 +16,1532 @@
 block discarded – undo
16 16
 class EE_Form_Section_Proper extends EE_Form_Section_Validatable
17 17
 {
18 18
 
19
-    const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
20
-
21
-    /**
22
-     * Subsections
23
-     *
24
-     * @var EE_Form_Section_Validatable[]
25
-     */
26
-    protected $_subsections = array();
27
-
28
-    /**
29
-     * Strategy for laying out the form
30
-     *
31
-     * @var EE_Form_Section_Layout_Base
32
-     */
33
-    protected $_layout_strategy;
34
-
35
-    /**
36
-     * Whether or not this form has received and validated a form submission yet
37
-     *
38
-     * @var boolean
39
-     */
40
-    protected $_received_submission = false;
41
-
42
-    /**
43
-     * message displayed to users upon successful form submission
44
-     *
45
-     * @var string
46
-     */
47
-    protected $_form_submission_success_message = '';
48
-
49
-    /**
50
-     * message displayed to users upon unsuccessful form submission
51
-     *
52
-     * @var string
53
-     */
54
-    protected $_form_submission_error_message = '';
55
-
56
-    /**
57
-     * @var array like post / request
58
-     */
59
-    protected $cached_request_data;
60
-
61
-    /**
62
-     * Stores whether this form (and its sub-sections) were found to be valid or not.
63
-     * Starts off as null, but once the form is validated, it set to either true or false
64
-     * @var boolean|null
65
-     */
66
-    protected $is_valid;
67
-
68
-    /**
69
-     * Stores all the data that will localized for form validation
70
-     *
71
-     * @var array
72
-     */
73
-    protected static $_js_localization = array();
74
-
75
-    /**
76
-     * whether or not the form's localized validation JS vars have been set
77
-     *
78
-     * @type boolean
79
-     */
80
-    protected static $_scripts_localized = false;
81
-
82
-
83
-    /**
84
-     * when constructing a proper form section, calls _construct_finalize on children
85
-     * so that they know who their parent is, and what name they've been given.
86
-     *
87
-     * @param array[] $options_array   {
88
-     * @type          $subsections     EE_Form_Section_Validatable[] where keys are the section's name
89
-     * @type          $include         string[] numerically-indexed where values are section names to be included,
90
-     *                                 and in that order. This is handy if you want
91
-     *                                 the subsections to be ordered differently than the default, and if you override
92
-     *                                 which fields are shown
93
-     * @type          $exclude         string[] values are subsections to be excluded. This is handy if you want
94
-     *                                 to remove certain default subsections (note: if you specify BOTH 'include' AND
95
-     *                                 'exclude', the inclusions will be applied first, and the exclusions will exclude
96
-     *                                 items from that list of inclusions)
97
-     * @type          $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
98
-     *                                 } @see EE_Form_Section_Validatable::__construct()
99
-     * @throws EE_Error
100
-     */
101
-    public function __construct($options_array = array())
102
-    {
103
-        $options_array = (array) apply_filters(
104
-            'FHEE__EE_Form_Section_Proper___construct__options_array',
105
-            $options_array,
106
-            $this
107
-        );
108
-        // call parent first, as it may be setting the name
109
-        parent::__construct($options_array);
110
-        // if they've included subsections in the constructor, add them now
111
-        if (isset($options_array['include'])) {
112
-            // we are going to make sure we ONLY have those subsections to include
113
-            // AND we are going to make sure they're in that specified order
114
-            $reordered_subsections = array();
115
-            foreach ($options_array['include'] as $input_name) {
116
-                if (isset($this->_subsections[ $input_name ])) {
117
-                    $reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
118
-                }
119
-            }
120
-            $this->_subsections = $reordered_subsections;
121
-        }
122
-        if (isset($options_array['exclude'])) {
123
-            $exclude            = $options_array['exclude'];
124
-            $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
125
-        }
126
-        if (isset($options_array['layout_strategy'])) {
127
-            $this->_layout_strategy = $options_array['layout_strategy'];
128
-        }
129
-        if (! $this->_layout_strategy) {
130
-            $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
131
-        }
132
-        $this->_layout_strategy->_construct_finalize($this);
133
-        // ok so we are definitely going to want the forms JS,
134
-        // so enqueue it or remember to enqueue it during wp_enqueue_scripts
135
-        if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
136
-            // ok so they've constructed this object after when they should have.
137
-            // just enqueue the generic form scripts and initialize the form immediately in the JS
138
-            EE_Form_Section_Proper::wp_enqueue_scripts(true);
139
-        } else {
140
-            add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
141
-            add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
142
-        }
143
-        add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
144
-        /**
145
-         * Gives other plugins a chance to hook in before construct finalize is called.
146
-         * The form probably doesn't yet have a parent form section.
147
-         * Since 4.9.32, when this action was introduced, this is the best place to add a subsection onto a form,
148
-         * assuming you don't care what the form section's name, HTML ID, or HTML name etc are.
149
-         * Also see AHEE__EE_Form_Section_Proper___construct_finalize__end
150
-         *
151
-         * @since 4.9.32
152
-         * @param EE_Form_Section_Proper $this          before __construct is done, but all of its logic,
153
-         *                                              except maybe calling _construct_finalize has been done
154
-         * @param array                  $options_array options passed into the constructor
155
-         */
156
-        do_action(
157
-            'AHEE__EE_Form_Input_Base___construct__before_construct_finalize_called',
158
-            $this,
159
-            $options_array
160
-        );
161
-        if (isset($options_array['name'])) {
162
-            $this->_construct_finalize(null, $options_array['name']);
163
-        }
164
-    }
165
-
166
-
167
-    /**
168
-     * Finishes construction given the parent form section and this form section's name
169
-     *
170
-     * @param EE_Form_Section_Proper $parent_form_section
171
-     * @param string                 $name
172
-     * @throws EE_Error
173
-     */
174
-    public function _construct_finalize($parent_form_section, $name)
175
-    {
176
-        parent::_construct_finalize($parent_form_section, $name);
177
-        $this->_set_default_name_if_empty();
178
-        $this->_set_default_html_id_if_empty();
179
-        foreach ($this->_subsections as $subsection_name => $subsection) {
180
-            if ($subsection instanceof EE_Form_Section_Base) {
181
-                $subsection->_construct_finalize($this, $subsection_name);
182
-            } else {
183
-                throw new EE_Error(
184
-                    sprintf(
185
-                        esc_html__(
186
-                            'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
187
-                            'event_espresso'
188
-                        ),
189
-                        $subsection_name,
190
-                        get_class($this),
191
-                        $subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
192
-                    )
193
-                );
194
-            }
195
-        }
196
-        /**
197
-         * Action performed just after form has been given a name (and HTML ID etc) and is fully constructed.
198
-         * If you have code that should modify the form and needs it and its subsections to have a name, HTML ID
199
-         * (or other attributes derived from the name like the HTML label id, etc), this is where it should be done.
200
-         * This might only happen just before displaying the form, or just before it receives form submission data.
201
-         * If you need to modify the form or its subsections before _construct_finalize is called on it (and we've
202
-         * ensured it has a name, HTML IDs, etc
203
-         *
204
-         * @param EE_Form_Section_Proper      $this
205
-         * @param EE_Form_Section_Proper|null $parent_form_section
206
-         * @param string                      $name
207
-         */
208
-        do_action(
209
-            'AHEE__EE_Form_Section_Proper___construct_finalize__end',
210
-            $this,
211
-            $parent_form_section,
212
-            $name
213
-        );
214
-    }
215
-
216
-
217
-    /**
218
-     * Gets the layout strategy for this form section
219
-     *
220
-     * @return EE_Form_Section_Layout_Base
221
-     */
222
-    public function get_layout_strategy()
223
-    {
224
-        return $this->_layout_strategy;
225
-    }
226
-
227
-
228
-    /**
229
-     * Gets the HTML for a single input for this form section according
230
-     * to the layout strategy
231
-     *
232
-     * @param EE_Form_Input_Base $input
233
-     * @return string
234
-     */
235
-    public function get_html_for_input($input)
236
-    {
237
-        return $this->_layout_strategy->layout_input($input);
238
-    }
239
-
240
-
241
-    /**
242
-     * was_submitted - checks if form inputs are present in request data
243
-     * Basically an alias for form_data_present_in() (which is used by both
244
-     * proper form sections and form inputs)
245
-     *
246
-     * @param null $form_data
247
-     * @return boolean
248
-     * @throws EE_Error
249
-     */
250
-    public function was_submitted($form_data = null)
251
-    {
252
-        return $this->form_data_present_in($form_data);
253
-    }
254
-
255
-    /**
256
-     * Gets the cached request data; but if there is none, or $req_data was set with
257
-     * something different, refresh the cache, and then return it
258
-     * @param null $req_data
259
-     * @return array
260
-     */
261
-    protected function getCachedRequest($req_data = null)
262
-    {
263
-        if (
264
-            $this->cached_request_data === null
265
-            || (
266
-                $req_data !== null
267
-                && $req_data !== $this->cached_request_data
268
-            )
269
-        ) {
270
-            $req_data = apply_filters(
271
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
272
-                $req_data,
273
-                $this
274
-            );
275
-            if ($req_data === null) {
276
-                /** @var RequestInterface $request */
277
-                $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
278
-                $req_data = $request->requestParams();
279
-            }
280
-            $req_data = apply_filters(
281
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
282
-                $req_data,
283
-                $this
284
-            );
285
-            $this->cached_request_data = (array) $req_data;
286
-        }
287
-        return $this->cached_request_data;
288
-    }
289
-
290
-
291
-    /**
292
-     * After the form section is initially created, call this to sanitize the data in the submission
293
-     * which relates to this form section, validate it, and set it as properties on the form.
294
-     *
295
-     * @param array|null $req_data should usually be post data (the default).
296
-     *                             However, you CAN supply a different array.
297
-     *                             Consider using set_defaults() instead however.
298
-     *                             (If you rendered the form in the page using $form_x->get_html()
299
-     *                             the inputs will have the correct name in the request data for this function
300
-     *                             to find them and populate the form with them.
301
-     *                             If you have a flat form (with only input subsections),
302
-     *                             you can supply a flat array where keys
303
-     *                             are the form input names and values are their values)
304
-     * @param boolean    $validate whether or not to perform validation on this data. Default is,
305
-     *                             of course, to validate that data, and set errors on the invalid values.
306
-     *                             But if the data has already been validated
307
-     *                             (eg you validated the data then stored it in the DB)
308
-     *                             you may want to skip this step.
309
-     * @throws InvalidArgumentException
310
-     * @throws InvalidInterfaceException
311
-     * @throws InvalidDataTypeException
312
-     * @throws EE_Error
313
-     */
314
-    public function receive_form_submission($req_data = null, $validate = true)
315
-    {
316
-        $req_data = $this->getCachedRequest($req_data);
317
-        $this->_normalize($req_data);
318
-        if ($validate) {
319
-            $this->_validate();
320
-            // if it's invalid, we're going to want to re-display so remember what they submitted
321
-            if (! $this->is_valid()) {
322
-                $this->store_submitted_form_data_in_session();
323
-            }
324
-        }
325
-        if ($this->submission_error_message() === '' && ! $this->is_valid()) {
326
-            $this->set_submission_error_message();
327
-        }
328
-        do_action(
329
-            'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
330
-            $req_data,
331
-            $this,
332
-            $validate
333
-        );
334
-    }
335
-
336
-
337
-    /**
338
-     * caches the originally submitted input values in the session
339
-     * so that they can be used to repopulate the form if it failed validation
340
-     *
341
-     * @return boolean whether or not the data was successfully stored in the session
342
-     * @throws InvalidArgumentException
343
-     * @throws InvalidInterfaceException
344
-     * @throws InvalidDataTypeException
345
-     * @throws EE_Error
346
-     */
347
-    protected function store_submitted_form_data_in_session()
348
-    {
349
-        return EE_Registry::instance()->SSN->set_session_data(
350
-            array(
351
-                EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
352
-            )
353
-        );
354
-    }
355
-
356
-
357
-    /**
358
-     * retrieves the originally submitted input values in the session
359
-     * so that they can be used to repopulate the form if it failed validation
360
-     *
361
-     * @return array
362
-     * @throws InvalidArgumentException
363
-     * @throws InvalidInterfaceException
364
-     * @throws InvalidDataTypeException
365
-     */
366
-    protected function get_submitted_form_data_from_session()
367
-    {
368
-        $session = EE_Registry::instance()->SSN;
369
-        if ($session instanceof EE_Session) {
370
-            return $session->get_session_data(
371
-                EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
372
-            );
373
-        }
374
-        return array();
375
-    }
376
-
377
-
378
-    /**
379
-     * flushed the originally submitted input values from the session
380
-     *
381
-     * @return boolean whether or not the data was successfully removed from the session
382
-     * @throws InvalidArgumentException
383
-     * @throws InvalidInterfaceException
384
-     * @throws InvalidDataTypeException
385
-     */
386
-    public static function flush_submitted_form_data_from_session()
387
-    {
388
-        return EE_Registry::instance()->SSN->reset_data(
389
-            array(EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
390
-        );
391
-    }
392
-
393
-
394
-    /**
395
-     * Populates this form and its subsections with data from the session.
396
-     * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
397
-     * validation errors when displaying too)
398
-     * Returns true if the form was populated from the session, false otherwise
399
-     *
400
-     * @return boolean
401
-     * @throws InvalidArgumentException
402
-     * @throws InvalidInterfaceException
403
-     * @throws InvalidDataTypeException
404
-     * @throws EE_Error
405
-     */
406
-    public function populate_from_session()
407
-    {
408
-        $form_data_in_session = $this->get_submitted_form_data_from_session();
409
-        if (empty($form_data_in_session)) {
410
-            return false;
411
-        }
412
-        $this->receive_form_submission($form_data_in_session);
413
-        add_action('shutdown', array('EE_Form_Section_Proper', 'flush_submitted_form_data_from_session'));
414
-        if ($this->form_data_present_in($form_data_in_session)) {
415
-            return true;
416
-        }
417
-        return false;
418
-    }
419
-
420
-
421
-    /**
422
-     * Populates the default data for the form, given an array where keys are
423
-     * the input names, and values are their values (preferably normalized to be their
424
-     * proper PHP types, not all strings... although that should be ok too).
425
-     * Proper subsections are sub-arrays, the key being the subsection's name, and
426
-     * the value being an array formatted in teh same way
427
-     *
428
-     * @param array $default_data
429
-     * @throws EE_Error
430
-     */
431
-    public function populate_defaults($default_data)
432
-    {
433
-        foreach ($this->subsections(false) as $subsection_name => $subsection) {
434
-            if (isset($default_data[ $subsection_name ])) {
435
-                if ($subsection instanceof EE_Form_Input_Base) {
436
-                    $subsection->set_default($default_data[ $subsection_name ]);
437
-                } elseif ($subsection instanceof EE_Form_Section_Proper) {
438
-                    $subsection->populate_defaults($default_data[ $subsection_name ]);
439
-                }
440
-            }
441
-        }
442
-    }
443
-
444
-
445
-    /**
446
-     * returns true if subsection exists
447
-     *
448
-     * @param string $name
449
-     * @return boolean
450
-     */
451
-    public function subsection_exists($name)
452
-    {
453
-        return isset($this->_subsections[ $name ]) ? true : false;
454
-    }
455
-
456
-
457
-    /**
458
-     * Gets the subsection specified by its name
459
-     *
460
-     * @param string  $name
461
-     * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
462
-     *                                                      so that the inputs will be properly configured.
463
-     *                                                      However, some client code may be ok
464
-     *                                                      with construction finalize being called later
465
-     *                                                      (realizing that the subsections' html names
466
-     *                                                      might not be set yet, etc.)
467
-     * @return EE_Form_Section_Base
468
-     * @throws EE_Error
469
-     */
470
-    public function get_subsection($name, $require_construction_to_be_finalized = true)
471
-    {
472
-        if ($require_construction_to_be_finalized) {
473
-            $this->ensure_construct_finalized_called();
474
-        }
475
-        return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
476
-    }
477
-
478
-
479
-    /**
480
-     * Gets all the validatable subsections of this form section
481
-     *
482
-     * @return EE_Form_Section_Validatable[]
483
-     * @throws EE_Error
484
-     */
485
-    public function get_validatable_subsections()
486
-    {
487
-        $validatable_subsections = array();
488
-        foreach ($this->subsections() as $name => $obj) {
489
-            if ($obj instanceof EE_Form_Section_Validatable) {
490
-                $validatable_subsections[ $name ] = $obj;
491
-            }
492
-        }
493
-        return $validatable_subsections;
494
-    }
495
-
496
-
497
-    /**
498
-     * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
499
-     * throw an EE_Error.
500
-     *
501
-     * @param string  $name
502
-     * @param boolean $require_construction_to_be_finalized most client code should
503
-     *                                                      leave this as TRUE so that the inputs will be properly
504
-     *                                                      configured. However, some client code may be ok with
505
-     *                                                      construction finalize being called later
506
-     *                                                      (realizing that the subsections' html names might not be
507
-     *                                                      set yet, etc.)
508
-     * @return EE_Form_Input_Base
509
-     * @throws EE_Error
510
-     */
511
-    public function get_input($name, $require_construction_to_be_finalized = true)
512
-    {
513
-        $subsection = $this->get_subsection(
514
-            $name,
515
-            $require_construction_to_be_finalized
516
-        );
517
-        if (! $subsection instanceof EE_Form_Input_Base) {
518
-            throw new EE_Error(
519
-                sprintf(
520
-                    esc_html__(
521
-                        "Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
522
-                        'event_espresso'
523
-                    ),
524
-                    $name,
525
-                    get_class($this),
526
-                    $subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
527
-                )
528
-            );
529
-        }
530
-        return $subsection;
531
-    }
532
-
533
-
534
-    /**
535
-     * Like get_input(), gets the proper subsection of the form given the name,
536
-     * otherwise throws an EE_Error
537
-     *
538
-     * @param string  $name
539
-     * @param boolean $require_construction_to_be_finalized most client code should
540
-     *                                                      leave this as TRUE so that the inputs will be properly
541
-     *                                                      configured. However, some client code may be ok with
542
-     *                                                      construction finalize being called later
543
-     *                                                      (realizing that the subsections' html names might not be
544
-     *                                                      set yet, etc.)
545
-     * @return EE_Form_Section_Proper
546
-     * @throws EE_Error
547
-     */
548
-    public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
549
-    {
550
-        $subsection = $this->get_subsection(
551
-            $name,
552
-            $require_construction_to_be_finalized
553
-        );
554
-        if (! $subsection instanceof EE_Form_Section_Proper) {
555
-            throw new EE_Error(
556
-                sprintf(
557
-                    esc_html__(
558
-                        "Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'",
559
-                        'event_espresso'
560
-                    ),
561
-                    $name,
562
-                    get_class($this)
563
-                )
564
-            );
565
-        }
566
-        return $subsection;
567
-    }
568
-
569
-
570
-    /**
571
-     * Gets the value of the specified input. Should be called after receive_form_submission()
572
-     * or populate_defaults() on the form, where the normalized value on the input is set.
573
-     *
574
-     * @param string $name
575
-     * @return mixed depending on the input's type and its normalization strategy
576
-     * @throws EE_Error
577
-     */
578
-    public function get_input_value($name)
579
-    {
580
-        $input = $this->get_input($name);
581
-        return $input->normalized_value();
582
-    }
583
-
584
-
585
-    /**
586
-     * Checks if this form section itself is valid, and then checks its subsections
587
-     *
588
-     * @throws EE_Error
589
-     * @return boolean
590
-     */
591
-    public function is_valid()
592
-    {
593
-        if ($this->is_valid === null) {
594
-            if (! $this->has_received_submission()) {
595
-                throw new EE_Error(
596
-                    sprintf(
597
-                        esc_html__(
598
-                            'You cannot check if a form is valid before receiving the form submission using receive_form_submission',
599
-                            'event_espresso'
600
-                        )
601
-                    )
602
-                );
603
-            }
604
-            if (! parent::is_valid()) {
605
-                $this->is_valid = false;
606
-            } else {
607
-                // ok so no general errors to this entire form section.
608
-                // so let's check the subsections, but only set errors if that hasn't been done yet
609
-                $this->is_valid = true;
610
-                foreach ($this->get_validatable_subsections() as $subsection) {
611
-                    if (! $subsection->is_valid()) {
612
-                        $this->is_valid = false;
613
-                    }
614
-                }
615
-            }
616
-        }
617
-        return $this->is_valid;
618
-    }
619
-
620
-
621
-    /**
622
-     * gets the default name of this form section if none is specified
623
-     *
624
-     * @return void
625
-     */
626
-    protected function _set_default_name_if_empty()
627
-    {
628
-        if (! $this->_name) {
629
-            $classname    = get_class($this);
630
-            $default_name = str_replace('EE_', '', $classname);
631
-            $this->_name  = $default_name;
632
-        }
633
-    }
634
-
635
-
636
-    /**
637
-     * Returns the HTML for the form, except for the form opening and closing tags
638
-     * (as the form section doesn't know where you necessarily want to send the information to),
639
-     * and except for a submit button. Enqueues JS and CSS; if called early enough we will
640
-     * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
641
-     * Not doing_it_wrong because theoretically this CAN be used properly,
642
-     * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
643
-     * any CSS.
644
-     *
645
-     * @throws InvalidArgumentException
646
-     * @throws InvalidInterfaceException
647
-     * @throws InvalidDataTypeException
648
-     * @throws EE_Error
649
-     */
650
-    public function get_html_and_js()
651
-    {
652
-        $this->enqueue_js();
653
-        return $this->get_html();
654
-    }
655
-
656
-
657
-    /**
658
-     * returns HTML for displaying this form section. recursively calls display_section() on all subsections
659
-     *
660
-     * @param bool $display_previously_submitted_data
661
-     * @return string
662
-     * @throws InvalidArgumentException
663
-     * @throws InvalidInterfaceException
664
-     * @throws InvalidDataTypeException
665
-     * @throws EE_Error
666
-     * @throws EE_Error
667
-     * @throws EE_Error
668
-     */
669
-    public function get_html($display_previously_submitted_data = true)
670
-    {
671
-        $this->ensure_construct_finalized_called();
672
-        if ($display_previously_submitted_data) {
673
-            $this->populate_from_session();
674
-        }
675
-        return $this->_form_html_filter
676
-            ? $this->_form_html_filter->filterHtml($this->_layout_strategy->layout_form(), $this)
677
-            : $this->_layout_strategy->layout_form();
678
-    }
679
-
680
-
681
-    /**
682
-     * enqueues JS and CSS for the form.
683
-     * It is preferred to call this before wp_enqueue_scripts so the
684
-     * scripts and styles can be put in the header, but if called later
685
-     * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
686
-     * only be in the header; but in HTML5 its ok in the body.
687
-     * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
688
-     * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
689
-     *
690
-     * @return void
691
-     * @throws EE_Error
692
-     */
693
-    public function enqueue_js()
694
-    {
695
-        $this->_enqueue_and_localize_form_js();
696
-        foreach ($this->subsections() as $subsection) {
697
-            $subsection->enqueue_js();
698
-        }
699
-    }
700
-
701
-
702
-    /**
703
-     * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
704
-     * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
705
-     * the wp_enqueue_scripts hook.
706
-     * However, registering the form js and localizing it can happen when we
707
-     * actually output the form (which is preferred, seeing how teh form's fields
708
-     * could change until it's actually outputted)
709
-     *
710
-     * @param boolean $init_form_validation_automatically whether or not we want the form validation
711
-     *                                                    to be triggered automatically or not
712
-     * @return void
713
-     */
714
-    public static function wp_enqueue_scripts($init_form_validation_automatically = true)
715
-    {
716
-        wp_register_script(
717
-            'ee_form_section_validation',
718
-            EE_GLOBAL_ASSETS_URL . 'scripts' . '/form_section_validation.js',
719
-            array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
720
-            EVENT_ESPRESSO_VERSION,
721
-            true
722
-        );
723
-        wp_localize_script(
724
-            'ee_form_section_validation',
725
-            'ee_form_section_validation_init',
726
-            array('init' => $init_form_validation_automatically ? '1' : '0')
727
-        );
728
-    }
729
-
730
-
731
-    /**
732
-     * gets the variables used by form_section_validation.js.
733
-     * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
734
-     * but before the wordpress hook wp_loaded
735
-     *
736
-     * @throws EE_Error
737
-     */
738
-    public function _enqueue_and_localize_form_js()
739
-    {
740
-        $this->ensure_construct_finalized_called();
741
-        // actually, we don't want to localize just yet. There may be other forms on the page.
742
-        // so we need to add our form section data to a static variable accessible by all form sections
743
-        // and localize it just before the footer
744
-        $this->localize_validation_rules();
745
-        add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
746
-        add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
747
-    }
748
-
749
-
750
-    /**
751
-     * add our form section data to a static variable accessible by all form sections
752
-     *
753
-     * @param bool $return_for_subsection
754
-     * @return void
755
-     * @throws EE_Error
756
-     */
757
-    public function localize_validation_rules($return_for_subsection = false)
758
-    {
759
-        // we only want to localize vars ONCE for the entire form,
760
-        // so if the form section doesn't have a parent, then it must be the top dog
761
-        if ($return_for_subsection || ! $this->parent_section()) {
762
-            EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
763
-                'form_section_id'  => $this->html_id(true),
764
-                'validation_rules' => $this->get_jquery_validation_rules(),
765
-                'other_data'       => $this->get_other_js_data(),
766
-                'errors'           => $this->subsection_validation_errors_by_html_name(),
767
-            );
768
-            EE_Form_Section_Proper::$_scripts_localized                                = true;
769
-        }
770
-    }
771
-
772
-
773
-    /**
774
-     * Gets an array of extra data that will be useful for client-side javascript.
775
-     * This is primarily data added by inputs and forms in addition to any
776
-     * scripts they might enqueue
777
-     *
778
-     * @param array $form_other_js_data
779
-     * @return array
780
-     * @throws EE_Error
781
-     */
782
-    public function get_other_js_data($form_other_js_data = array())
783
-    {
784
-        foreach ($this->subsections() as $subsection) {
785
-            $form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
786
-        }
787
-        return $form_other_js_data;
788
-    }
789
-
790
-
791
-    /**
792
-     * Gets a flat array of inputs for this form section and its subsections.
793
-     * Keys are their form names, and values are the inputs themselves
794
-     *
795
-     * @return EE_Form_Input_Base
796
-     * @throws EE_Error
797
-     */
798
-    public function inputs_in_subsections()
799
-    {
800
-        $inputs = array();
801
-        foreach ($this->subsections() as $subsection) {
802
-            if ($subsection instanceof EE_Form_Input_Base) {
803
-                $inputs[ $subsection->html_name() ] = $subsection;
804
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
805
-                $inputs += $subsection->inputs_in_subsections();
806
-            }
807
-        }
808
-        return $inputs;
809
-    }
810
-
811
-
812
-    /**
813
-     * Gets a flat array of all the validation errors.
814
-     * Keys are html names (because those should be unique)
815
-     * and values are a string of all their validation errors
816
-     *
817
-     * @return string[]
818
-     * @throws EE_Error
819
-     */
820
-    public function subsection_validation_errors_by_html_name()
821
-    {
822
-        $inputs = $this->inputs();
823
-        $errors = array();
824
-        foreach ($inputs as $form_input) {
825
-            if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
826
-                $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
827
-            }
828
-        }
829
-        return $errors;
830
-    }
831
-
832
-
833
-    /**
834
-     * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
835
-     * Should be setup by each form during the _enqueues_and_localize_form_js
836
-     *
837
-     * @throws InvalidArgumentException
838
-     * @throws InvalidInterfaceException
839
-     * @throws InvalidDataTypeException
840
-     */
841
-    public static function localize_script_for_all_forms()
842
-    {
843
-        // allow inputs and stuff to hook in their JS and stuff here
844
-        do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
845
-        EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
846
-        $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
847
-            ? EE_Registry::instance()->CFG->registration->email_validation_level
848
-            : 'wp_default';
849
-        EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
850
-        wp_enqueue_script('ee_form_section_validation');
851
-        wp_localize_script(
852
-            'ee_form_section_validation',
853
-            'ee_form_section_vars',
854
-            EE_Form_Section_Proper::$_js_localization
855
-        );
856
-    }
857
-
858
-
859
-    /**
860
-     * ensure_scripts_localized
861
-     *
862
-     * @throws EE_Error
863
-     */
864
-    public function ensure_scripts_localized()
865
-    {
866
-        if (! EE_Form_Section_Proper::$_scripts_localized) {
867
-            $this->_enqueue_and_localize_form_js();
868
-        }
869
-    }
870
-
871
-
872
-    /**
873
-     * Gets the hard-coded validation error messages to be used in the JS. The convention
874
-     * is that the key here should be the same as the custom validation rule put in the JS file
875
-     *
876
-     * @return array keys are custom validation rules, and values are internationalized strings
877
-     */
878
-    private static function _get_localized_error_messages()
879
-    {
880
-        return array(
881
-            'validUrl' => wp_strip_all_tags(__('This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg', 'event_espresso')),
882
-            'regex'    => wp_strip_all_tags(__('Please check your input', 'event_espresso'))
883
-        );
884
-    }
885
-
886
-
887
-    /**
888
-     * @return array
889
-     */
890
-    public static function js_localization()
891
-    {
892
-        return self::$_js_localization;
893
-    }
894
-
895
-
896
-    /**
897
-     * @return void
898
-     */
899
-    public static function reset_js_localization()
900
-    {
901
-        self::$_js_localization = array();
902
-    }
903
-
904
-
905
-    /**
906
-     * Gets the JS to put inside the jquery validation rules for subsection of this form section.
907
-     * See parent function for more...
908
-     *
909
-     * @return array
910
-     * @throws EE_Error
911
-     */
912
-    public function get_jquery_validation_rules()
913
-    {
914
-        $jquery_validation_rules = array();
915
-        foreach ($this->get_validatable_subsections() as $subsection) {
916
-            $jquery_validation_rules = array_merge(
917
-                $jquery_validation_rules,
918
-                $subsection->get_jquery_validation_rules()
919
-            );
920
-        }
921
-        return $jquery_validation_rules;
922
-    }
923
-
924
-
925
-    /**
926
-     * Sanitizes all the data and sets the sanitized value of each field
927
-     *
928
-     * @param array $req_data
929
-     * @return void
930
-     * @throws EE_Error
931
-     */
932
-    protected function _normalize($req_data)
933
-    {
934
-        $this->_received_submission = true;
935
-        $this->_validation_errors   = array();
936
-        foreach ($this->get_validatable_subsections() as $subsection) {
937
-            try {
938
-                $subsection->_normalize($req_data);
939
-            } catch (EE_Validation_Error $e) {
940
-                $subsection->add_validation_error($e);
941
-            }
942
-        }
943
-    }
944
-
945
-
946
-    /**
947
-     * Performs validation on this form section and its subsections.
948
-     * For each subsection,
949
-     * calls _validate_{subsection_name} on THIS form (if the function exists)
950
-     * and passes it the subsection, then calls _validate on that subsection.
951
-     * If you need to perform validation on the form as a whole (considering multiple)
952
-     * you would be best to override this _validate method,
953
-     * calling parent::_validate() first.
954
-     *
955
-     * @throws EE_Error
956
-     */
957
-    protected function _validate()
958
-    {
959
-        // reset the cache of whether this form is valid or not- we're re-validating it now
960
-        $this->is_valid = null;
961
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
962
-            if (method_exists($this, '_validate_' . $subsection_name)) {
963
-                call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
964
-            }
965
-            $subsection->_validate();
966
-        }
967
-    }
968
-
969
-
970
-    /**
971
-     * Gets all the validated inputs for the form section
972
-     *
973
-     * @return array
974
-     * @throws EE_Error
975
-     */
976
-    public function valid_data()
977
-    {
978
-        $inputs = array();
979
-        foreach ($this->subsections() as $subsection_name => $subsection) {
980
-            if ($subsection instanceof EE_Form_Section_Proper) {
981
-                $inputs[ $subsection_name ] = $subsection->valid_data();
982
-            } elseif ($subsection instanceof EE_Form_Input_Base) {
983
-                $inputs[ $subsection_name ] = $subsection->normalized_value();
984
-            }
985
-        }
986
-        return $inputs;
987
-    }
988
-
989
-
990
-    /**
991
-     * Gets all the inputs on this form section
992
-     *
993
-     * @return EE_Form_Input_Base[]
994
-     * @throws EE_Error
995
-     */
996
-    public function inputs()
997
-    {
998
-        $inputs = array();
999
-        foreach ($this->subsections() as $subsection_name => $subsection) {
1000
-            if ($subsection instanceof EE_Form_Input_Base) {
1001
-                $inputs[ $subsection_name ] = $subsection;
1002
-            }
1003
-        }
1004
-        return $inputs;
1005
-    }
1006
-
1007
-
1008
-    /**
1009
-     * Gets all the subsections which are a proper form
1010
-     *
1011
-     * @return EE_Form_Section_Proper[]
1012
-     * @throws EE_Error
1013
-     */
1014
-    public function subforms()
1015
-    {
1016
-        $form_sections = array();
1017
-        foreach ($this->subsections() as $name => $obj) {
1018
-            if ($obj instanceof EE_Form_Section_Proper) {
1019
-                $form_sections[ $name ] = $obj;
1020
-            }
1021
-        }
1022
-        return $form_sections;
1023
-    }
1024
-
1025
-
1026
-    /**
1027
-     * Gets all the subsections (inputs, proper subsections, or html-only sections).
1028
-     * Consider using inputs() or subforms()
1029
-     * if you only want form inputs or proper form sections.
1030
-     *
1031
-     * @param boolean $require_construction_to_be_finalized most client code should
1032
-     *                                                      leave this as TRUE so that the inputs will be properly
1033
-     *                                                      configured. However, some client code may be ok with
1034
-     *                                                      construction finalize being called later
1035
-     *                                                      (realizing that the subsections' html names might not be
1036
-     *                                                      set yet, etc.)
1037
-     * @return EE_Form_Section_Proper[]
1038
-     * @throws EE_Error
1039
-     */
1040
-    public function subsections($require_construction_to_be_finalized = true)
1041
-    {
1042
-        if ($require_construction_to_be_finalized) {
1043
-            $this->ensure_construct_finalized_called();
1044
-        }
1045
-        return $this->_subsections;
1046
-    }
1047
-
1048
-
1049
-    /**
1050
-     * Returns whether this form has any subforms or inputs
1051
-     * @return bool
1052
-     */
1053
-    public function hasSubsections()
1054
-    {
1055
-        return ! empty($this->_subsections);
1056
-    }
1057
-
1058
-
1059
-    /**
1060
-     * Returns a simple array where keys are input names, and values are their normalized
1061
-     * values. (Similar to calling get_input_value on inputs)
1062
-     *
1063
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1064
-     *                                        or just this forms' direct children inputs
1065
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1066
-     *                                        or allow multidimensional array
1067
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
1068
-     *                                        with array keys being input names
1069
-     *                                        (regardless of whether they are from a subsection or not),
1070
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1071
-     *                                        where keys are always subsection names and values are either
1072
-     *                                        the input's normalized value, or an array like the top-level array
1073
-     * @throws EE_Error
1074
-     */
1075
-    public function input_values($include_subform_inputs = false, $flatten = false)
1076
-    {
1077
-        return $this->_input_values(false, $include_subform_inputs, $flatten);
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
1083
-     * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
1084
-     * is not necessarily the value we want to display to users. This creates an array
1085
-     * where keys are the input names, and values are their display values
1086
-     *
1087
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1088
-     *                                        or just this forms' direct children inputs
1089
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1090
-     *                                        or allow multidimensional array
1091
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
1092
-     *                                        with array keys being input names
1093
-     *                                        (regardless of whether they are from a subsection or not),
1094
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1095
-     *                                        where keys are always subsection names and values are either
1096
-     *                                        the input's normalized value, or an array like the top-level array
1097
-     * @throws EE_Error
1098
-     */
1099
-    public function input_pretty_values($include_subform_inputs = false, $flatten = false)
1100
-    {
1101
-        return $this->_input_values(true, $include_subform_inputs, $flatten);
1102
-    }
1103
-
1104
-
1105
-    /**
1106
-     * Gets the input values from the form
1107
-     *
1108
-     * @param boolean $pretty                 Whether to retrieve the pretty value,
1109
-     *                                        or just the normalized value
1110
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1111
-     *                                        or just this forms' direct children inputs
1112
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1113
-     *                                        or allow multidimensional array
1114
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
1115
-     *                                        input names (regardless of whether they are from a subsection or not),
1116
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1117
-     *                                        where keys are always subsection names and values are either
1118
-     *                                        the input's normalized value, or an array like the top-level array
1119
-     * @throws EE_Error
1120
-     */
1121
-    public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
1122
-    {
1123
-        $input_values = array();
1124
-        foreach ($this->subsections() as $subsection_name => $subsection) {
1125
-            if ($subsection instanceof EE_Form_Input_Base) {
1126
-                $input_values[ $subsection_name ] = $pretty
1127
-                    ? $subsection->pretty_value()
1128
-                    : $subsection->normalized_value();
1129
-            } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1130
-                $subform_input_values = $subsection->_input_values(
1131
-                    $pretty,
1132
-                    $include_subform_inputs,
1133
-                    $flatten
1134
-                );
1135
-                if ($flatten) {
1136
-                    $input_values = array_merge($input_values, $subform_input_values);
1137
-                } else {
1138
-                    $input_values[ $subsection_name ] = $subform_input_values;
1139
-                }
1140
-            }
1141
-        }
1142
-        return $input_values;
1143
-    }
1144
-
1145
-
1146
-    /**
1147
-     * Gets the originally submitted input values from the form
1148
-     *
1149
-     * @param boolean $include_subforms  Whether to include inputs from subforms,
1150
-     *                                   or just this forms' direct children inputs
1151
-     * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1152
-     *                                   with array keys being input names
1153
-     *                                   (regardless of whether they are from a subsection or not),
1154
-     *                                   and if $flatten is FALSE it can be a multidimensional array
1155
-     *                                   where keys are always subsection names and values are either
1156
-     *                                   the input's normalized value, or an array like the top-level array
1157
-     * @throws EE_Error
1158
-     */
1159
-    public function submitted_values($include_subforms = false)
1160
-    {
1161
-        $submitted_values = array();
1162
-        foreach ($this->subsections() as $subsection) {
1163
-            if ($subsection instanceof EE_Form_Input_Base) {
1164
-                // is this input part of an array of inputs?
1165
-                if (strpos($subsection->html_name(), '[') !== false) {
1166
-                    $full_input_name  = EEH_Array::convert_array_values_to_keys(
1167
-                        explode(
1168
-                            '[',
1169
-                            str_replace(']', '', $subsection->html_name())
1170
-                        ),
1171
-                        $subsection->raw_value()
1172
-                    );
1173
-                    $submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1174
-                } else {
1175
-                    $submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1176
-                }
1177
-            } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1178
-                $subform_input_values = $subsection->submitted_values($include_subforms);
1179
-                $submitted_values     = array_replace_recursive($submitted_values, $subform_input_values);
1180
-            }
1181
-        }
1182
-        return $submitted_values;
1183
-    }
1184
-
1185
-
1186
-    /**
1187
-     * Indicates whether or not this form has received a submission yet
1188
-     * (ie, had receive_form_submission called on it yet)
1189
-     *
1190
-     * @return boolean
1191
-     * @throws EE_Error
1192
-     */
1193
-    public function has_received_submission()
1194
-    {
1195
-        $this->ensure_construct_finalized_called();
1196
-        return $this->_received_submission;
1197
-    }
1198
-
1199
-
1200
-    /**
1201
-     * Equivalent to passing 'exclude' in the constructor's options array.
1202
-     * Removes the listed inputs from the form
1203
-     *
1204
-     * @param array $inputs_to_exclude values are the input names
1205
-     * @return void
1206
-     */
1207
-    public function exclude(array $inputs_to_exclude = array())
1208
-    {
1209
-        foreach ($inputs_to_exclude as $input_to_exclude_name) {
1210
-            unset($this->_subsections[ $input_to_exclude_name ]);
1211
-        }
1212
-    }
1213
-
1214
-
1215
-    /**
1216
-     * Changes these inputs' display strategy to be EE_Hidden_Display_Strategy.
1217
-     * @param array $inputs_to_hide
1218
-     * @throws EE_Error
1219
-     */
1220
-    public function hide(array $inputs_to_hide = array())
1221
-    {
1222
-        foreach ($inputs_to_hide as $input_to_hide) {
1223
-            $input = $this->get_input($input_to_hide);
1224
-            $input->set_display_strategy(new EE_Hidden_Display_Strategy());
1225
-        }
1226
-    }
1227
-
1228
-
1229
-    /**
1230
-     * add_subsections
1231
-     * Adds the listed subsections to the form section.
1232
-     * If $subsection_name_to_target is provided,
1233
-     * then new subsections are added before or after that subsection,
1234
-     * otherwise to the start or end of the entire subsections array.
1235
-     *
1236
-     * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1237
-     *                                                          where keys are their names
1238
-     * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1239
-     *                                                          should be added before or after
1240
-     *                                                          IF $subsection_name_to_target is null,
1241
-     *                                                          then $new_subsections will be added to
1242
-     *                                                          the beginning or end of the entire subsections array
1243
-     * @param boolean                $add_before                whether to add $new_subsections, before or after
1244
-     *                                                          $subsection_name_to_target,
1245
-     *                                                          or if $subsection_name_to_target is null,
1246
-     *                                                          before or after entire subsections array
1247
-     * @return void
1248
-     * @throws EE_Error
1249
-     */
1250
-    public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1251
-    {
1252
-        foreach ($new_subsections as $subsection_name => $subsection) {
1253
-            if (! $subsection instanceof EE_Form_Section_Base) {
1254
-                EE_Error::add_error(
1255
-                    sprintf(
1256
-                        esc_html__(
1257
-                            "Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1258
-                            'event_espresso'
1259
-                        ),
1260
-                        get_class($subsection),
1261
-                        $subsection_name,
1262
-                        $this->name()
1263
-                    )
1264
-                );
1265
-                unset($new_subsections[ $subsection_name ]);
1266
-            }
1267
-        }
1268
-        $this->_subsections = EEH_Array::insert_into_array(
1269
-            $this->_subsections,
1270
-            $new_subsections,
1271
-            $subsection_name_to_target,
1272
-            $add_before
1273
-        );
1274
-        if ($this->_construction_finalized) {
1275
-            foreach ($this->_subsections as $name => $subsection) {
1276
-                $subsection->_construct_finalize($this, $name);
1277
-            }
1278
-        }
1279
-    }
1280
-
1281
-
1282
-    /**
1283
-     * @param string $subsection_name
1284
-     * @param bool   $recursive
1285
-     * @return bool
1286
-     */
1287
-    public function has_subsection($subsection_name, $recursive = false)
1288
-    {
1289
-        foreach ($this->_subsections as $name => $subsection) {
1290
-            if (
1291
-                $name === $subsection_name
1292
-                || (
1293
-                    $recursive
1294
-                    && $subsection instanceof EE_Form_Section_Proper
1295
-                    && $subsection->has_subsection($subsection_name, $recursive)
1296
-                )
1297
-            ) {
1298
-                return true;
1299
-            }
1300
-        }
1301
-        return false;
1302
-    }
1303
-
1304
-
1305
-
1306
-    /**
1307
-     * Just gets all validatable subsections to clean their sensitive data
1308
-     *
1309
-     * @throws EE_Error
1310
-     */
1311
-    public function clean_sensitive_data()
1312
-    {
1313
-        foreach ($this->get_validatable_subsections() as $subsection) {
1314
-            $subsection->clean_sensitive_data();
1315
-        }
1316
-    }
1317
-
1318
-
1319
-    /**
1320
-     * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1321
-     * @param string                           $form_submission_error_message
1322
-     * @param EE_Form_Section_Validatable $form_section unused
1323
-     * @throws EE_Error
1324
-     */
1325
-    public function set_submission_error_message(
1326
-        $form_submission_error_message = ''
1327
-    ) {
1328
-        $this->_form_submission_error_message = ! empty($form_submission_error_message)
1329
-            ? $form_submission_error_message
1330
-            : $this->getAllValidationErrorsString();
1331
-    }
1332
-
1333
-
1334
-    /**
1335
-     * Returns the cached error message. A default value is set for this during _validate(),
1336
-     * (called during receive_form_submission) but it can be explicitly set using
1337
-     * set_submission_error_message
1338
-     *
1339
-     * @return string
1340
-     */
1341
-    public function submission_error_message()
1342
-    {
1343
-        return $this->_form_submission_error_message;
1344
-    }
1345
-
1346
-
1347
-    /**
1348
-     * Sets a message to display if the data submitted to the form was valid.
1349
-     * @param string $form_submission_success_message
1350
-     */
1351
-    public function set_submission_success_message($form_submission_success_message = '')
1352
-    {
1353
-        $this->_form_submission_success_message = ! empty($form_submission_success_message)
1354
-            ? $form_submission_success_message
1355
-            : esc_html__('Form submitted successfully', 'event_espresso');
1356
-    }
1357
-
1358
-
1359
-    /**
1360
-     * Gets a message appropriate for display when the form is correctly submitted
1361
-     * @return string
1362
-     */
1363
-    public function submission_success_message()
1364
-    {
1365
-        return $this->_form_submission_success_message;
1366
-    }
1367
-
1368
-
1369
-    /**
1370
-     * Returns the prefix that should be used on child of this form section for
1371
-     * their html names. If this form section itself has a parent, prepends ITS
1372
-     * prefix onto this form section's prefix. Used primarily by
1373
-     * EE_Form_Input_Base::_set_default_html_name_if_empty
1374
-     *
1375
-     * @return string
1376
-     * @throws EE_Error
1377
-     */
1378
-    public function html_name_prefix()
1379
-    {
1380
-        if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1381
-            return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1382
-        }
1383
-        return $this->name();
1384
-    }
1385
-
1386
-
1387
-    /**
1388
-     * Gets the name, but first checks _construct_finalize has been called. If not,
1389
-     * calls it (assumes there is no parent and that we want the name to be whatever
1390
-     * was set, which is probably nothing, or the classname)
1391
-     *
1392
-     * @return string
1393
-     * @throws EE_Error
1394
-     */
1395
-    public function name()
1396
-    {
1397
-        $this->ensure_construct_finalized_called();
1398
-        return parent::name();
1399
-    }
1400
-
1401
-
1402
-    /**
1403
-     * @return EE_Form_Section_Proper
1404
-     * @throws EE_Error
1405
-     */
1406
-    public function parent_section()
1407
-    {
1408
-        $this->ensure_construct_finalized_called();
1409
-        return parent::parent_section();
1410
-    }
1411
-
1412
-
1413
-    /**
1414
-     * make sure construction finalized was called, otherwise children might not be ready
1415
-     *
1416
-     * @return void
1417
-     * @throws EE_Error
1418
-     */
1419
-    public function ensure_construct_finalized_called()
1420
-    {
1421
-        if (! $this->_construction_finalized) {
1422
-            $this->_construct_finalize($this->_parent_section, $this->_name);
1423
-        }
1424
-    }
1425
-
1426
-
1427
-    /**
1428
-     * Checks if any of this form section's inputs, or any of its children's inputs,
1429
-     * are in teh form data. If any are found, returns true. Else false
1430
-     *
1431
-     * @param array $req_data
1432
-     * @return boolean
1433
-     * @throws EE_Error
1434
-     */
1435
-    public function form_data_present_in($req_data = null)
1436
-    {
1437
-        $req_data = $this->getCachedRequest($req_data);
1438
-        foreach ($this->subsections() as $subsection) {
1439
-            if ($subsection instanceof EE_Form_Input_Base) {
1440
-                if ($subsection->form_data_present_in($req_data)) {
1441
-                    return true;
1442
-                }
1443
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
1444
-                if ($subsection->form_data_present_in($req_data)) {
1445
-                    return true;
1446
-                }
1447
-            }
1448
-        }
1449
-        return false;
1450
-    }
1451
-
1452
-
1453
-    /**
1454
-     * Gets validation errors for this form section and subsections
1455
-     * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1456
-     * gets the validation errors for ALL subsection
1457
-     *
1458
-     * @return EE_Validation_Error[]
1459
-     * @throws EE_Error
1460
-     */
1461
-    public function get_validation_errors_accumulated()
1462
-    {
1463
-        $validation_errors = $this->get_validation_errors();
1464
-        foreach ($this->get_validatable_subsections() as $subsection) {
1465
-            if ($subsection instanceof EE_Form_Section_Proper) {
1466
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1467
-            } else {
1468
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors();
1469
-            }
1470
-            if ($validation_errors_on_this_subsection) {
1471
-                $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1472
-            }
1473
-        }
1474
-        return $validation_errors;
1475
-    }
1476
-
1477
-    /**
1478
-     * Fetch validation errors from children and grandchildren and puts them in a single string.
1479
-     * This traverses the form section tree to generate this, but you probably want to instead use
1480
-     * get_form_submission_error_message() which is usually this message cached (or a custom validation error message)
1481
-     *
1482
-     * @return string
1483
-     * @since 4.9.59.p
1484
-     */
1485
-    protected function getAllValidationErrorsString()
1486
-    {
1487
-        $submission_error_messages = array();
1488
-        // bad, bad, bad registrant
1489
-        foreach ($this->get_validation_errors_accumulated() as $validation_error) {
1490
-            if ($validation_error instanceof EE_Validation_Error) {
1491
-                $form_section = $validation_error->get_form_section();
1492
-                if ($form_section instanceof EE_Form_Input_Base) {
1493
-                    $label = $validation_error->get_form_section()->html_label_text();
1494
-                } elseif ($form_section instanceof EE_Form_Section_Validatable) {
1495
-                    $label = $validation_error->get_form_section()->name();
1496
-                } else {
1497
-                    $label = esc_html__('Unknown', 'event_espresso');
1498
-                }
1499
-                $submission_error_messages[] = sprintf(
1500
-                    esc_html__('%s : %s', 'event_espresso'),
1501
-                    $label,
1502
-                    $validation_error->getMessage()
1503
-                );
1504
-            }
1505
-        }
1506
-        return implode('<br>', $submission_error_messages);
1507
-    }
1508
-
1509
-
1510
-    /**
1511
-     * This isn't just the name of an input, it's a path pointing to an input. The
1512
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
1513
-     * dot-dot-slash (../) means to ascend into the parent section.
1514
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1515
-     * which will be returned.
1516
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1517
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1518
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1519
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1520
-     * Etc
1521
-     *
1522
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1523
-     * @return EE_Form_Section_Base
1524
-     * @throws EE_Error
1525
-     */
1526
-    public function find_section_from_path($form_section_path)
1527
-    {
1528
-        // check if we can find the input from purely going straight up the tree
1529
-        $input = parent::find_section_from_path($form_section_path);
1530
-        if ($input instanceof EE_Form_Section_Base) {
1531
-            return $input;
1532
-        }
1533
-        $next_slash_pos = strpos($form_section_path, '/');
1534
-        if ($next_slash_pos !== false) {
1535
-            $child_section_name = substr($form_section_path, 0, $next_slash_pos);
1536
-            $subpath            = substr($form_section_path, $next_slash_pos + 1);
1537
-        } else {
1538
-            $child_section_name = $form_section_path;
1539
-            $subpath            = '';
1540
-        }
1541
-        $child_section = $this->get_subsection($child_section_name);
1542
-        if ($child_section instanceof EE_Form_Section_Base) {
1543
-            return $child_section->find_section_from_path($subpath);
1544
-        }
1545
-        return null;
1546
-    }
19
+	const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
20
+
21
+	/**
22
+	 * Subsections
23
+	 *
24
+	 * @var EE_Form_Section_Validatable[]
25
+	 */
26
+	protected $_subsections = array();
27
+
28
+	/**
29
+	 * Strategy for laying out the form
30
+	 *
31
+	 * @var EE_Form_Section_Layout_Base
32
+	 */
33
+	protected $_layout_strategy;
34
+
35
+	/**
36
+	 * Whether or not this form has received and validated a form submission yet
37
+	 *
38
+	 * @var boolean
39
+	 */
40
+	protected $_received_submission = false;
41
+
42
+	/**
43
+	 * message displayed to users upon successful form submission
44
+	 *
45
+	 * @var string
46
+	 */
47
+	protected $_form_submission_success_message = '';
48
+
49
+	/**
50
+	 * message displayed to users upon unsuccessful form submission
51
+	 *
52
+	 * @var string
53
+	 */
54
+	protected $_form_submission_error_message = '';
55
+
56
+	/**
57
+	 * @var array like post / request
58
+	 */
59
+	protected $cached_request_data;
60
+
61
+	/**
62
+	 * Stores whether this form (and its sub-sections) were found to be valid or not.
63
+	 * Starts off as null, but once the form is validated, it set to either true or false
64
+	 * @var boolean|null
65
+	 */
66
+	protected $is_valid;
67
+
68
+	/**
69
+	 * Stores all the data that will localized for form validation
70
+	 *
71
+	 * @var array
72
+	 */
73
+	protected static $_js_localization = array();
74
+
75
+	/**
76
+	 * whether or not the form's localized validation JS vars have been set
77
+	 *
78
+	 * @type boolean
79
+	 */
80
+	protected static $_scripts_localized = false;
81
+
82
+
83
+	/**
84
+	 * when constructing a proper form section, calls _construct_finalize on children
85
+	 * so that they know who their parent is, and what name they've been given.
86
+	 *
87
+	 * @param array[] $options_array   {
88
+	 * @type          $subsections     EE_Form_Section_Validatable[] where keys are the section's name
89
+	 * @type          $include         string[] numerically-indexed where values are section names to be included,
90
+	 *                                 and in that order. This is handy if you want
91
+	 *                                 the subsections to be ordered differently than the default, and if you override
92
+	 *                                 which fields are shown
93
+	 * @type          $exclude         string[] values are subsections to be excluded. This is handy if you want
94
+	 *                                 to remove certain default subsections (note: if you specify BOTH 'include' AND
95
+	 *                                 'exclude', the inclusions will be applied first, and the exclusions will exclude
96
+	 *                                 items from that list of inclusions)
97
+	 * @type          $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
98
+	 *                                 } @see EE_Form_Section_Validatable::__construct()
99
+	 * @throws EE_Error
100
+	 */
101
+	public function __construct($options_array = array())
102
+	{
103
+		$options_array = (array) apply_filters(
104
+			'FHEE__EE_Form_Section_Proper___construct__options_array',
105
+			$options_array,
106
+			$this
107
+		);
108
+		// call parent first, as it may be setting the name
109
+		parent::__construct($options_array);
110
+		// if they've included subsections in the constructor, add them now
111
+		if (isset($options_array['include'])) {
112
+			// we are going to make sure we ONLY have those subsections to include
113
+			// AND we are going to make sure they're in that specified order
114
+			$reordered_subsections = array();
115
+			foreach ($options_array['include'] as $input_name) {
116
+				if (isset($this->_subsections[ $input_name ])) {
117
+					$reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
118
+				}
119
+			}
120
+			$this->_subsections = $reordered_subsections;
121
+		}
122
+		if (isset($options_array['exclude'])) {
123
+			$exclude            = $options_array['exclude'];
124
+			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
125
+		}
126
+		if (isset($options_array['layout_strategy'])) {
127
+			$this->_layout_strategy = $options_array['layout_strategy'];
128
+		}
129
+		if (! $this->_layout_strategy) {
130
+			$this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
131
+		}
132
+		$this->_layout_strategy->_construct_finalize($this);
133
+		// ok so we are definitely going to want the forms JS,
134
+		// so enqueue it or remember to enqueue it during wp_enqueue_scripts
135
+		if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
136
+			// ok so they've constructed this object after when they should have.
137
+			// just enqueue the generic form scripts and initialize the form immediately in the JS
138
+			EE_Form_Section_Proper::wp_enqueue_scripts(true);
139
+		} else {
140
+			add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
141
+			add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
142
+		}
143
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
144
+		/**
145
+		 * Gives other plugins a chance to hook in before construct finalize is called.
146
+		 * The form probably doesn't yet have a parent form section.
147
+		 * Since 4.9.32, when this action was introduced, this is the best place to add a subsection onto a form,
148
+		 * assuming you don't care what the form section's name, HTML ID, or HTML name etc are.
149
+		 * Also see AHEE__EE_Form_Section_Proper___construct_finalize__end
150
+		 *
151
+		 * @since 4.9.32
152
+		 * @param EE_Form_Section_Proper $this          before __construct is done, but all of its logic,
153
+		 *                                              except maybe calling _construct_finalize has been done
154
+		 * @param array                  $options_array options passed into the constructor
155
+		 */
156
+		do_action(
157
+			'AHEE__EE_Form_Input_Base___construct__before_construct_finalize_called',
158
+			$this,
159
+			$options_array
160
+		);
161
+		if (isset($options_array['name'])) {
162
+			$this->_construct_finalize(null, $options_array['name']);
163
+		}
164
+	}
165
+
166
+
167
+	/**
168
+	 * Finishes construction given the parent form section and this form section's name
169
+	 *
170
+	 * @param EE_Form_Section_Proper $parent_form_section
171
+	 * @param string                 $name
172
+	 * @throws EE_Error
173
+	 */
174
+	public function _construct_finalize($parent_form_section, $name)
175
+	{
176
+		parent::_construct_finalize($parent_form_section, $name);
177
+		$this->_set_default_name_if_empty();
178
+		$this->_set_default_html_id_if_empty();
179
+		foreach ($this->_subsections as $subsection_name => $subsection) {
180
+			if ($subsection instanceof EE_Form_Section_Base) {
181
+				$subsection->_construct_finalize($this, $subsection_name);
182
+			} else {
183
+				throw new EE_Error(
184
+					sprintf(
185
+						esc_html__(
186
+							'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
187
+							'event_espresso'
188
+						),
189
+						$subsection_name,
190
+						get_class($this),
191
+						$subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
192
+					)
193
+				);
194
+			}
195
+		}
196
+		/**
197
+		 * Action performed just after form has been given a name (and HTML ID etc) and is fully constructed.
198
+		 * If you have code that should modify the form and needs it and its subsections to have a name, HTML ID
199
+		 * (or other attributes derived from the name like the HTML label id, etc), this is where it should be done.
200
+		 * This might only happen just before displaying the form, or just before it receives form submission data.
201
+		 * If you need to modify the form or its subsections before _construct_finalize is called on it (and we've
202
+		 * ensured it has a name, HTML IDs, etc
203
+		 *
204
+		 * @param EE_Form_Section_Proper      $this
205
+		 * @param EE_Form_Section_Proper|null $parent_form_section
206
+		 * @param string                      $name
207
+		 */
208
+		do_action(
209
+			'AHEE__EE_Form_Section_Proper___construct_finalize__end',
210
+			$this,
211
+			$parent_form_section,
212
+			$name
213
+		);
214
+	}
215
+
216
+
217
+	/**
218
+	 * Gets the layout strategy for this form section
219
+	 *
220
+	 * @return EE_Form_Section_Layout_Base
221
+	 */
222
+	public function get_layout_strategy()
223
+	{
224
+		return $this->_layout_strategy;
225
+	}
226
+
227
+
228
+	/**
229
+	 * Gets the HTML for a single input for this form section according
230
+	 * to the layout strategy
231
+	 *
232
+	 * @param EE_Form_Input_Base $input
233
+	 * @return string
234
+	 */
235
+	public function get_html_for_input($input)
236
+	{
237
+		return $this->_layout_strategy->layout_input($input);
238
+	}
239
+
240
+
241
+	/**
242
+	 * was_submitted - checks if form inputs are present in request data
243
+	 * Basically an alias for form_data_present_in() (which is used by both
244
+	 * proper form sections and form inputs)
245
+	 *
246
+	 * @param null $form_data
247
+	 * @return boolean
248
+	 * @throws EE_Error
249
+	 */
250
+	public function was_submitted($form_data = null)
251
+	{
252
+		return $this->form_data_present_in($form_data);
253
+	}
254
+
255
+	/**
256
+	 * Gets the cached request data; but if there is none, or $req_data was set with
257
+	 * something different, refresh the cache, and then return it
258
+	 * @param null $req_data
259
+	 * @return array
260
+	 */
261
+	protected function getCachedRequest($req_data = null)
262
+	{
263
+		if (
264
+			$this->cached_request_data === null
265
+			|| (
266
+				$req_data !== null
267
+				&& $req_data !== $this->cached_request_data
268
+			)
269
+		) {
270
+			$req_data = apply_filters(
271
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
272
+				$req_data,
273
+				$this
274
+			);
275
+			if ($req_data === null) {
276
+				/** @var RequestInterface $request */
277
+				$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
278
+				$req_data = $request->requestParams();
279
+			}
280
+			$req_data = apply_filters(
281
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
282
+				$req_data,
283
+				$this
284
+			);
285
+			$this->cached_request_data = (array) $req_data;
286
+		}
287
+		return $this->cached_request_data;
288
+	}
289
+
290
+
291
+	/**
292
+	 * After the form section is initially created, call this to sanitize the data in the submission
293
+	 * which relates to this form section, validate it, and set it as properties on the form.
294
+	 *
295
+	 * @param array|null $req_data should usually be post data (the default).
296
+	 *                             However, you CAN supply a different array.
297
+	 *                             Consider using set_defaults() instead however.
298
+	 *                             (If you rendered the form in the page using $form_x->get_html()
299
+	 *                             the inputs will have the correct name in the request data for this function
300
+	 *                             to find them and populate the form with them.
301
+	 *                             If you have a flat form (with only input subsections),
302
+	 *                             you can supply a flat array where keys
303
+	 *                             are the form input names and values are their values)
304
+	 * @param boolean    $validate whether or not to perform validation on this data. Default is,
305
+	 *                             of course, to validate that data, and set errors on the invalid values.
306
+	 *                             But if the data has already been validated
307
+	 *                             (eg you validated the data then stored it in the DB)
308
+	 *                             you may want to skip this step.
309
+	 * @throws InvalidArgumentException
310
+	 * @throws InvalidInterfaceException
311
+	 * @throws InvalidDataTypeException
312
+	 * @throws EE_Error
313
+	 */
314
+	public function receive_form_submission($req_data = null, $validate = true)
315
+	{
316
+		$req_data = $this->getCachedRequest($req_data);
317
+		$this->_normalize($req_data);
318
+		if ($validate) {
319
+			$this->_validate();
320
+			// if it's invalid, we're going to want to re-display so remember what they submitted
321
+			if (! $this->is_valid()) {
322
+				$this->store_submitted_form_data_in_session();
323
+			}
324
+		}
325
+		if ($this->submission_error_message() === '' && ! $this->is_valid()) {
326
+			$this->set_submission_error_message();
327
+		}
328
+		do_action(
329
+			'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
330
+			$req_data,
331
+			$this,
332
+			$validate
333
+		);
334
+	}
335
+
336
+
337
+	/**
338
+	 * caches the originally submitted input values in the session
339
+	 * so that they can be used to repopulate the form if it failed validation
340
+	 *
341
+	 * @return boolean whether or not the data was successfully stored in the session
342
+	 * @throws InvalidArgumentException
343
+	 * @throws InvalidInterfaceException
344
+	 * @throws InvalidDataTypeException
345
+	 * @throws EE_Error
346
+	 */
347
+	protected function store_submitted_form_data_in_session()
348
+	{
349
+		return EE_Registry::instance()->SSN->set_session_data(
350
+			array(
351
+				EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
352
+			)
353
+		);
354
+	}
355
+
356
+
357
+	/**
358
+	 * retrieves the originally submitted input values in the session
359
+	 * so that they can be used to repopulate the form if it failed validation
360
+	 *
361
+	 * @return array
362
+	 * @throws InvalidArgumentException
363
+	 * @throws InvalidInterfaceException
364
+	 * @throws InvalidDataTypeException
365
+	 */
366
+	protected function get_submitted_form_data_from_session()
367
+	{
368
+		$session = EE_Registry::instance()->SSN;
369
+		if ($session instanceof EE_Session) {
370
+			return $session->get_session_data(
371
+				EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
372
+			);
373
+		}
374
+		return array();
375
+	}
376
+
377
+
378
+	/**
379
+	 * flushed the originally submitted input values from the session
380
+	 *
381
+	 * @return boolean whether or not the data was successfully removed from the session
382
+	 * @throws InvalidArgumentException
383
+	 * @throws InvalidInterfaceException
384
+	 * @throws InvalidDataTypeException
385
+	 */
386
+	public static function flush_submitted_form_data_from_session()
387
+	{
388
+		return EE_Registry::instance()->SSN->reset_data(
389
+			array(EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
390
+		);
391
+	}
392
+
393
+
394
+	/**
395
+	 * Populates this form and its subsections with data from the session.
396
+	 * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
397
+	 * validation errors when displaying too)
398
+	 * Returns true if the form was populated from the session, false otherwise
399
+	 *
400
+	 * @return boolean
401
+	 * @throws InvalidArgumentException
402
+	 * @throws InvalidInterfaceException
403
+	 * @throws InvalidDataTypeException
404
+	 * @throws EE_Error
405
+	 */
406
+	public function populate_from_session()
407
+	{
408
+		$form_data_in_session = $this->get_submitted_form_data_from_session();
409
+		if (empty($form_data_in_session)) {
410
+			return false;
411
+		}
412
+		$this->receive_form_submission($form_data_in_session);
413
+		add_action('shutdown', array('EE_Form_Section_Proper', 'flush_submitted_form_data_from_session'));
414
+		if ($this->form_data_present_in($form_data_in_session)) {
415
+			return true;
416
+		}
417
+		return false;
418
+	}
419
+
420
+
421
+	/**
422
+	 * Populates the default data for the form, given an array where keys are
423
+	 * the input names, and values are their values (preferably normalized to be their
424
+	 * proper PHP types, not all strings... although that should be ok too).
425
+	 * Proper subsections are sub-arrays, the key being the subsection's name, and
426
+	 * the value being an array formatted in teh same way
427
+	 *
428
+	 * @param array $default_data
429
+	 * @throws EE_Error
430
+	 */
431
+	public function populate_defaults($default_data)
432
+	{
433
+		foreach ($this->subsections(false) as $subsection_name => $subsection) {
434
+			if (isset($default_data[ $subsection_name ])) {
435
+				if ($subsection instanceof EE_Form_Input_Base) {
436
+					$subsection->set_default($default_data[ $subsection_name ]);
437
+				} elseif ($subsection instanceof EE_Form_Section_Proper) {
438
+					$subsection->populate_defaults($default_data[ $subsection_name ]);
439
+				}
440
+			}
441
+		}
442
+	}
443
+
444
+
445
+	/**
446
+	 * returns true if subsection exists
447
+	 *
448
+	 * @param string $name
449
+	 * @return boolean
450
+	 */
451
+	public function subsection_exists($name)
452
+	{
453
+		return isset($this->_subsections[ $name ]) ? true : false;
454
+	}
455
+
456
+
457
+	/**
458
+	 * Gets the subsection specified by its name
459
+	 *
460
+	 * @param string  $name
461
+	 * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
462
+	 *                                                      so that the inputs will be properly configured.
463
+	 *                                                      However, some client code may be ok
464
+	 *                                                      with construction finalize being called later
465
+	 *                                                      (realizing that the subsections' html names
466
+	 *                                                      might not be set yet, etc.)
467
+	 * @return EE_Form_Section_Base
468
+	 * @throws EE_Error
469
+	 */
470
+	public function get_subsection($name, $require_construction_to_be_finalized = true)
471
+	{
472
+		if ($require_construction_to_be_finalized) {
473
+			$this->ensure_construct_finalized_called();
474
+		}
475
+		return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
476
+	}
477
+
478
+
479
+	/**
480
+	 * Gets all the validatable subsections of this form section
481
+	 *
482
+	 * @return EE_Form_Section_Validatable[]
483
+	 * @throws EE_Error
484
+	 */
485
+	public function get_validatable_subsections()
486
+	{
487
+		$validatable_subsections = array();
488
+		foreach ($this->subsections() as $name => $obj) {
489
+			if ($obj instanceof EE_Form_Section_Validatable) {
490
+				$validatable_subsections[ $name ] = $obj;
491
+			}
492
+		}
493
+		return $validatable_subsections;
494
+	}
495
+
496
+
497
+	/**
498
+	 * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
499
+	 * throw an EE_Error.
500
+	 *
501
+	 * @param string  $name
502
+	 * @param boolean $require_construction_to_be_finalized most client code should
503
+	 *                                                      leave this as TRUE so that the inputs will be properly
504
+	 *                                                      configured. However, some client code may be ok with
505
+	 *                                                      construction finalize being called later
506
+	 *                                                      (realizing that the subsections' html names might not be
507
+	 *                                                      set yet, etc.)
508
+	 * @return EE_Form_Input_Base
509
+	 * @throws EE_Error
510
+	 */
511
+	public function get_input($name, $require_construction_to_be_finalized = true)
512
+	{
513
+		$subsection = $this->get_subsection(
514
+			$name,
515
+			$require_construction_to_be_finalized
516
+		);
517
+		if (! $subsection instanceof EE_Form_Input_Base) {
518
+			throw new EE_Error(
519
+				sprintf(
520
+					esc_html__(
521
+						"Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
522
+						'event_espresso'
523
+					),
524
+					$name,
525
+					get_class($this),
526
+					$subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
527
+				)
528
+			);
529
+		}
530
+		return $subsection;
531
+	}
532
+
533
+
534
+	/**
535
+	 * Like get_input(), gets the proper subsection of the form given the name,
536
+	 * otherwise throws an EE_Error
537
+	 *
538
+	 * @param string  $name
539
+	 * @param boolean $require_construction_to_be_finalized most client code should
540
+	 *                                                      leave this as TRUE so that the inputs will be properly
541
+	 *                                                      configured. However, some client code may be ok with
542
+	 *                                                      construction finalize being called later
543
+	 *                                                      (realizing that the subsections' html names might not be
544
+	 *                                                      set yet, etc.)
545
+	 * @return EE_Form_Section_Proper
546
+	 * @throws EE_Error
547
+	 */
548
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
549
+	{
550
+		$subsection = $this->get_subsection(
551
+			$name,
552
+			$require_construction_to_be_finalized
553
+		);
554
+		if (! $subsection instanceof EE_Form_Section_Proper) {
555
+			throw new EE_Error(
556
+				sprintf(
557
+					esc_html__(
558
+						"Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'",
559
+						'event_espresso'
560
+					),
561
+					$name,
562
+					get_class($this)
563
+				)
564
+			);
565
+		}
566
+		return $subsection;
567
+	}
568
+
569
+
570
+	/**
571
+	 * Gets the value of the specified input. Should be called after receive_form_submission()
572
+	 * or populate_defaults() on the form, where the normalized value on the input is set.
573
+	 *
574
+	 * @param string $name
575
+	 * @return mixed depending on the input's type and its normalization strategy
576
+	 * @throws EE_Error
577
+	 */
578
+	public function get_input_value($name)
579
+	{
580
+		$input = $this->get_input($name);
581
+		return $input->normalized_value();
582
+	}
583
+
584
+
585
+	/**
586
+	 * Checks if this form section itself is valid, and then checks its subsections
587
+	 *
588
+	 * @throws EE_Error
589
+	 * @return boolean
590
+	 */
591
+	public function is_valid()
592
+	{
593
+		if ($this->is_valid === null) {
594
+			if (! $this->has_received_submission()) {
595
+				throw new EE_Error(
596
+					sprintf(
597
+						esc_html__(
598
+							'You cannot check if a form is valid before receiving the form submission using receive_form_submission',
599
+							'event_espresso'
600
+						)
601
+					)
602
+				);
603
+			}
604
+			if (! parent::is_valid()) {
605
+				$this->is_valid = false;
606
+			} else {
607
+				// ok so no general errors to this entire form section.
608
+				// so let's check the subsections, but only set errors if that hasn't been done yet
609
+				$this->is_valid = true;
610
+				foreach ($this->get_validatable_subsections() as $subsection) {
611
+					if (! $subsection->is_valid()) {
612
+						$this->is_valid = false;
613
+					}
614
+				}
615
+			}
616
+		}
617
+		return $this->is_valid;
618
+	}
619
+
620
+
621
+	/**
622
+	 * gets the default name of this form section if none is specified
623
+	 *
624
+	 * @return void
625
+	 */
626
+	protected function _set_default_name_if_empty()
627
+	{
628
+		if (! $this->_name) {
629
+			$classname    = get_class($this);
630
+			$default_name = str_replace('EE_', '', $classname);
631
+			$this->_name  = $default_name;
632
+		}
633
+	}
634
+
635
+
636
+	/**
637
+	 * Returns the HTML for the form, except for the form opening and closing tags
638
+	 * (as the form section doesn't know where you necessarily want to send the information to),
639
+	 * and except for a submit button. Enqueues JS and CSS; if called early enough we will
640
+	 * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
641
+	 * Not doing_it_wrong because theoretically this CAN be used properly,
642
+	 * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
643
+	 * any CSS.
644
+	 *
645
+	 * @throws InvalidArgumentException
646
+	 * @throws InvalidInterfaceException
647
+	 * @throws InvalidDataTypeException
648
+	 * @throws EE_Error
649
+	 */
650
+	public function get_html_and_js()
651
+	{
652
+		$this->enqueue_js();
653
+		return $this->get_html();
654
+	}
655
+
656
+
657
+	/**
658
+	 * returns HTML for displaying this form section. recursively calls display_section() on all subsections
659
+	 *
660
+	 * @param bool $display_previously_submitted_data
661
+	 * @return string
662
+	 * @throws InvalidArgumentException
663
+	 * @throws InvalidInterfaceException
664
+	 * @throws InvalidDataTypeException
665
+	 * @throws EE_Error
666
+	 * @throws EE_Error
667
+	 * @throws EE_Error
668
+	 */
669
+	public function get_html($display_previously_submitted_data = true)
670
+	{
671
+		$this->ensure_construct_finalized_called();
672
+		if ($display_previously_submitted_data) {
673
+			$this->populate_from_session();
674
+		}
675
+		return $this->_form_html_filter
676
+			? $this->_form_html_filter->filterHtml($this->_layout_strategy->layout_form(), $this)
677
+			: $this->_layout_strategy->layout_form();
678
+	}
679
+
680
+
681
+	/**
682
+	 * enqueues JS and CSS for the form.
683
+	 * It is preferred to call this before wp_enqueue_scripts so the
684
+	 * scripts and styles can be put in the header, but if called later
685
+	 * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
686
+	 * only be in the header; but in HTML5 its ok in the body.
687
+	 * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
688
+	 * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
689
+	 *
690
+	 * @return void
691
+	 * @throws EE_Error
692
+	 */
693
+	public function enqueue_js()
694
+	{
695
+		$this->_enqueue_and_localize_form_js();
696
+		foreach ($this->subsections() as $subsection) {
697
+			$subsection->enqueue_js();
698
+		}
699
+	}
700
+
701
+
702
+	/**
703
+	 * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
704
+	 * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
705
+	 * the wp_enqueue_scripts hook.
706
+	 * However, registering the form js and localizing it can happen when we
707
+	 * actually output the form (which is preferred, seeing how teh form's fields
708
+	 * could change until it's actually outputted)
709
+	 *
710
+	 * @param boolean $init_form_validation_automatically whether or not we want the form validation
711
+	 *                                                    to be triggered automatically or not
712
+	 * @return void
713
+	 */
714
+	public static function wp_enqueue_scripts($init_form_validation_automatically = true)
715
+	{
716
+		wp_register_script(
717
+			'ee_form_section_validation',
718
+			EE_GLOBAL_ASSETS_URL . 'scripts' . '/form_section_validation.js',
719
+			array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
720
+			EVENT_ESPRESSO_VERSION,
721
+			true
722
+		);
723
+		wp_localize_script(
724
+			'ee_form_section_validation',
725
+			'ee_form_section_validation_init',
726
+			array('init' => $init_form_validation_automatically ? '1' : '0')
727
+		);
728
+	}
729
+
730
+
731
+	/**
732
+	 * gets the variables used by form_section_validation.js.
733
+	 * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
734
+	 * but before the wordpress hook wp_loaded
735
+	 *
736
+	 * @throws EE_Error
737
+	 */
738
+	public function _enqueue_and_localize_form_js()
739
+	{
740
+		$this->ensure_construct_finalized_called();
741
+		// actually, we don't want to localize just yet. There may be other forms on the page.
742
+		// so we need to add our form section data to a static variable accessible by all form sections
743
+		// and localize it just before the footer
744
+		$this->localize_validation_rules();
745
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
746
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
747
+	}
748
+
749
+
750
+	/**
751
+	 * add our form section data to a static variable accessible by all form sections
752
+	 *
753
+	 * @param bool $return_for_subsection
754
+	 * @return void
755
+	 * @throws EE_Error
756
+	 */
757
+	public function localize_validation_rules($return_for_subsection = false)
758
+	{
759
+		// we only want to localize vars ONCE for the entire form,
760
+		// so if the form section doesn't have a parent, then it must be the top dog
761
+		if ($return_for_subsection || ! $this->parent_section()) {
762
+			EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
763
+				'form_section_id'  => $this->html_id(true),
764
+				'validation_rules' => $this->get_jquery_validation_rules(),
765
+				'other_data'       => $this->get_other_js_data(),
766
+				'errors'           => $this->subsection_validation_errors_by_html_name(),
767
+			);
768
+			EE_Form_Section_Proper::$_scripts_localized                                = true;
769
+		}
770
+	}
771
+
772
+
773
+	/**
774
+	 * Gets an array of extra data that will be useful for client-side javascript.
775
+	 * This is primarily data added by inputs and forms in addition to any
776
+	 * scripts they might enqueue
777
+	 *
778
+	 * @param array $form_other_js_data
779
+	 * @return array
780
+	 * @throws EE_Error
781
+	 */
782
+	public function get_other_js_data($form_other_js_data = array())
783
+	{
784
+		foreach ($this->subsections() as $subsection) {
785
+			$form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
786
+		}
787
+		return $form_other_js_data;
788
+	}
789
+
790
+
791
+	/**
792
+	 * Gets a flat array of inputs for this form section and its subsections.
793
+	 * Keys are their form names, and values are the inputs themselves
794
+	 *
795
+	 * @return EE_Form_Input_Base
796
+	 * @throws EE_Error
797
+	 */
798
+	public function inputs_in_subsections()
799
+	{
800
+		$inputs = array();
801
+		foreach ($this->subsections() as $subsection) {
802
+			if ($subsection instanceof EE_Form_Input_Base) {
803
+				$inputs[ $subsection->html_name() ] = $subsection;
804
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
805
+				$inputs += $subsection->inputs_in_subsections();
806
+			}
807
+		}
808
+		return $inputs;
809
+	}
810
+
811
+
812
+	/**
813
+	 * Gets a flat array of all the validation errors.
814
+	 * Keys are html names (because those should be unique)
815
+	 * and values are a string of all their validation errors
816
+	 *
817
+	 * @return string[]
818
+	 * @throws EE_Error
819
+	 */
820
+	public function subsection_validation_errors_by_html_name()
821
+	{
822
+		$inputs = $this->inputs();
823
+		$errors = array();
824
+		foreach ($inputs as $form_input) {
825
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
826
+				$errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
827
+			}
828
+		}
829
+		return $errors;
830
+	}
831
+
832
+
833
+	/**
834
+	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
835
+	 * Should be setup by each form during the _enqueues_and_localize_form_js
836
+	 *
837
+	 * @throws InvalidArgumentException
838
+	 * @throws InvalidInterfaceException
839
+	 * @throws InvalidDataTypeException
840
+	 */
841
+	public static function localize_script_for_all_forms()
842
+	{
843
+		// allow inputs and stuff to hook in their JS and stuff here
844
+		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
845
+		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
846
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
847
+			? EE_Registry::instance()->CFG->registration->email_validation_level
848
+			: 'wp_default';
849
+		EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
850
+		wp_enqueue_script('ee_form_section_validation');
851
+		wp_localize_script(
852
+			'ee_form_section_validation',
853
+			'ee_form_section_vars',
854
+			EE_Form_Section_Proper::$_js_localization
855
+		);
856
+	}
857
+
858
+
859
+	/**
860
+	 * ensure_scripts_localized
861
+	 *
862
+	 * @throws EE_Error
863
+	 */
864
+	public function ensure_scripts_localized()
865
+	{
866
+		if (! EE_Form_Section_Proper::$_scripts_localized) {
867
+			$this->_enqueue_and_localize_form_js();
868
+		}
869
+	}
870
+
871
+
872
+	/**
873
+	 * Gets the hard-coded validation error messages to be used in the JS. The convention
874
+	 * is that the key here should be the same as the custom validation rule put in the JS file
875
+	 *
876
+	 * @return array keys are custom validation rules, and values are internationalized strings
877
+	 */
878
+	private static function _get_localized_error_messages()
879
+	{
880
+		return array(
881
+			'validUrl' => wp_strip_all_tags(__('This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg', 'event_espresso')),
882
+			'regex'    => wp_strip_all_tags(__('Please check your input', 'event_espresso'))
883
+		);
884
+	}
885
+
886
+
887
+	/**
888
+	 * @return array
889
+	 */
890
+	public static function js_localization()
891
+	{
892
+		return self::$_js_localization;
893
+	}
894
+
895
+
896
+	/**
897
+	 * @return void
898
+	 */
899
+	public static function reset_js_localization()
900
+	{
901
+		self::$_js_localization = array();
902
+	}
903
+
904
+
905
+	/**
906
+	 * Gets the JS to put inside the jquery validation rules for subsection of this form section.
907
+	 * See parent function for more...
908
+	 *
909
+	 * @return array
910
+	 * @throws EE_Error
911
+	 */
912
+	public function get_jquery_validation_rules()
913
+	{
914
+		$jquery_validation_rules = array();
915
+		foreach ($this->get_validatable_subsections() as $subsection) {
916
+			$jquery_validation_rules = array_merge(
917
+				$jquery_validation_rules,
918
+				$subsection->get_jquery_validation_rules()
919
+			);
920
+		}
921
+		return $jquery_validation_rules;
922
+	}
923
+
924
+
925
+	/**
926
+	 * Sanitizes all the data and sets the sanitized value of each field
927
+	 *
928
+	 * @param array $req_data
929
+	 * @return void
930
+	 * @throws EE_Error
931
+	 */
932
+	protected function _normalize($req_data)
933
+	{
934
+		$this->_received_submission = true;
935
+		$this->_validation_errors   = array();
936
+		foreach ($this->get_validatable_subsections() as $subsection) {
937
+			try {
938
+				$subsection->_normalize($req_data);
939
+			} catch (EE_Validation_Error $e) {
940
+				$subsection->add_validation_error($e);
941
+			}
942
+		}
943
+	}
944
+
945
+
946
+	/**
947
+	 * Performs validation on this form section and its subsections.
948
+	 * For each subsection,
949
+	 * calls _validate_{subsection_name} on THIS form (if the function exists)
950
+	 * and passes it the subsection, then calls _validate on that subsection.
951
+	 * If you need to perform validation on the form as a whole (considering multiple)
952
+	 * you would be best to override this _validate method,
953
+	 * calling parent::_validate() first.
954
+	 *
955
+	 * @throws EE_Error
956
+	 */
957
+	protected function _validate()
958
+	{
959
+		// reset the cache of whether this form is valid or not- we're re-validating it now
960
+		$this->is_valid = null;
961
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
962
+			if (method_exists($this, '_validate_' . $subsection_name)) {
963
+				call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
964
+			}
965
+			$subsection->_validate();
966
+		}
967
+	}
968
+
969
+
970
+	/**
971
+	 * Gets all the validated inputs for the form section
972
+	 *
973
+	 * @return array
974
+	 * @throws EE_Error
975
+	 */
976
+	public function valid_data()
977
+	{
978
+		$inputs = array();
979
+		foreach ($this->subsections() as $subsection_name => $subsection) {
980
+			if ($subsection instanceof EE_Form_Section_Proper) {
981
+				$inputs[ $subsection_name ] = $subsection->valid_data();
982
+			} elseif ($subsection instanceof EE_Form_Input_Base) {
983
+				$inputs[ $subsection_name ] = $subsection->normalized_value();
984
+			}
985
+		}
986
+		return $inputs;
987
+	}
988
+
989
+
990
+	/**
991
+	 * Gets all the inputs on this form section
992
+	 *
993
+	 * @return EE_Form_Input_Base[]
994
+	 * @throws EE_Error
995
+	 */
996
+	public function inputs()
997
+	{
998
+		$inputs = array();
999
+		foreach ($this->subsections() as $subsection_name => $subsection) {
1000
+			if ($subsection instanceof EE_Form_Input_Base) {
1001
+				$inputs[ $subsection_name ] = $subsection;
1002
+			}
1003
+		}
1004
+		return $inputs;
1005
+	}
1006
+
1007
+
1008
+	/**
1009
+	 * Gets all the subsections which are a proper form
1010
+	 *
1011
+	 * @return EE_Form_Section_Proper[]
1012
+	 * @throws EE_Error
1013
+	 */
1014
+	public function subforms()
1015
+	{
1016
+		$form_sections = array();
1017
+		foreach ($this->subsections() as $name => $obj) {
1018
+			if ($obj instanceof EE_Form_Section_Proper) {
1019
+				$form_sections[ $name ] = $obj;
1020
+			}
1021
+		}
1022
+		return $form_sections;
1023
+	}
1024
+
1025
+
1026
+	/**
1027
+	 * Gets all the subsections (inputs, proper subsections, or html-only sections).
1028
+	 * Consider using inputs() or subforms()
1029
+	 * if you only want form inputs or proper form sections.
1030
+	 *
1031
+	 * @param boolean $require_construction_to_be_finalized most client code should
1032
+	 *                                                      leave this as TRUE so that the inputs will be properly
1033
+	 *                                                      configured. However, some client code may be ok with
1034
+	 *                                                      construction finalize being called later
1035
+	 *                                                      (realizing that the subsections' html names might not be
1036
+	 *                                                      set yet, etc.)
1037
+	 * @return EE_Form_Section_Proper[]
1038
+	 * @throws EE_Error
1039
+	 */
1040
+	public function subsections($require_construction_to_be_finalized = true)
1041
+	{
1042
+		if ($require_construction_to_be_finalized) {
1043
+			$this->ensure_construct_finalized_called();
1044
+		}
1045
+		return $this->_subsections;
1046
+	}
1047
+
1048
+
1049
+	/**
1050
+	 * Returns whether this form has any subforms or inputs
1051
+	 * @return bool
1052
+	 */
1053
+	public function hasSubsections()
1054
+	{
1055
+		return ! empty($this->_subsections);
1056
+	}
1057
+
1058
+
1059
+	/**
1060
+	 * Returns a simple array where keys are input names, and values are their normalized
1061
+	 * values. (Similar to calling get_input_value on inputs)
1062
+	 *
1063
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1064
+	 *                                        or just this forms' direct children inputs
1065
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1066
+	 *                                        or allow multidimensional array
1067
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
1068
+	 *                                        with array keys being input names
1069
+	 *                                        (regardless of whether they are from a subsection or not),
1070
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1071
+	 *                                        where keys are always subsection names and values are either
1072
+	 *                                        the input's normalized value, or an array like the top-level array
1073
+	 * @throws EE_Error
1074
+	 */
1075
+	public function input_values($include_subform_inputs = false, $flatten = false)
1076
+	{
1077
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
1083
+	 * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
1084
+	 * is not necessarily the value we want to display to users. This creates an array
1085
+	 * where keys are the input names, and values are their display values
1086
+	 *
1087
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1088
+	 *                                        or just this forms' direct children inputs
1089
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1090
+	 *                                        or allow multidimensional array
1091
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
1092
+	 *                                        with array keys being input names
1093
+	 *                                        (regardless of whether they are from a subsection or not),
1094
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1095
+	 *                                        where keys are always subsection names and values are either
1096
+	 *                                        the input's normalized value, or an array like the top-level array
1097
+	 * @throws EE_Error
1098
+	 */
1099
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false)
1100
+	{
1101
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
1102
+	}
1103
+
1104
+
1105
+	/**
1106
+	 * Gets the input values from the form
1107
+	 *
1108
+	 * @param boolean $pretty                 Whether to retrieve the pretty value,
1109
+	 *                                        or just the normalized value
1110
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1111
+	 *                                        or just this forms' direct children inputs
1112
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1113
+	 *                                        or allow multidimensional array
1114
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
1115
+	 *                                        input names (regardless of whether they are from a subsection or not),
1116
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1117
+	 *                                        where keys are always subsection names and values are either
1118
+	 *                                        the input's normalized value, or an array like the top-level array
1119
+	 * @throws EE_Error
1120
+	 */
1121
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
1122
+	{
1123
+		$input_values = array();
1124
+		foreach ($this->subsections() as $subsection_name => $subsection) {
1125
+			if ($subsection instanceof EE_Form_Input_Base) {
1126
+				$input_values[ $subsection_name ] = $pretty
1127
+					? $subsection->pretty_value()
1128
+					: $subsection->normalized_value();
1129
+			} elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1130
+				$subform_input_values = $subsection->_input_values(
1131
+					$pretty,
1132
+					$include_subform_inputs,
1133
+					$flatten
1134
+				);
1135
+				if ($flatten) {
1136
+					$input_values = array_merge($input_values, $subform_input_values);
1137
+				} else {
1138
+					$input_values[ $subsection_name ] = $subform_input_values;
1139
+				}
1140
+			}
1141
+		}
1142
+		return $input_values;
1143
+	}
1144
+
1145
+
1146
+	/**
1147
+	 * Gets the originally submitted input values from the form
1148
+	 *
1149
+	 * @param boolean $include_subforms  Whether to include inputs from subforms,
1150
+	 *                                   or just this forms' direct children inputs
1151
+	 * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1152
+	 *                                   with array keys being input names
1153
+	 *                                   (regardless of whether they are from a subsection or not),
1154
+	 *                                   and if $flatten is FALSE it can be a multidimensional array
1155
+	 *                                   where keys are always subsection names and values are either
1156
+	 *                                   the input's normalized value, or an array like the top-level array
1157
+	 * @throws EE_Error
1158
+	 */
1159
+	public function submitted_values($include_subforms = false)
1160
+	{
1161
+		$submitted_values = array();
1162
+		foreach ($this->subsections() as $subsection) {
1163
+			if ($subsection instanceof EE_Form_Input_Base) {
1164
+				// is this input part of an array of inputs?
1165
+				if (strpos($subsection->html_name(), '[') !== false) {
1166
+					$full_input_name  = EEH_Array::convert_array_values_to_keys(
1167
+						explode(
1168
+							'[',
1169
+							str_replace(']', '', $subsection->html_name())
1170
+						),
1171
+						$subsection->raw_value()
1172
+					);
1173
+					$submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1174
+				} else {
1175
+					$submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1176
+				}
1177
+			} elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1178
+				$subform_input_values = $subsection->submitted_values($include_subforms);
1179
+				$submitted_values     = array_replace_recursive($submitted_values, $subform_input_values);
1180
+			}
1181
+		}
1182
+		return $submitted_values;
1183
+	}
1184
+
1185
+
1186
+	/**
1187
+	 * Indicates whether or not this form has received a submission yet
1188
+	 * (ie, had receive_form_submission called on it yet)
1189
+	 *
1190
+	 * @return boolean
1191
+	 * @throws EE_Error
1192
+	 */
1193
+	public function has_received_submission()
1194
+	{
1195
+		$this->ensure_construct_finalized_called();
1196
+		return $this->_received_submission;
1197
+	}
1198
+
1199
+
1200
+	/**
1201
+	 * Equivalent to passing 'exclude' in the constructor's options array.
1202
+	 * Removes the listed inputs from the form
1203
+	 *
1204
+	 * @param array $inputs_to_exclude values are the input names
1205
+	 * @return void
1206
+	 */
1207
+	public function exclude(array $inputs_to_exclude = array())
1208
+	{
1209
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
1210
+			unset($this->_subsections[ $input_to_exclude_name ]);
1211
+		}
1212
+	}
1213
+
1214
+
1215
+	/**
1216
+	 * Changes these inputs' display strategy to be EE_Hidden_Display_Strategy.
1217
+	 * @param array $inputs_to_hide
1218
+	 * @throws EE_Error
1219
+	 */
1220
+	public function hide(array $inputs_to_hide = array())
1221
+	{
1222
+		foreach ($inputs_to_hide as $input_to_hide) {
1223
+			$input = $this->get_input($input_to_hide);
1224
+			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
1225
+		}
1226
+	}
1227
+
1228
+
1229
+	/**
1230
+	 * add_subsections
1231
+	 * Adds the listed subsections to the form section.
1232
+	 * If $subsection_name_to_target is provided,
1233
+	 * then new subsections are added before or after that subsection,
1234
+	 * otherwise to the start or end of the entire subsections array.
1235
+	 *
1236
+	 * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1237
+	 *                                                          where keys are their names
1238
+	 * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1239
+	 *                                                          should be added before or after
1240
+	 *                                                          IF $subsection_name_to_target is null,
1241
+	 *                                                          then $new_subsections will be added to
1242
+	 *                                                          the beginning or end of the entire subsections array
1243
+	 * @param boolean                $add_before                whether to add $new_subsections, before or after
1244
+	 *                                                          $subsection_name_to_target,
1245
+	 *                                                          or if $subsection_name_to_target is null,
1246
+	 *                                                          before or after entire subsections array
1247
+	 * @return void
1248
+	 * @throws EE_Error
1249
+	 */
1250
+	public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1251
+	{
1252
+		foreach ($new_subsections as $subsection_name => $subsection) {
1253
+			if (! $subsection instanceof EE_Form_Section_Base) {
1254
+				EE_Error::add_error(
1255
+					sprintf(
1256
+						esc_html__(
1257
+							"Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1258
+							'event_espresso'
1259
+						),
1260
+						get_class($subsection),
1261
+						$subsection_name,
1262
+						$this->name()
1263
+					)
1264
+				);
1265
+				unset($new_subsections[ $subsection_name ]);
1266
+			}
1267
+		}
1268
+		$this->_subsections = EEH_Array::insert_into_array(
1269
+			$this->_subsections,
1270
+			$new_subsections,
1271
+			$subsection_name_to_target,
1272
+			$add_before
1273
+		);
1274
+		if ($this->_construction_finalized) {
1275
+			foreach ($this->_subsections as $name => $subsection) {
1276
+				$subsection->_construct_finalize($this, $name);
1277
+			}
1278
+		}
1279
+	}
1280
+
1281
+
1282
+	/**
1283
+	 * @param string $subsection_name
1284
+	 * @param bool   $recursive
1285
+	 * @return bool
1286
+	 */
1287
+	public function has_subsection($subsection_name, $recursive = false)
1288
+	{
1289
+		foreach ($this->_subsections as $name => $subsection) {
1290
+			if (
1291
+				$name === $subsection_name
1292
+				|| (
1293
+					$recursive
1294
+					&& $subsection instanceof EE_Form_Section_Proper
1295
+					&& $subsection->has_subsection($subsection_name, $recursive)
1296
+				)
1297
+			) {
1298
+				return true;
1299
+			}
1300
+		}
1301
+		return false;
1302
+	}
1303
+
1304
+
1305
+
1306
+	/**
1307
+	 * Just gets all validatable subsections to clean their sensitive data
1308
+	 *
1309
+	 * @throws EE_Error
1310
+	 */
1311
+	public function clean_sensitive_data()
1312
+	{
1313
+		foreach ($this->get_validatable_subsections() as $subsection) {
1314
+			$subsection->clean_sensitive_data();
1315
+		}
1316
+	}
1317
+
1318
+
1319
+	/**
1320
+	 * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1321
+	 * @param string                           $form_submission_error_message
1322
+	 * @param EE_Form_Section_Validatable $form_section unused
1323
+	 * @throws EE_Error
1324
+	 */
1325
+	public function set_submission_error_message(
1326
+		$form_submission_error_message = ''
1327
+	) {
1328
+		$this->_form_submission_error_message = ! empty($form_submission_error_message)
1329
+			? $form_submission_error_message
1330
+			: $this->getAllValidationErrorsString();
1331
+	}
1332
+
1333
+
1334
+	/**
1335
+	 * Returns the cached error message. A default value is set for this during _validate(),
1336
+	 * (called during receive_form_submission) but it can be explicitly set using
1337
+	 * set_submission_error_message
1338
+	 *
1339
+	 * @return string
1340
+	 */
1341
+	public function submission_error_message()
1342
+	{
1343
+		return $this->_form_submission_error_message;
1344
+	}
1345
+
1346
+
1347
+	/**
1348
+	 * Sets a message to display if the data submitted to the form was valid.
1349
+	 * @param string $form_submission_success_message
1350
+	 */
1351
+	public function set_submission_success_message($form_submission_success_message = '')
1352
+	{
1353
+		$this->_form_submission_success_message = ! empty($form_submission_success_message)
1354
+			? $form_submission_success_message
1355
+			: esc_html__('Form submitted successfully', 'event_espresso');
1356
+	}
1357
+
1358
+
1359
+	/**
1360
+	 * Gets a message appropriate for display when the form is correctly submitted
1361
+	 * @return string
1362
+	 */
1363
+	public function submission_success_message()
1364
+	{
1365
+		return $this->_form_submission_success_message;
1366
+	}
1367
+
1368
+
1369
+	/**
1370
+	 * Returns the prefix that should be used on child of this form section for
1371
+	 * their html names. If this form section itself has a parent, prepends ITS
1372
+	 * prefix onto this form section's prefix. Used primarily by
1373
+	 * EE_Form_Input_Base::_set_default_html_name_if_empty
1374
+	 *
1375
+	 * @return string
1376
+	 * @throws EE_Error
1377
+	 */
1378
+	public function html_name_prefix()
1379
+	{
1380
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1381
+			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1382
+		}
1383
+		return $this->name();
1384
+	}
1385
+
1386
+
1387
+	/**
1388
+	 * Gets the name, but first checks _construct_finalize has been called. If not,
1389
+	 * calls it (assumes there is no parent and that we want the name to be whatever
1390
+	 * was set, which is probably nothing, or the classname)
1391
+	 *
1392
+	 * @return string
1393
+	 * @throws EE_Error
1394
+	 */
1395
+	public function name()
1396
+	{
1397
+		$this->ensure_construct_finalized_called();
1398
+		return parent::name();
1399
+	}
1400
+
1401
+
1402
+	/**
1403
+	 * @return EE_Form_Section_Proper
1404
+	 * @throws EE_Error
1405
+	 */
1406
+	public function parent_section()
1407
+	{
1408
+		$this->ensure_construct_finalized_called();
1409
+		return parent::parent_section();
1410
+	}
1411
+
1412
+
1413
+	/**
1414
+	 * make sure construction finalized was called, otherwise children might not be ready
1415
+	 *
1416
+	 * @return void
1417
+	 * @throws EE_Error
1418
+	 */
1419
+	public function ensure_construct_finalized_called()
1420
+	{
1421
+		if (! $this->_construction_finalized) {
1422
+			$this->_construct_finalize($this->_parent_section, $this->_name);
1423
+		}
1424
+	}
1425
+
1426
+
1427
+	/**
1428
+	 * Checks if any of this form section's inputs, or any of its children's inputs,
1429
+	 * are in teh form data. If any are found, returns true. Else false
1430
+	 *
1431
+	 * @param array $req_data
1432
+	 * @return boolean
1433
+	 * @throws EE_Error
1434
+	 */
1435
+	public function form_data_present_in($req_data = null)
1436
+	{
1437
+		$req_data = $this->getCachedRequest($req_data);
1438
+		foreach ($this->subsections() as $subsection) {
1439
+			if ($subsection instanceof EE_Form_Input_Base) {
1440
+				if ($subsection->form_data_present_in($req_data)) {
1441
+					return true;
1442
+				}
1443
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
1444
+				if ($subsection->form_data_present_in($req_data)) {
1445
+					return true;
1446
+				}
1447
+			}
1448
+		}
1449
+		return false;
1450
+	}
1451
+
1452
+
1453
+	/**
1454
+	 * Gets validation errors for this form section and subsections
1455
+	 * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1456
+	 * gets the validation errors for ALL subsection
1457
+	 *
1458
+	 * @return EE_Validation_Error[]
1459
+	 * @throws EE_Error
1460
+	 */
1461
+	public function get_validation_errors_accumulated()
1462
+	{
1463
+		$validation_errors = $this->get_validation_errors();
1464
+		foreach ($this->get_validatable_subsections() as $subsection) {
1465
+			if ($subsection instanceof EE_Form_Section_Proper) {
1466
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1467
+			} else {
1468
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
1469
+			}
1470
+			if ($validation_errors_on_this_subsection) {
1471
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1472
+			}
1473
+		}
1474
+		return $validation_errors;
1475
+	}
1476
+
1477
+	/**
1478
+	 * Fetch validation errors from children and grandchildren and puts them in a single string.
1479
+	 * This traverses the form section tree to generate this, but you probably want to instead use
1480
+	 * get_form_submission_error_message() which is usually this message cached (or a custom validation error message)
1481
+	 *
1482
+	 * @return string
1483
+	 * @since 4.9.59.p
1484
+	 */
1485
+	protected function getAllValidationErrorsString()
1486
+	{
1487
+		$submission_error_messages = array();
1488
+		// bad, bad, bad registrant
1489
+		foreach ($this->get_validation_errors_accumulated() as $validation_error) {
1490
+			if ($validation_error instanceof EE_Validation_Error) {
1491
+				$form_section = $validation_error->get_form_section();
1492
+				if ($form_section instanceof EE_Form_Input_Base) {
1493
+					$label = $validation_error->get_form_section()->html_label_text();
1494
+				} elseif ($form_section instanceof EE_Form_Section_Validatable) {
1495
+					$label = $validation_error->get_form_section()->name();
1496
+				} else {
1497
+					$label = esc_html__('Unknown', 'event_espresso');
1498
+				}
1499
+				$submission_error_messages[] = sprintf(
1500
+					esc_html__('%s : %s', 'event_espresso'),
1501
+					$label,
1502
+					$validation_error->getMessage()
1503
+				);
1504
+			}
1505
+		}
1506
+		return implode('<br>', $submission_error_messages);
1507
+	}
1508
+
1509
+
1510
+	/**
1511
+	 * This isn't just the name of an input, it's a path pointing to an input. The
1512
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
1513
+	 * dot-dot-slash (../) means to ascend into the parent section.
1514
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1515
+	 * which will be returned.
1516
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1517
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1518
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1519
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1520
+	 * Etc
1521
+	 *
1522
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1523
+	 * @return EE_Form_Section_Base
1524
+	 * @throws EE_Error
1525
+	 */
1526
+	public function find_section_from_path($form_section_path)
1527
+	{
1528
+		// check if we can find the input from purely going straight up the tree
1529
+		$input = parent::find_section_from_path($form_section_path);
1530
+		if ($input instanceof EE_Form_Section_Base) {
1531
+			return $input;
1532
+		}
1533
+		$next_slash_pos = strpos($form_section_path, '/');
1534
+		if ($next_slash_pos !== false) {
1535
+			$child_section_name = substr($form_section_path, 0, $next_slash_pos);
1536
+			$subpath            = substr($form_section_path, $next_slash_pos + 1);
1537
+		} else {
1538
+			$child_section_name = $form_section_path;
1539
+			$subpath            = '';
1540
+		}
1541
+		$child_section = $this->get_subsection($child_section_name);
1542
+		if ($child_section instanceof EE_Form_Section_Base) {
1543
+			return $child_section->find_section_from_path($subpath);
1544
+		}
1545
+		return null;
1546
+	}
1547 1547
 }
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
@@ -29,173 +29,173 @@
 block discarded – undo
29 29
 class EED_Venue_Single extends EED_Module
30 30
 {
31 31
 
32
-    /**
33
-     * @return EED_Venue_Single
34
-     */
35
-    public static function instance()
36
-    {
37
-        return parent::get_instance(__CLASS__);
38
-    }
39
-
40
-
41
-    /**
42
-     * set_hooks - for hooking into EE Core, other modules, etc
43
-     *
44
-     * @return void
45
-     * @throws InvalidArgumentException
46
-     * @throws InvalidDataTypeException
47
-     * @throws InvalidInterfaceException
48
-     */
49
-    public static function set_hooks()
50
-    {
51
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
-        );
55
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
56
-        EE_Config::register_route(
57
-            $custom_post_types['espresso_venues']['singular_slug'],
58
-            'Venue_Single',
59
-            'run'
60
-        );
61
-    }
62
-
63
-    /**
64
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
-     *
66
-     * @access    public
67
-     * @return    void
68
-     */
69
-    public static function set_hooks_admin()
70
-    {
71
-    }
72
-
73
-
74
-    /**
75
-     * run - initial module setup
76
-     *
77
-     * @access    public
78
-     * @param \WP $WP
79
-     */
80
-    public function run($WP)
81
-    {
82
-        // check what template is loaded
83
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
84
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
-    }
86
-
87
-
88
-    /**
89
-     * template_include
90
-     *
91
-     * @access public
92
-     * @param  string $template
93
-     * @return string
94
-     */
95
-    public function template_include($template)
96
-    {
97
-        // not a custom template?
98
-        if (
99
-            EE_Registry::instance()
100
-                       ->load_core('Front_Controller', array(), false, true)
101
-                       ->get_selected_template() != 'single-espresso_venues.php'
102
-        ) {
103
-            EEH_Template::load_espresso_theme_functions();
104
-            // then add extra event data via hooks
105
-            add_filter('the_title', array($this, 'the_title'), 100, 1);
106
-            add_filter('the_content', array($this, 'venue_details'), 100);
107
-            // don't display entry meta because the existing theme will take car of that
108
-            add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
109
-        }
110
-        return $template;
111
-    }
112
-
113
-
114
-    /**
115
-     * the_title
116
-     *
117
-     * @access public
118
-     * @param  string $title
119
-     * @return string
120
-     */
121
-    public function the_title($title = '')
122
-    {
123
-        return $title;
124
-    }
125
-
126
-
127
-    /**
128
-     *    venue_details
129
-     *
130
-     * @access public
131
-     * @param  string $content
132
-     * @return string
133
-     */
134
-    public function venue_details($content)
135
-    {
136
-        global $post;
137
-        if (
138
-            $post->post_type == 'espresso_venues'
139
-            && ! post_password_required()
140
-        ) {
141
-            // since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
142
-            // it uses the_content() for displaying the $post->post_content
143
-            // so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
144
-            // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
145
-            remove_filter('the_content', array($this, 'venue_details'), 100);
146
-            // add filters we want
147
-            add_filter('the_content', array($this, 'venue_location'), 110);
148
-            // now load our template
149
-            $template = EEH_Template::locate_template('content-espresso_venues-details.php');
150
-            // remove other filters we added so they won't get applied to the next post
151
-            remove_filter('the_content', array($this, 'venue_location'), 110);
152
-        }
153
-        // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
154
-        return ! empty($template) ? $template : $content;
155
-    }
156
-
157
-
158
-    /**
159
-     * venue_location
160
-     *
161
-     * @access public
162
-     * @param  string $content
163
-     * @return string
164
-     */
165
-    public function venue_location($content)
166
-    {
167
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
168
-    }
169
-
170
-
171
-    /**
172
-     *    wp_enqueue_scripts
173
-     *
174
-     * @access public
175
-     * @return void
176
-     */
177
-    public function wp_enqueue_scripts()
178
-    {
179
-        // get some style
180
-        if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
181
-            // first check theme folder
182
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
183
-                wp_register_style(
184
-                    $this->theme,
185
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
186
-                    array('dashicons', 'espresso_default')
187
-                );
188
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
189
-                wp_register_style(
190
-                    $this->theme,
191
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
192
-                    array('dashicons', 'espresso_default')
193
-                );
194
-            }
195
-            wp_enqueue_style($this->theme);
196
-            if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
197
-                add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
198
-            }
199
-        }
200
-    }
32
+	/**
33
+	 * @return EED_Venue_Single
34
+	 */
35
+	public static function instance()
36
+	{
37
+		return parent::get_instance(__CLASS__);
38
+	}
39
+
40
+
41
+	/**
42
+	 * set_hooks - for hooking into EE Core, other modules, etc
43
+	 *
44
+	 * @return void
45
+	 * @throws InvalidArgumentException
46
+	 * @throws InvalidDataTypeException
47
+	 * @throws InvalidInterfaceException
48
+	 */
49
+	public static function set_hooks()
50
+	{
51
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
+		);
55
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
56
+		EE_Config::register_route(
57
+			$custom_post_types['espresso_venues']['singular_slug'],
58
+			'Venue_Single',
59
+			'run'
60
+		);
61
+	}
62
+
63
+	/**
64
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
+	 *
66
+	 * @access    public
67
+	 * @return    void
68
+	 */
69
+	public static function set_hooks_admin()
70
+	{
71
+	}
72
+
73
+
74
+	/**
75
+	 * run - initial module setup
76
+	 *
77
+	 * @access    public
78
+	 * @param \WP $WP
79
+	 */
80
+	public function run($WP)
81
+	{
82
+		// check what template is loaded
83
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
84
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
+	}
86
+
87
+
88
+	/**
89
+	 * template_include
90
+	 *
91
+	 * @access public
92
+	 * @param  string $template
93
+	 * @return string
94
+	 */
95
+	public function template_include($template)
96
+	{
97
+		// not a custom template?
98
+		if (
99
+			EE_Registry::instance()
100
+					   ->load_core('Front_Controller', array(), false, true)
101
+					   ->get_selected_template() != 'single-espresso_venues.php'
102
+		) {
103
+			EEH_Template::load_espresso_theme_functions();
104
+			// then add extra event data via hooks
105
+			add_filter('the_title', array($this, 'the_title'), 100, 1);
106
+			add_filter('the_content', array($this, 'venue_details'), 100);
107
+			// don't display entry meta because the existing theme will take car of that
108
+			add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
109
+		}
110
+		return $template;
111
+	}
112
+
113
+
114
+	/**
115
+	 * the_title
116
+	 *
117
+	 * @access public
118
+	 * @param  string $title
119
+	 * @return string
120
+	 */
121
+	public function the_title($title = '')
122
+	{
123
+		return $title;
124
+	}
125
+
126
+
127
+	/**
128
+	 *    venue_details
129
+	 *
130
+	 * @access public
131
+	 * @param  string $content
132
+	 * @return string
133
+	 */
134
+	public function venue_details($content)
135
+	{
136
+		global $post;
137
+		if (
138
+			$post->post_type == 'espresso_venues'
139
+			&& ! post_password_required()
140
+		) {
141
+			// since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
142
+			// it uses the_content() for displaying the $post->post_content
143
+			// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
144
+			// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
145
+			remove_filter('the_content', array($this, 'venue_details'), 100);
146
+			// add filters we want
147
+			add_filter('the_content', array($this, 'venue_location'), 110);
148
+			// now load our template
149
+			$template = EEH_Template::locate_template('content-espresso_venues-details.php');
150
+			// remove other filters we added so they won't get applied to the next post
151
+			remove_filter('the_content', array($this, 'venue_location'), 110);
152
+		}
153
+		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
154
+		return ! empty($template) ? $template : $content;
155
+	}
156
+
157
+
158
+	/**
159
+	 * venue_location
160
+	 *
161
+	 * @access public
162
+	 * @param  string $content
163
+	 * @return string
164
+	 */
165
+	public function venue_location($content)
166
+	{
167
+		return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
168
+	}
169
+
170
+
171
+	/**
172
+	 *    wp_enqueue_scripts
173
+	 *
174
+	 * @access public
175
+	 * @return void
176
+	 */
177
+	public function wp_enqueue_scripts()
178
+	{
179
+		// get some style
180
+		if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) {
181
+			// first check theme folder
182
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
183
+				wp_register_style(
184
+					$this->theme,
185
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
186
+					array('dashicons', 'espresso_default')
187
+				);
188
+			} elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
189
+				wp_register_style(
190
+					$this->theme,
191
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
192
+					array('dashicons', 'espresso_default')
193
+				);
194
+			}
195
+			wp_enqueue_style($this->theme);
196
+			if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
197
+				add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
198
+			}
199
+		}
200
+	}
201 201
 }
Please login to merge, or discard this patch.