Completed
Branch BUG/11475/decode-site-title-fo... (bbd86e)
by
unknown
13:39 queued 25s
created
core/helpers/EEH_URL.helper.php 1 patch
Indentation   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -14,262 +14,262 @@
 block discarded – undo
14 14
 class EEH_URL
15 15
 {
16 16
 
17
-    /**
18
-     * _add_query_arg
19
-     * adds nonce to array of arguments then calls WP add_query_arg function
20
-     *
21
-     * @access public
22
-     * @param array  $args
23
-     * @param string $url
24
-     * @param bool   $exclude_nonce If true then the nonce will be excluded from the generated url.
25
-     * @return string
26
-     */
27
-    public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false)
28
-    {
29
-        if (empty($url)) {
30
-            $user_msg = esc_html__(
31
-                'An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.',
32
-                'event_espresso'
33
-            );
34
-            $dev_msg  = $user_msg . "\n"
35
-                . sprintf(
36
-                    esc_html__(
37
-                        'In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s method.',
38
-                        'event_espresso'
39
-                    ),
40
-                    __CLASS__ . '::add_query_args_and_nonce'
41
-                );
42
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
43
-        }
44
-        // check that an action exists and add nonce
45
-        if (! $exclude_nonce) {
46
-            if (isset($args['action']) && ! empty($args['action'])) {
47
-                $args = array_merge(
48
-                    $args,
49
-                    array(
50
-                        $args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce')
51
-                    )
52
-                );
53
-            } else {
54
-                $args = array_merge(
55
-                    $args,
56
-                    array(
57
-                        'action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce')
58
-                    )
59
-                );
60
-            }
61
-        }
17
+	/**
18
+	 * _add_query_arg
19
+	 * adds nonce to array of arguments then calls WP add_query_arg function
20
+	 *
21
+	 * @access public
22
+	 * @param array  $args
23
+	 * @param string $url
24
+	 * @param bool   $exclude_nonce If true then the nonce will be excluded from the generated url.
25
+	 * @return string
26
+	 */
27
+	public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false)
28
+	{
29
+		if (empty($url)) {
30
+			$user_msg = esc_html__(
31
+				'An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.',
32
+				'event_espresso'
33
+			);
34
+			$dev_msg  = $user_msg . "\n"
35
+				. sprintf(
36
+					esc_html__(
37
+						'In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s method.',
38
+						'event_espresso'
39
+					),
40
+					__CLASS__ . '::add_query_args_and_nonce'
41
+				);
42
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
43
+		}
44
+		// check that an action exists and add nonce
45
+		if (! $exclude_nonce) {
46
+			if (isset($args['action']) && ! empty($args['action'])) {
47
+				$args = array_merge(
48
+					$args,
49
+					array(
50
+						$args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce')
51
+					)
52
+				);
53
+			} else {
54
+				$args = array_merge(
55
+					$args,
56
+					array(
57
+						'action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce')
58
+					)
59
+				);
60
+			}
61
+		}
62 62
 
63
-        //finally, let's always add a return address (if present) :)
64
-        $args = ! empty($_REQUEST['action']) && ! isset($_REQUEST['return'])
65
-            ? array_merge($args, array('return' => $_REQUEST['action']))
66
-            : $args;
63
+		//finally, let's always add a return address (if present) :)
64
+		$args = ! empty($_REQUEST['action']) && ! isset($_REQUEST['return'])
65
+			? array_merge($args, array('return' => $_REQUEST['action']))
66
+			: $args;
67 67
 
68
-        return add_query_arg($args, $url);
69
-    }
68
+		return add_query_arg($args, $url);
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * Returns whether not the remote file exists.
74
-     * Checking via GET because HEAD requests are blocked on some server configurations.
75
-     *
76
-     * @param string  $url
77
-     * @param array $args  the arguments that should be passed through to the wp_remote_request call.
78
-     * @return boolean
79
-     */
80
-    public static function remote_file_exists($url, $args = array())
81
-    {
82
-        $results = wp_remote_request(
83
-            $url,
84
-            array_merge(
85
-                array(
86
-                    'method'      => 'GET',
87
-                    'redirection' => 1,
88
-                ),
89
-                $args
90
-            )
91
-        );
92
-        if (! $results instanceof WP_Error &&
93
-            isset($results['response']) &&
94
-            isset($results['response']['code']) &&
95
-            $results['response']['code'] == '200') {
96
-            return true;
97
-        } else {
98
-            return false;
99
-        }
100
-    }
72
+	/**
73
+	 * Returns whether not the remote file exists.
74
+	 * Checking via GET because HEAD requests are blocked on some server configurations.
75
+	 *
76
+	 * @param string  $url
77
+	 * @param array $args  the arguments that should be passed through to the wp_remote_request call.
78
+	 * @return boolean
79
+	 */
80
+	public static function remote_file_exists($url, $args = array())
81
+	{
82
+		$results = wp_remote_request(
83
+			$url,
84
+			array_merge(
85
+				array(
86
+					'method'      => 'GET',
87
+					'redirection' => 1,
88
+				),
89
+				$args
90
+			)
91
+		);
92
+		if (! $results instanceof WP_Error &&
93
+			isset($results['response']) &&
94
+			isset($results['response']['code']) &&
95
+			$results['response']['code'] == '200') {
96
+			return true;
97
+		} else {
98
+			return false;
99
+		}
100
+	}
101 101
 
102 102
 
103
-    /**
104
-     * refactor_url
105
-     * primarily used for removing the query string from a URL
106
-     *
107
-     * @param string $url
108
-     * @param bool   $remove_query  - TRUE (default) will strip off any URL params, ie: ?this=1&that=2
109
-     * @param bool   $base_url_only - TRUE will only return the scheme and host with no other parameters
110
-     * @return string
111
-     */
112
-    public static function refactor_url($url = '', $remove_query = true, $base_url_only = false)
113
-    {
114
-        // break apart incoming URL
115
-        $url_bits = parse_url($url);
116
-        // HTTP or HTTPS ?
117
-        $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'http://';
118
-        // domain
119
-        $host = isset($url_bits['host']) ? $url_bits['host'] : '';
120
-        // if only the base URL is requested, then return that now
121
-        if ($base_url_only) {
122
-            return $scheme . $host;
123
-        }
124
-        $port = isset($url_bits['port']) ? ':' . $url_bits['port'] : '';
125
-        $user = isset($url_bits['user']) ? $url_bits['user'] : '';
126
-        $pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : '';
127
-        $pass = ($user || $pass) ? $pass . '@' : '';
128
-        $path = isset($url_bits['path']) ? $url_bits['path'] : '';
129
-        // if the query string is not required, then return what we have so far
130
-        if ($remove_query) {
131
-            return $scheme . $user . $pass . $host . $port . $path;
132
-        }
133
-        $query    = isset($url_bits['query']) ? '?' . $url_bits['query'] : '';
134
-        $fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : '';
135
-        return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
136
-    }
103
+	/**
104
+	 * refactor_url
105
+	 * primarily used for removing the query string from a URL
106
+	 *
107
+	 * @param string $url
108
+	 * @param bool   $remove_query  - TRUE (default) will strip off any URL params, ie: ?this=1&that=2
109
+	 * @param bool   $base_url_only - TRUE will only return the scheme and host with no other parameters
110
+	 * @return string
111
+	 */
112
+	public static function refactor_url($url = '', $remove_query = true, $base_url_only = false)
113
+	{
114
+		// break apart incoming URL
115
+		$url_bits = parse_url($url);
116
+		// HTTP or HTTPS ?
117
+		$scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'http://';
118
+		// domain
119
+		$host = isset($url_bits['host']) ? $url_bits['host'] : '';
120
+		// if only the base URL is requested, then return that now
121
+		if ($base_url_only) {
122
+			return $scheme . $host;
123
+		}
124
+		$port = isset($url_bits['port']) ? ':' . $url_bits['port'] : '';
125
+		$user = isset($url_bits['user']) ? $url_bits['user'] : '';
126
+		$pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : '';
127
+		$pass = ($user || $pass) ? $pass . '@' : '';
128
+		$path = isset($url_bits['path']) ? $url_bits['path'] : '';
129
+		// if the query string is not required, then return what we have so far
130
+		if ($remove_query) {
131
+			return $scheme . $user . $pass . $host . $port . $path;
132
+		}
133
+		$query    = isset($url_bits['query']) ? '?' . $url_bits['query'] : '';
134
+		$fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : '';
135
+		return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
136
+	}
137 137
 
138 138
 
139
-    /**
140
-     * get_query_string
141
-     * returns just the query string from a URL, formatted by default into an array of key value pairs
142
-     *
143
-     * @param string $url
144
-     * @param bool   $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will
145
-     *                         simply return the query string
146
-     * @return string|array
147
-     */
148
-    public static function get_query_string($url = '', $as_array = true)
149
-    {
150
-        // decode, then break apart incoming URL
151
-        $url_bits = parse_url(html_entity_decode($url));
152
-        // grab query string from URL
153
-        $query = isset($url_bits['query']) ? $url_bits['query'] : '';
154
-        // if we don't want the query string formatted into an array of key => value pairs, then just return it as is
155
-        if (! $as_array) {
156
-            return $query;
157
-        }
158
-        // if no query string exists then just return an empty array now
159
-        if (empty($query)) {
160
-            return array();
161
-        }
162
-        // empty array to hold results
163
-        $query_params = array();
164
-        // now break apart the query string into separate params
165
-        $query = explode('&', $query);
166
-        // loop thru our query params
167
-        foreach ($query as $query_args) {
168
-            // break apart the key value pairs
169
-            $query_args = explode('=', $query_args);
170
-            // and add to our results array
171
-            $query_params[$query_args[0]] = $query_args[1];
172
-        }
173
-        return $query_params;
174
-    }
139
+	/**
140
+	 * get_query_string
141
+	 * returns just the query string from a URL, formatted by default into an array of key value pairs
142
+	 *
143
+	 * @param string $url
144
+	 * @param bool   $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will
145
+	 *                         simply return the query string
146
+	 * @return string|array
147
+	 */
148
+	public static function get_query_string($url = '', $as_array = true)
149
+	{
150
+		// decode, then break apart incoming URL
151
+		$url_bits = parse_url(html_entity_decode($url));
152
+		// grab query string from URL
153
+		$query = isset($url_bits['query']) ? $url_bits['query'] : '';
154
+		// if we don't want the query string formatted into an array of key => value pairs, then just return it as is
155
+		if (! $as_array) {
156
+			return $query;
157
+		}
158
+		// if no query string exists then just return an empty array now
159
+		if (empty($query)) {
160
+			return array();
161
+		}
162
+		// empty array to hold results
163
+		$query_params = array();
164
+		// now break apart the query string into separate params
165
+		$query = explode('&', $query);
166
+		// loop thru our query params
167
+		foreach ($query as $query_args) {
168
+			// break apart the key value pairs
169
+			$query_args = explode('=', $query_args);
170
+			// and add to our results array
171
+			$query_params[$query_args[0]] = $query_args[1];
172
+		}
173
+		return $query_params;
174
+	}
175 175
 
176 176
 
177
-    /**
178
-     * prevent_prefetching
179
-     *
180
-     * @return void
181
-     */
182
-    public static function prevent_prefetching()
183
-    {
184
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes
185
-        // with the registration process
186
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
187
-    }
177
+	/**
178
+	 * prevent_prefetching
179
+	 *
180
+	 * @return void
181
+	 */
182
+	public static function prevent_prefetching()
183
+	{
184
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes
185
+		// with the registration process
186
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
187
+	}
188 188
 
189 189
 
190
-    /**
191
-     * This generates a unique site-specific string.
192
-     * An example usage for this string would be to save as a unique identifier for a record in the db for usage in
193
-     * urls.
194
-     *
195
-     * @param   string $prefix Use this to prefix the string with something.
196
-     * @return string
197
-     */
198
-    public static function generate_unique_token($prefix = '')
199
-    {
200
-        $token = md5(uniqid() . mt_rand());
201
-        return $prefix ? $prefix . '_' . $token : $token;
202
-    }
190
+	/**
191
+	 * This generates a unique site-specific string.
192
+	 * An example usage for this string would be to save as a unique identifier for a record in the db for usage in
193
+	 * urls.
194
+	 *
195
+	 * @param   string $prefix Use this to prefix the string with something.
196
+	 * @return string
197
+	 */
198
+	public static function generate_unique_token($prefix = '')
199
+	{
200
+		$token = md5(uniqid() . mt_rand());
201
+		return $prefix ? $prefix . '_' . $token : $token;
202
+	}
203 203
 
204 204
 
205
-    /**
206
-     * filter_input_server_url
207
-     * uses filter_input() to sanitize one of the INPUT_SERVER URL values
208
-     * but adds a backup in case filter_input() returns nothing, which can erringly happen on some servers
209
-     *
210
-     * @param string $server_variable
211
-     * @return string
212
-     */
213
-    public static function filter_input_server_url($server_variable = 'REQUEST_URI')
214
-    {
215
-        $URL              = '';
216
-        $server_variables = array(
217
-            'REQUEST_URI' => 1,
218
-            'HTTP_HOST'   => 1,
219
-            'PHP_SELF'    => 1,
220
-        );
221
-        $server_variable  = strtoupper($server_variable);
222
-        // whitelist INPUT_SERVER var
223
-        if (isset($server_variables[$server_variable])) {
224
-            $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE);
225
-            if (empty($URL)) {
226
-                // fallback sanitization if the above fails
227
-                $URL = wp_sanitize_redirect($_SERVER[$server_variable]);
228
-            }
229
-        }
230
-        return $URL;
231
-    }
205
+	/**
206
+	 * filter_input_server_url
207
+	 * uses filter_input() to sanitize one of the INPUT_SERVER URL values
208
+	 * but adds a backup in case filter_input() returns nothing, which can erringly happen on some servers
209
+	 *
210
+	 * @param string $server_variable
211
+	 * @return string
212
+	 */
213
+	public static function filter_input_server_url($server_variable = 'REQUEST_URI')
214
+	{
215
+		$URL              = '';
216
+		$server_variables = array(
217
+			'REQUEST_URI' => 1,
218
+			'HTTP_HOST'   => 1,
219
+			'PHP_SELF'    => 1,
220
+		);
221
+		$server_variable  = strtoupper($server_variable);
222
+		// whitelist INPUT_SERVER var
223
+		if (isset($server_variables[$server_variable])) {
224
+			$URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE);
225
+			if (empty($URL)) {
226
+				// fallback sanitization if the above fails
227
+				$URL = wp_sanitize_redirect($_SERVER[$server_variable]);
228
+			}
229
+		}
230
+		return $URL;
231
+	}
232 232
 
233 233
 
234
-    /**
235
-     * Gets the current page's full URL.
236
-     *
237
-     * @return string
238
-     */
239
-    public static function current_url()
240
-    {
241
-        $url = '';
242
-        if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
243
-            $url = is_ssl() ? 'https://' : 'http://';
244
-            $url .= \EEH_URL::filter_input_server_url('HTTP_HOST');
245
-            $url .= \EEH_URL::filter_input_server_url('REQUEST_URI');
246
-        }
247
-        return $url;
248
-    }
234
+	/**
235
+	 * Gets the current page's full URL.
236
+	 *
237
+	 * @return string
238
+	 */
239
+	public static function current_url()
240
+	{
241
+		$url = '';
242
+		if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
243
+			$url = is_ssl() ? 'https://' : 'http://';
244
+			$url .= \EEH_URL::filter_input_server_url('HTTP_HOST');
245
+			$url .= \EEH_URL::filter_input_server_url('REQUEST_URI');
246
+		}
247
+		return $url;
248
+	}
249 249
 
250 250
 
251
-    /**
252
-     * Identical in functionality to EEH_current_url except it removes any provided query_parameters from it.
253
-     *
254
-     * @param array $query_parameters An array of query_parameters to remove from the current url.
255
-     * @since 4.9.46.rc.029
256
-     * @return string
257
-     */
258
-    public static function current_url_without_query_paramaters(array $query_parameters)
259
-    {
260
-        return remove_query_arg($query_parameters, EEH_URL::current_url());
261
-    }
251
+	/**
252
+	 * Identical in functionality to EEH_current_url except it removes any provided query_parameters from it.
253
+	 *
254
+	 * @param array $query_parameters An array of query_parameters to remove from the current url.
255
+	 * @since 4.9.46.rc.029
256
+	 * @return string
257
+	 */
258
+	public static function current_url_without_query_paramaters(array $query_parameters)
259
+	{
260
+		return remove_query_arg($query_parameters, EEH_URL::current_url());
261
+	}
262 262
 
263 263
 
264
-    /**
265
-     * @param string $location
266
-     * @param int    $status
267
-     * @param string $exit_notice
268
-     */
269
-    public static function safeRedirectAndExit($location, $status = 302, $exit_notice = '')
270
-    {
271
-        EE_Error::get_notices(false, true);
272
-        wp_safe_redirect($location, $status);
273
-        exit($exit_notice);
274
-    }
264
+	/**
265
+	 * @param string $location
266
+	 * @param int    $status
267
+	 * @param string $exit_notice
268
+	 */
269
+	public static function safeRedirectAndExit($location, $status = 302, $exit_notice = '')
270
+	{
271
+		EE_Error::get_notices(false, true);
272
+		wp_safe_redirect($location, $status);
273
+		exit($exit_notice);
274
+	}
275 275
 }
Please login to merge, or discard this patch.
strategies/display/EE_Invisible_Recaptcha_Display_Strategy.strategy.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -18,27 +18,27 @@  discard block
 block discarded – undo
18 18
 class EE_Invisible_Recaptcha_Display_Strategy extends EE_Display_Strategy_Base
19 19
 {
20 20
 
21
-    /**
22
-     * @return EE_Form_Input_Base|EE_Invisible_Recaptcha_Input
23
-     */
24
-    public function input()
25
-    {
26
-        return $this->_input;
27
-    }
28
-
29
-
30
-    /**
31
-     * returns HTML and javascript related to the displaying of this input
32
-     *
33
-     * @return string
34
-     * @throws InvalidInterfaceException
35
-     * @throws InvalidDataTypeException
36
-     * @throws InvalidArgumentException
37
-     */
38
-    public function display()
39
-    {
40
-        wp_enqueue_script(EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA);
41
-        return <<<EOD
21
+	/**
22
+	 * @return EE_Form_Input_Base|EE_Invisible_Recaptcha_Input
23
+	 */
24
+	public function input()
25
+	{
26
+		return $this->_input;
27
+	}
28
+
29
+
30
+	/**
31
+	 * returns HTML and javascript related to the displaying of this input
32
+	 *
33
+	 * @return string
34
+	 * @throws InvalidInterfaceException
35
+	 * @throws InvalidDataTypeException
36
+	 * @throws InvalidArgumentException
37
+	 */
38
+	public function display()
39
+	{
40
+		wp_enqueue_script(EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA);
41
+		return <<<EOD
42 42
     <div id="g-recaptcha-{$this->input()->recaptchaId()}"
43 43
         class="g-recaptcha"
44 44
         data-sitekey="{$this->input()->siteKey()}"
@@ -48,5 +48,5 @@  discard block
 block discarded – undo
48 48
         >
49 49
     </div>
50 50
 EOD;
51
-    }
51
+	}
52 52
 }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Div_Per_Section_Layout.strategy.php 2 patches
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -14,138 +14,138 @@
 block discarded – undo
14 14
 class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base
15 15
 {
16 16
 
17
-    /**
18
-     * opening div tag for a form
19
-     *
20
-     * @return string
21
-     */
22
-    public function layout_form_begin()
23
-    {
24
-        return EEH_HTML::div(
25
-            '',
26
-            $this->_form_section->html_id(),
27
-            $this->_form_section->html_class(),
28
-            $this->_form_section->html_style()
29
-        );
30
-    }
31
-
32
-
33
-
34
-    /**
35
-     * Lays out the row for the input, including label and errors
36
-     *
37
-     * @param EE_Form_Input_Base $input
38
-     * @return string
39
-     * @throws \EE_Error
40
-     */
41
-    public function layout_input($input)
42
-    {
43
-        $html = '';
44
-        // set something unique for the id
45
-        $html_id = (string)$input->html_id() !== ''
46
-            ? (string)$input->html_id()
47
-            : spl_object_hash($input);
48
-        // and add a generic input type class
49
-        $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
50
-        if ($input instanceof EE_Hidden_Input) {
51
-            $html .= EEH_HTML::nl() . $input->get_html_for_input();
52
-        } else if ($input instanceof EE_Submit_Input) {
53
-            $html .= EEH_HTML::div(
54
-                $input->get_html_for_input(),
55
-                $html_id . '-submit-dv',
56
-                "{$input->html_class()}-submit-dv {$html_class}"
57
-            );
58
-        } else if ($input instanceof EE_Select_Input) {
59
-            $html .= EEH_HTML::div(
60
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
61
-                EEH_HTML::nl() . $input->get_html_for_errors() .
62
-                EEH_HTML::nl() . $input->get_html_for_input() .
63
-                EEH_HTML::nl() . $input->get_html_for_help(),
64
-                $html_id . '-input-dv',
65
-                "{$input->html_class()}-input-dv {$html_class}"
66
-            );
67
-        } else if ($input instanceof EE_Form_Input_With_Options_Base) {
68
-            $html .= EEH_HTML::div(
69
-                EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
70
-                EEH_HTML::nl() . $input->get_html_for_errors() .
71
-                EEH_HTML::nl() . $input->get_html_for_input() .
72
-                EEH_HTML::nl() . $input->get_html_for_help(),
73
-                $html_id . '-input-dv',
74
-                "{$input->html_class()}-input-dv {$html_class}"
75
-            );
76
-        } else {
77
-            $html .= EEH_HTML::div(
78
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
79
-                EEH_HTML::nl() . $input->get_html_for_errors() .
80
-                EEH_HTML::nl() . $input->get_html_for_input() .
81
-                EEH_HTML::nl() . $input->get_html_for_help(),
82
-                $html_id . '-input-dv',
83
-                "{$input->html_class()}-input-dv {$html_class}"
84
-            );
85
-        }
86
-        return $html;
87
-    }
88
-
89
-
90
-
91
-    /**
92
-     *
93
-     * _display_label_for_option_type_question
94
-     * Gets the HTML for the 'label', which is just text for this (because labels
95
-     * should be for each input)
96
-     *
97
-     * @param EE_Form_Input_With_Options_Base $input
98
-     * @return string
99
-     */
100
-    protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input)
101
-    {
102
-        if ($input->display_html_label_text()) {
103
-            $html_label_text = $input->html_label_text();
104
-            $label_html = EEH_HTML::div(
105
-                $input->required()
106
-                    ? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
107
-                    : $html_label_text,
108
-                $input->html_label_id(),
109
-                $input->required()
110
-                    ? 'ee-required-label ' . $input->html_label_class()
111
-                    : $input->html_label_class(),
112
-                $input->html_label_style(),
113
-                $input->html_other_attributes()
114
-            );
115
-            // if no content was provided to EEH_HTML::div() above (ie: an empty label),
116
-            // then we need to close the div manually
117
-            if(empty($html_label_text)){
118
-                $label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class());
119
-            }
120
-            return $label_html;
121
-        }
122
-        return '';
123
-    }
124
-
125
-
126
-
127
-    /**
128
-     * Lays out a row for the subsection
129
-     *
130
-     * @param EE_Form_Section_Proper $form_section
131
-     * @return string
132
-     */
133
-    public function layout_subsection($form_section)
134
-    {
135
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
136
-    }
137
-
138
-
139
-
140
-    /**
141
-     * closing div tag for a form
142
-     *
143
-     * @return string
144
-     */
145
-    public function layout_form_end()
146
-    {
147
-        return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class());
148
-    }
17
+	/**
18
+	 * opening div tag for a form
19
+	 *
20
+	 * @return string
21
+	 */
22
+	public function layout_form_begin()
23
+	{
24
+		return EEH_HTML::div(
25
+			'',
26
+			$this->_form_section->html_id(),
27
+			$this->_form_section->html_class(),
28
+			$this->_form_section->html_style()
29
+		);
30
+	}
31
+
32
+
33
+
34
+	/**
35
+	 * Lays out the row for the input, including label and errors
36
+	 *
37
+	 * @param EE_Form_Input_Base $input
38
+	 * @return string
39
+	 * @throws \EE_Error
40
+	 */
41
+	public function layout_input($input)
42
+	{
43
+		$html = '';
44
+		// set something unique for the id
45
+		$html_id = (string)$input->html_id() !== ''
46
+			? (string)$input->html_id()
47
+			: spl_object_hash($input);
48
+		// and add a generic input type class
49
+		$html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
50
+		if ($input instanceof EE_Hidden_Input) {
51
+			$html .= EEH_HTML::nl() . $input->get_html_for_input();
52
+		} else if ($input instanceof EE_Submit_Input) {
53
+			$html .= EEH_HTML::div(
54
+				$input->get_html_for_input(),
55
+				$html_id . '-submit-dv',
56
+				"{$input->html_class()}-submit-dv {$html_class}"
57
+			);
58
+		} else if ($input instanceof EE_Select_Input) {
59
+			$html .= EEH_HTML::div(
60
+				EEH_HTML::nl(1) . $input->get_html_for_label() .
61
+				EEH_HTML::nl() . $input->get_html_for_errors() .
62
+				EEH_HTML::nl() . $input->get_html_for_input() .
63
+				EEH_HTML::nl() . $input->get_html_for_help(),
64
+				$html_id . '-input-dv',
65
+				"{$input->html_class()}-input-dv {$html_class}"
66
+			);
67
+		} else if ($input instanceof EE_Form_Input_With_Options_Base) {
68
+			$html .= EEH_HTML::div(
69
+				EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
70
+				EEH_HTML::nl() . $input->get_html_for_errors() .
71
+				EEH_HTML::nl() . $input->get_html_for_input() .
72
+				EEH_HTML::nl() . $input->get_html_for_help(),
73
+				$html_id . '-input-dv',
74
+				"{$input->html_class()}-input-dv {$html_class}"
75
+			);
76
+		} else {
77
+			$html .= EEH_HTML::div(
78
+				EEH_HTML::nl(1) . $input->get_html_for_label() .
79
+				EEH_HTML::nl() . $input->get_html_for_errors() .
80
+				EEH_HTML::nl() . $input->get_html_for_input() .
81
+				EEH_HTML::nl() . $input->get_html_for_help(),
82
+				$html_id . '-input-dv',
83
+				"{$input->html_class()}-input-dv {$html_class}"
84
+			);
85
+		}
86
+		return $html;
87
+	}
88
+
89
+
90
+
91
+	/**
92
+	 *
93
+	 * _display_label_for_option_type_question
94
+	 * Gets the HTML for the 'label', which is just text for this (because labels
95
+	 * should be for each input)
96
+	 *
97
+	 * @param EE_Form_Input_With_Options_Base $input
98
+	 * @return string
99
+	 */
100
+	protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input)
101
+	{
102
+		if ($input->display_html_label_text()) {
103
+			$html_label_text = $input->html_label_text();
104
+			$label_html = EEH_HTML::div(
105
+				$input->required()
106
+					? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
107
+					: $html_label_text,
108
+				$input->html_label_id(),
109
+				$input->required()
110
+					? 'ee-required-label ' . $input->html_label_class()
111
+					: $input->html_label_class(),
112
+				$input->html_label_style(),
113
+				$input->html_other_attributes()
114
+			);
115
+			// if no content was provided to EEH_HTML::div() above (ie: an empty label),
116
+			// then we need to close the div manually
117
+			if(empty($html_label_text)){
118
+				$label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class());
119
+			}
120
+			return $label_html;
121
+		}
122
+		return '';
123
+	}
124
+
125
+
126
+
127
+	/**
128
+	 * Lays out a row for the subsection
129
+	 *
130
+	 * @param EE_Form_Section_Proper $form_section
131
+	 * @return string
132
+	 */
133
+	public function layout_subsection($form_section)
134
+	{
135
+		return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
136
+	}
137
+
138
+
139
+
140
+	/**
141
+	 * closing div tag for a form
142
+	 *
143
+	 * @return string
144
+	 */
145
+	public function layout_form_end()
146
+	{
147
+		return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class());
148
+	}
149 149
 
150 150
 
151 151
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -42,44 +42,44 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $html = '';
44 44
         // set something unique for the id
45
-        $html_id = (string)$input->html_id() !== ''
46
-            ? (string)$input->html_id()
45
+        $html_id = (string) $input->html_id() !== ''
46
+            ? (string) $input->html_id()
47 47
             : spl_object_hash($input);
48 48
         // and add a generic input type class
49
-        $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
49
+        $html_class = sanitize_key(str_replace('_', '-', get_class($input))).'-dv';
50 50
         if ($input instanceof EE_Hidden_Input) {
51
-            $html .= EEH_HTML::nl() . $input->get_html_for_input();
51
+            $html .= EEH_HTML::nl().$input->get_html_for_input();
52 52
         } else if ($input instanceof EE_Submit_Input) {
53 53
             $html .= EEH_HTML::div(
54 54
                 $input->get_html_for_input(),
55
-                $html_id . '-submit-dv',
55
+                $html_id.'-submit-dv',
56 56
                 "{$input->html_class()}-submit-dv {$html_class}"
57 57
             );
58 58
         } else if ($input instanceof EE_Select_Input) {
59 59
             $html .= EEH_HTML::div(
60
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
61
-                EEH_HTML::nl() . $input->get_html_for_errors() .
62
-                EEH_HTML::nl() . $input->get_html_for_input() .
63
-                EEH_HTML::nl() . $input->get_html_for_help(),
64
-                $html_id . '-input-dv',
60
+                EEH_HTML::nl(1).$input->get_html_for_label().
61
+                EEH_HTML::nl().$input->get_html_for_errors().
62
+                EEH_HTML::nl().$input->get_html_for_input().
63
+                EEH_HTML::nl().$input->get_html_for_help(),
64
+                $html_id.'-input-dv',
65 65
                 "{$input->html_class()}-input-dv {$html_class}"
66 66
             );
67 67
         } else if ($input instanceof EE_Form_Input_With_Options_Base) {
68 68
             $html .= EEH_HTML::div(
69
-                EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
70
-                EEH_HTML::nl() . $input->get_html_for_errors() .
71
-                EEH_HTML::nl() . $input->get_html_for_input() .
72
-                EEH_HTML::nl() . $input->get_html_for_help(),
73
-                $html_id . '-input-dv',
69
+                EEH_HTML::nl().$this->_display_label_for_option_type_question($input).
70
+                EEH_HTML::nl().$input->get_html_for_errors().
71
+                EEH_HTML::nl().$input->get_html_for_input().
72
+                EEH_HTML::nl().$input->get_html_for_help(),
73
+                $html_id.'-input-dv',
74 74
                 "{$input->html_class()}-input-dv {$html_class}"
75 75
             );
76 76
         } else {
77 77
             $html .= EEH_HTML::div(
78
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
79
-                EEH_HTML::nl() . $input->get_html_for_errors() .
80
-                EEH_HTML::nl() . $input->get_html_for_input() .
81
-                EEH_HTML::nl() . $input->get_html_for_help(),
82
-                $html_id . '-input-dv',
78
+                EEH_HTML::nl(1).$input->get_html_for_label().
79
+                EEH_HTML::nl().$input->get_html_for_errors().
80
+                EEH_HTML::nl().$input->get_html_for_input().
81
+                EEH_HTML::nl().$input->get_html_for_help(),
82
+                $html_id.'-input-dv',
83 83
                 "{$input->html_class()}-input-dv {$html_class}"
84 84
             );
85 85
         }
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
             $html_label_text = $input->html_label_text();
104 104
             $label_html = EEH_HTML::div(
105 105
                 $input->required()
106
-                    ? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk')
106
+                    ? $html_label_text.EEH_HTML::span('*', '', 'ee-asterisk')
107 107
                     : $html_label_text,
108 108
                 $input->html_label_id(),
109 109
                 $input->required()
110
-                    ? 'ee-required-label ' . $input->html_label_class()
110
+                    ? 'ee-required-label '.$input->html_label_class()
111 111
                     : $input->html_label_class(),
112 112
                 $input->html_label_style(),
113 113
                 $input->html_other_attributes()
114 114
             );
115 115
             // if no content was provided to EEH_HTML::div() above (ie: an empty label),
116 116
             // then we need to close the div manually
117
-            if(empty($html_label_text)){
117
+            if (empty($html_label_text)) {
118 118
                 $label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class());
119 119
             }
120 120
             return $label_html;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function layout_subsection($form_section)
134 134
     {
135
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
135
+        return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1);
136 136
     }
137 137
 
138 138
 
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Base.form.php 2 patches
Indentation   +474 added lines, -474 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\libraries\form_sections\strategies\filter\FormHtmlFilter;
5 5
 
6 6
 if (! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -21,485 +21,485 @@  discard block
 block discarded – undo
21 21
 abstract class EE_Form_Section_Base
22 22
 {
23 23
 
24
-    /**
25
-     * the URL the form is submitted to
26
-     *
27
-     * @var string
28
-     */
29
-    protected $_action;
30
-
31
-    /**
32
-     * POST (default) or GET
33
-     *
34
-     * @var string
35
-     */
36
-    protected $_method;
37
-
38
-    /**
39
-     * html_id and html_name are derived from this by default
40
-     *
41
-     * @var string
42
-     */
43
-    protected $_name;
44
-
45
-    /**
46
-     * $_html_id
47
-     * @var string
48
-     */
49
-    protected $_html_id;
50
-
51
-    /**
52
-     * $_html_class
53
-     * @var string
54
-     */
55
-    protected $_html_class;
56
-
57
-    /**
58
-     * $_html_style
59
-     * @var string
60
-     */
61
-    protected $_html_style;
62
-
63
-    /**
64
-     * $_other_html_attributes
65
-     * @var string
66
-     */
67
-    protected $_other_html_attributes;
68
-
69
-    /**
70
-     * The form section of which this form section is a part
71
-     *
72
-     * @var EE_Form_Section_Proper
73
-     */
74
-    protected $_parent_section;
75
-
76
-    /**
77
-     * flag indicating that _construct_finalize has been called.
78
-     * If it has not been called and we try to use functions which require it, we call it
79
-     * with no parameters. But normally, _construct_finalize should be called by the instantiating class
80
-     *
81
-     * @var boolean
82
-     */
83
-    protected $_construction_finalized;
84
-
85
-    /**
86
-     * Strategy for parsing the form HTML upon display
87
-     *
88
-     * @var FormHtmlFilter
89
-     */
90
-    protected $_form_html_filter;
91
-
92
-
93
-    /**
94
-     * @param array $options_array {
95
-     * @type        $name          string the name for this form section, if you want to explicitly define it
96
-     *                             }
97
-     * @throws InvalidDataTypeException
98
-     */
99
-    public function __construct($options_array = array())
100
-    {
101
-        // used by display strategies
102
-        // assign incoming values to properties
103
-        foreach ($options_array as $key => $value) {
104
-            $key = '_' . $key;
105
-            if (property_exists($this, $key) && empty($this->{$key})) {
106
-                $this->{$key} = $value;
107
-                if($key === '_subsections' && ! is_array($value)) {
108
-                    throw new InvalidDataTypeException($key, $value, 'array');
109
-                }
110
-            }
111
-        }
112
-        // set parser which allows the form section's rendered HTML to be filtered
113
-        if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) {
114
-            $this->_form_html_filter = $options_array['form_html_filter'];
115
-        }
116
-    }
117
-
118
-
119
-
120
-    /**
121
-     * @param $parent_form_section
122
-     * @param $name
123
-     * @throws \EE_Error
124
-     */
125
-    protected function _construct_finalize($parent_form_section, $name)
126
-    {
127
-        $this->_construction_finalized = true;
128
-        $this->_parent_section = $parent_form_section;
129
-        if ($name !== null) {
130
-            $this->_name = $name;
131
-        }
132
-    }
133
-
134
-
135
-
136
-    /**
137
-     * make sure construction finalized was called, otherwise children might not be ready
138
-     *
139
-     * @return void
140
-     * @throws \EE_Error
141
-     */
142
-    public function ensure_construct_finalized_called()
143
-    {
144
-        if (! $this->_construction_finalized) {
145
-            $this->_construct_finalize($this->_parent_section, $this->_name);
146
-        }
147
-    }
148
-
149
-
150
-
151
-    /**
152
-     * @return string
153
-     */
154
-    public function action()
155
-    {
156
-        return $this->_action;
157
-    }
158
-
159
-
160
-
161
-    /**
162
-     * @param string $action
163
-     */
164
-    public function set_action($action)
165
-    {
166
-        $this->_action = $action;
167
-    }
168
-
169
-
170
-
171
-    /**
172
-     * @return string
173
-     */
174
-    public function method()
175
-    {
176
-        return ! empty($this->_method) ? $this->_method : 'POST';
177
-    }
178
-
179
-
180
-
181
-    /**
182
-     * @param string $method
183
-     */
184
-    public function set_method($method)
185
-    {
186
-        switch ($method) {
187
-            case 'get' :
188
-            case 'GET' :
189
-                $this->_method = 'GET';
190
-                break;
191
-            default :
192
-                $this->_method = 'POST';
193
-        }
194
-    }
195
-
196
-
197
-
198
-    /**
199
-     * Sets the html_id to its default value, if none was specified in the constructor.
200
-     * Calculation involves using the name and the parent's html id
201
-     * return void
202
-     *
203
-     * @throws \EE_Error
204
-     */
205
-    protected function _set_default_html_id_if_empty()
206
-    {
207
-        if (! $this->_html_id) {
208
-            if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
209
-                $this->_html_id = $this->_parent_section->html_id()
210
-                                  . '-'
211
-                                  . $this->_prep_name_for_html_id($this->name());
212
-            } else {
213
-                $this->_html_id = $this->_prep_name_for_html_id($this->name());
214
-            }
215
-        }
216
-    }
217
-
218
-
219
-
220
-    /**
221
-     * _prep_name_for_html_id
222
-     *
223
-     * @param $name
224
-     * @return string
225
-     */
226
-    private function _prep_name_for_html_id($name)
227
-    {
228
-        return sanitize_key(str_replace(array('&nbsp;', ' ', '_'), '-', $name));
229
-    }
24
+	/**
25
+	 * the URL the form is submitted to
26
+	 *
27
+	 * @var string
28
+	 */
29
+	protected $_action;
30
+
31
+	/**
32
+	 * POST (default) or GET
33
+	 *
34
+	 * @var string
35
+	 */
36
+	protected $_method;
37
+
38
+	/**
39
+	 * html_id and html_name are derived from this by default
40
+	 *
41
+	 * @var string
42
+	 */
43
+	protected $_name;
44
+
45
+	/**
46
+	 * $_html_id
47
+	 * @var string
48
+	 */
49
+	protected $_html_id;
50
+
51
+	/**
52
+	 * $_html_class
53
+	 * @var string
54
+	 */
55
+	protected $_html_class;
56
+
57
+	/**
58
+	 * $_html_style
59
+	 * @var string
60
+	 */
61
+	protected $_html_style;
62
+
63
+	/**
64
+	 * $_other_html_attributes
65
+	 * @var string
66
+	 */
67
+	protected $_other_html_attributes;
68
+
69
+	/**
70
+	 * The form section of which this form section is a part
71
+	 *
72
+	 * @var EE_Form_Section_Proper
73
+	 */
74
+	protected $_parent_section;
75
+
76
+	/**
77
+	 * flag indicating that _construct_finalize has been called.
78
+	 * If it has not been called and we try to use functions which require it, we call it
79
+	 * with no parameters. But normally, _construct_finalize should be called by the instantiating class
80
+	 *
81
+	 * @var boolean
82
+	 */
83
+	protected $_construction_finalized;
84
+
85
+	/**
86
+	 * Strategy for parsing the form HTML upon display
87
+	 *
88
+	 * @var FormHtmlFilter
89
+	 */
90
+	protected $_form_html_filter;
91
+
92
+
93
+	/**
94
+	 * @param array $options_array {
95
+	 * @type        $name          string the name for this form section, if you want to explicitly define it
96
+	 *                             }
97
+	 * @throws InvalidDataTypeException
98
+	 */
99
+	public function __construct($options_array = array())
100
+	{
101
+		// used by display strategies
102
+		// assign incoming values to properties
103
+		foreach ($options_array as $key => $value) {
104
+			$key = '_' . $key;
105
+			if (property_exists($this, $key) && empty($this->{$key})) {
106
+				$this->{$key} = $value;
107
+				if($key === '_subsections' && ! is_array($value)) {
108
+					throw new InvalidDataTypeException($key, $value, 'array');
109
+				}
110
+			}
111
+		}
112
+		// set parser which allows the form section's rendered HTML to be filtered
113
+		if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) {
114
+			$this->_form_html_filter = $options_array['form_html_filter'];
115
+		}
116
+	}
117
+
118
+
119
+
120
+	/**
121
+	 * @param $parent_form_section
122
+	 * @param $name
123
+	 * @throws \EE_Error
124
+	 */
125
+	protected function _construct_finalize($parent_form_section, $name)
126
+	{
127
+		$this->_construction_finalized = true;
128
+		$this->_parent_section = $parent_form_section;
129
+		if ($name !== null) {
130
+			$this->_name = $name;
131
+		}
132
+	}
133
+
134
+
135
+
136
+	/**
137
+	 * make sure construction finalized was called, otherwise children might not be ready
138
+	 *
139
+	 * @return void
140
+	 * @throws \EE_Error
141
+	 */
142
+	public function ensure_construct_finalized_called()
143
+	{
144
+		if (! $this->_construction_finalized) {
145
+			$this->_construct_finalize($this->_parent_section, $this->_name);
146
+		}
147
+	}
148
+
149
+
150
+
151
+	/**
152
+	 * @return string
153
+	 */
154
+	public function action()
155
+	{
156
+		return $this->_action;
157
+	}
158
+
159
+
160
+
161
+	/**
162
+	 * @param string $action
163
+	 */
164
+	public function set_action($action)
165
+	{
166
+		$this->_action = $action;
167
+	}
168
+
169
+
170
+
171
+	/**
172
+	 * @return string
173
+	 */
174
+	public function method()
175
+	{
176
+		return ! empty($this->_method) ? $this->_method : 'POST';
177
+	}
178
+
179
+
180
+
181
+	/**
182
+	 * @param string $method
183
+	 */
184
+	public function set_method($method)
185
+	{
186
+		switch ($method) {
187
+			case 'get' :
188
+			case 'GET' :
189
+				$this->_method = 'GET';
190
+				break;
191
+			default :
192
+				$this->_method = 'POST';
193
+		}
194
+	}
195
+
196
+
197
+
198
+	/**
199
+	 * Sets the html_id to its default value, if none was specified in the constructor.
200
+	 * Calculation involves using the name and the parent's html id
201
+	 * return void
202
+	 *
203
+	 * @throws \EE_Error
204
+	 */
205
+	protected function _set_default_html_id_if_empty()
206
+	{
207
+		if (! $this->_html_id) {
208
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
209
+				$this->_html_id = $this->_parent_section->html_id()
210
+								  . '-'
211
+								  . $this->_prep_name_for_html_id($this->name());
212
+			} else {
213
+				$this->_html_id = $this->_prep_name_for_html_id($this->name());
214
+			}
215
+		}
216
+	}
217
+
218
+
219
+
220
+	/**
221
+	 * _prep_name_for_html_id
222
+	 *
223
+	 * @param $name
224
+	 * @return string
225
+	 */
226
+	private function _prep_name_for_html_id($name)
227
+	{
228
+		return sanitize_key(str_replace(array('&nbsp;', ' ', '_'), '-', $name));
229
+	}
230 230
 
231 231
 
232 232
 
233
-    /**
234
-     * Returns the HTML, JS, and CSS necessary to display this form section on a page.
235
-     * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action,
236
-     * and call get_html when you want to output the html. Calling get_html_and_js after
237
-     * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary
238
-     * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/
239
-     * and so might stop working anytime.
240
-     *
241
-     * @return string
242
-     */
243
-    public function get_html_and_js()
244
-    {
245
-        return $this->get_html();
246
-    }
233
+	/**
234
+	 * Returns the HTML, JS, and CSS necessary to display this form section on a page.
235
+	 * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action,
236
+	 * and call get_html when you want to output the html. Calling get_html_and_js after
237
+	 * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary
238
+	 * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/
239
+	 * and so might stop working anytime.
240
+	 *
241
+	 * @return string
242
+	 */
243
+	public function get_html_and_js()
244
+	{
245
+		return $this->get_html();
246
+	}
247 247
 
248 248
 
249 249
 
250
-    /**
251
-     * Gets the HTML for displaying this form section
252
-     *
253
-     * @return string
254
-     */
255
-    abstract public function get_html();
256
-
257
-
258
-    /**
259
-     * @param bool $add_pound_sign
260
-     * @return string
261
-     * @throws EE_Error
262
-     */
263
-    public function html_id($add_pound_sign = false)
264
-    {
265
-        $this->_set_default_html_id_if_empty();
266
-        return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
267
-    }
268
-
269
-
270
-
271
-    /**
272
-     * @return string
273
-     */
274
-    public function html_class()
275
-    {
276
-        return $this->_html_class;
277
-    }
278
-
279
-
280
-
281
-    /**
282
-     * @return string
283
-     */
284
-    public function html_style()
285
-    {
286
-        return $this->_html_style;
287
-    }
288
-
289
-
290
-
291
-    /**
292
-     * @param mixed $html_class
293
-     */
294
-    public function set_html_class($html_class)
295
-    {
296
-        $this->_html_class = $html_class;
297
-    }
298
-
299
-
300
-
301
-    /**
302
-     * @param mixed $html_id
303
-     */
304
-    public function set_html_id($html_id)
305
-    {
306
-        $this->_html_id = $html_id;
307
-    }
308
-
309
-
310
-
311
-    /**
312
-     * @param mixed $html_style
313
-     */
314
-    public function set_html_style($html_style)
315
-    {
316
-        $this->_html_style = $html_style;
317
-    }
318
-
319
-
320
-
321
-    /**
322
-     * @param string $other_html_attributes
323
-     */
324
-    public function set_other_html_attributes($other_html_attributes)
325
-    {
326
-        $this->_other_html_attributes = $other_html_attributes;
327
-    }
328
-
329
-
330
-
331
-    /**
332
-     * @return string
333
-     */
334
-    public function other_html_attributes()
335
-    {
336
-        return $this->_other_html_attributes;
337
-    }
338
-
339
-
340
-
341
-    /**
342
-     * Gets the name of the form section. This is not the same as the HTML name.
343
-     *
344
-     * @throws EE_Error
345
-     * @return string
346
-     */
347
-    public function name()
348
-    {
349
-        if (! $this->_construction_finalized) {
350
-            throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
351
-                'event_espresso'), get_class($this)));
352
-        }
353
-        return $this->_name;
354
-    }
355
-
356
-
357
-
358
-    /**
359
-     * Gets the parent section
360
-     *
361
-     * @return EE_Form_Section_Proper
362
-     */
363
-    public function parent_section()
364
-    {
365
-        return $this->_parent_section;
366
-    }
367
-
368
-
369
-    /**
370
-     * returns HTML for generating the opening form HTML tag (<form>)
371
-     *
372
-     * @param string $action           the URL the form is submitted to
373
-     * @param string $method           POST (default) or GET
374
-     * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
375
-     * @return string
376
-     * @throws EE_Error
377
-     */
378
-    public function form_open($action = '', $method = '', $other_attributes = '')
379
-    {
380
-        if (! empty($action)) {
381
-            $this->set_action($action);
382
-        }
383
-        if (! empty($method)) {
384
-            $this->set_method($method);
385
-        }
386
-        $html = EEH_HTML::nl(1, 'form') . '<form';
387
-        $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
388
-        $html .= ' action="' . $this->action() . '"';
389
-        $html .= ' method="' . $this->method() . '"';
390
-        $html .= ' name="' . $this->name() . '"';
391
-        $html .= $other_attributes . '>';
392
-        return $html;
393
-    }
394
-
395
-
396
-
397
-    /**
398
-     * ensures that html id for form either ends in "-form" or "-frm"
399
-     * so that id doesn't conflict/collide with other elements
400
-     *
401
-     * @param string $html_id
402
-     * @return string
403
-     */
404
-    protected function get_html_id_for_form($html_id)
405
-    {
406
-        $strlen = strlen($html_id);
407
-        $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4
408
-            ? $html_id
409
-            : $html_id . '-frm';
410
-        return $html_id;
411
-    }
412
-
413
-
414
-    /**
415
-     * returns HTML for generating the closing form HTML tag (</form>)
416
-     *
417
-     * @return string
418
-     * @throws EE_Error
419
-     */
420
-    public function form_close()
421
-    {
422
-        return EEH_HTML::nl(-1, 'form')
423
-               . '</form>'
424
-               . EEH_HTML::nl()
425
-               . '<!-- end of ee-'
426
-               . $this->html_id()
427
-               . '-form -->'
428
-               . EEH_HTML::nl();
429
-    }
430
-
431
-
432
-
433
-    /**
434
-     * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and
435
-     * wp_enqueue_style; the scripts could have optionally been registered earlier)
436
-     * Default does nothing, but child classes can override
437
-     *
438
-     * @return void
439
-     */
440
-    public function enqueue_js()
441
-    {
442
-        //defaults to enqueue NO js or css
443
-    }
444
-
445
-
446
-
447
-    /**
448
-     * Adds any extra data needed by js. Eventually we'll call wp_localize_script
449
-     * with it, and it will be on each form section's 'other_data' property.
450
-     * By default nothing is added, but child classes can extend this method to add something.
451
-     * Eg, if you have an input that will cause a modal dialog to appear,
452
-     * here you could add an entry like 'modal_dialog_inputs' to this array
453
-     * to map between the input's html ID and the modal dialogue's ID, so that
454
-     * your JS code will know where to find the modal dialog when the input is pressed.
455
-     * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id';
456
-     *
457
-     * @param array $form_other_js_data
458
-     * @return array
459
-     */
460
-    public function get_other_js_data($form_other_js_data = array())
461
-    {
462
-        return $form_other_js_data;
463
-    }
464
-
465
-
466
-
467
-    /**
468
-     * This isn't just the name of an input, it's a path pointing to an input. The
469
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
470
-     * dot-dot-slash (../) means to ascend into the parent section.
471
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
472
-     * which will be returned.
473
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
474
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
475
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
476
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
477
-     * Etc
478
-     *
479
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
480
-     * @return EE_Form_Section_Base
481
-     */
482
-    public function find_section_from_path($form_section_path)
483
-    {
484
-        if (strpos($form_section_path, '/') === 0) {
485
-            $form_section_path = substr($form_section_path, strlen('/'));
486
-        }
487
-        if (empty($form_section_path)) {
488
-            return $this;
489
-        }
490
-        if (strpos($form_section_path, '../') === 0) {
491
-            $parent = $this->parent_section();
492
-            $form_section_path = substr($form_section_path, strlen('../'));
493
-            if ($parent instanceof EE_Form_Section_Base) {
494
-                return $parent->find_section_from_path($form_section_path);
495
-            }
496
-            if (empty($form_section_path)) {
497
-                return $this;
498
-            }
499
-        }
500
-        //couldn't find it using simple parent following
501
-        return null;
502
-    }
250
+	/**
251
+	 * Gets the HTML for displaying this form section
252
+	 *
253
+	 * @return string
254
+	 */
255
+	abstract public function get_html();
256
+
257
+
258
+	/**
259
+	 * @param bool $add_pound_sign
260
+	 * @return string
261
+	 * @throws EE_Error
262
+	 */
263
+	public function html_id($add_pound_sign = false)
264
+	{
265
+		$this->_set_default_html_id_if_empty();
266
+		return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
267
+	}
268
+
269
+
270
+
271
+	/**
272
+	 * @return string
273
+	 */
274
+	public function html_class()
275
+	{
276
+		return $this->_html_class;
277
+	}
278
+
279
+
280
+
281
+	/**
282
+	 * @return string
283
+	 */
284
+	public function html_style()
285
+	{
286
+		return $this->_html_style;
287
+	}
288
+
289
+
290
+
291
+	/**
292
+	 * @param mixed $html_class
293
+	 */
294
+	public function set_html_class($html_class)
295
+	{
296
+		$this->_html_class = $html_class;
297
+	}
298
+
299
+
300
+
301
+	/**
302
+	 * @param mixed $html_id
303
+	 */
304
+	public function set_html_id($html_id)
305
+	{
306
+		$this->_html_id = $html_id;
307
+	}
308
+
309
+
310
+
311
+	/**
312
+	 * @param mixed $html_style
313
+	 */
314
+	public function set_html_style($html_style)
315
+	{
316
+		$this->_html_style = $html_style;
317
+	}
318
+
319
+
320
+
321
+	/**
322
+	 * @param string $other_html_attributes
323
+	 */
324
+	public function set_other_html_attributes($other_html_attributes)
325
+	{
326
+		$this->_other_html_attributes = $other_html_attributes;
327
+	}
328
+
329
+
330
+
331
+	/**
332
+	 * @return string
333
+	 */
334
+	public function other_html_attributes()
335
+	{
336
+		return $this->_other_html_attributes;
337
+	}
338
+
339
+
340
+
341
+	/**
342
+	 * Gets the name of the form section. This is not the same as the HTML name.
343
+	 *
344
+	 * @throws EE_Error
345
+	 * @return string
346
+	 */
347
+	public function name()
348
+	{
349
+		if (! $this->_construction_finalized) {
350
+			throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
351
+				'event_espresso'), get_class($this)));
352
+		}
353
+		return $this->_name;
354
+	}
355
+
356
+
357
+
358
+	/**
359
+	 * Gets the parent section
360
+	 *
361
+	 * @return EE_Form_Section_Proper
362
+	 */
363
+	public function parent_section()
364
+	{
365
+		return $this->_parent_section;
366
+	}
367
+
368
+
369
+	/**
370
+	 * returns HTML for generating the opening form HTML tag (<form>)
371
+	 *
372
+	 * @param string $action           the URL the form is submitted to
373
+	 * @param string $method           POST (default) or GET
374
+	 * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
375
+	 * @return string
376
+	 * @throws EE_Error
377
+	 */
378
+	public function form_open($action = '', $method = '', $other_attributes = '')
379
+	{
380
+		if (! empty($action)) {
381
+			$this->set_action($action);
382
+		}
383
+		if (! empty($method)) {
384
+			$this->set_method($method);
385
+		}
386
+		$html = EEH_HTML::nl(1, 'form') . '<form';
387
+		$html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
388
+		$html .= ' action="' . $this->action() . '"';
389
+		$html .= ' method="' . $this->method() . '"';
390
+		$html .= ' name="' . $this->name() . '"';
391
+		$html .= $other_attributes . '>';
392
+		return $html;
393
+	}
394
+
395
+
396
+
397
+	/**
398
+	 * ensures that html id for form either ends in "-form" or "-frm"
399
+	 * so that id doesn't conflict/collide with other elements
400
+	 *
401
+	 * @param string $html_id
402
+	 * @return string
403
+	 */
404
+	protected function get_html_id_for_form($html_id)
405
+	{
406
+		$strlen = strlen($html_id);
407
+		$html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4
408
+			? $html_id
409
+			: $html_id . '-frm';
410
+		return $html_id;
411
+	}
412
+
413
+
414
+	/**
415
+	 * returns HTML for generating the closing form HTML tag (</form>)
416
+	 *
417
+	 * @return string
418
+	 * @throws EE_Error
419
+	 */
420
+	public function form_close()
421
+	{
422
+		return EEH_HTML::nl(-1, 'form')
423
+			   . '</form>'
424
+			   . EEH_HTML::nl()
425
+			   . '<!-- end of ee-'
426
+			   . $this->html_id()
427
+			   . '-form -->'
428
+			   . EEH_HTML::nl();
429
+	}
430
+
431
+
432
+
433
+	/**
434
+	 * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and
435
+	 * wp_enqueue_style; the scripts could have optionally been registered earlier)
436
+	 * Default does nothing, but child classes can override
437
+	 *
438
+	 * @return void
439
+	 */
440
+	public function enqueue_js()
441
+	{
442
+		//defaults to enqueue NO js or css
443
+	}
444
+
445
+
446
+
447
+	/**
448
+	 * Adds any extra data needed by js. Eventually we'll call wp_localize_script
449
+	 * with it, and it will be on each form section's 'other_data' property.
450
+	 * By default nothing is added, but child classes can extend this method to add something.
451
+	 * Eg, if you have an input that will cause a modal dialog to appear,
452
+	 * here you could add an entry like 'modal_dialog_inputs' to this array
453
+	 * to map between the input's html ID and the modal dialogue's ID, so that
454
+	 * your JS code will know where to find the modal dialog when the input is pressed.
455
+	 * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id';
456
+	 *
457
+	 * @param array $form_other_js_data
458
+	 * @return array
459
+	 */
460
+	public function get_other_js_data($form_other_js_data = array())
461
+	{
462
+		return $form_other_js_data;
463
+	}
464
+
465
+
466
+
467
+	/**
468
+	 * This isn't just the name of an input, it's a path pointing to an input. The
469
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
470
+	 * dot-dot-slash (../) means to ascend into the parent section.
471
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
472
+	 * which will be returned.
473
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
474
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
475
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
476
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
477
+	 * Etc
478
+	 *
479
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
480
+	 * @return EE_Form_Section_Base
481
+	 */
482
+	public function find_section_from_path($form_section_path)
483
+	{
484
+		if (strpos($form_section_path, '/') === 0) {
485
+			$form_section_path = substr($form_section_path, strlen('/'));
486
+		}
487
+		if (empty($form_section_path)) {
488
+			return $this;
489
+		}
490
+		if (strpos($form_section_path, '../') === 0) {
491
+			$parent = $this->parent_section();
492
+			$form_section_path = substr($form_section_path, strlen('../'));
493
+			if ($parent instanceof EE_Form_Section_Base) {
494
+				return $parent->find_section_from_path($form_section_path);
495
+			}
496
+			if (empty($form_section_path)) {
497
+				return $this;
498
+			}
499
+		}
500
+		//couldn't find it using simple parent following
501
+		return null;
502
+	}
503 503
 
504 504
 
505 505
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\exceptions\InvalidDataTypeException;
4 4
 use EventEspresso\core\libraries\form_sections\strategies\filter\FormHtmlFilter;
5 5
 
6
-if (! defined('EVENT_ESPRESSO_VERSION')) {
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7 7
     exit('No direct script access allowed');
8 8
 }
9 9
 
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
         // used by display strategies
102 102
         // assign incoming values to properties
103 103
         foreach ($options_array as $key => $value) {
104
-            $key = '_' . $key;
104
+            $key = '_'.$key;
105 105
             if (property_exists($this, $key) && empty($this->{$key})) {
106 106
                 $this->{$key} = $value;
107
-                if($key === '_subsections' && ! is_array($value)) {
107
+                if ($key === '_subsections' && ! is_array($value)) {
108 108
                     throw new InvalidDataTypeException($key, $value, 'array');
109 109
                 }
110 110
             }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function ensure_construct_finalized_called()
143 143
     {
144
-        if (! $this->_construction_finalized) {
144
+        if ( ! $this->_construction_finalized) {
145 145
             $this->_construct_finalize($this->_parent_section, $this->_name);
146 146
         }
147 147
     }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     protected function _set_default_html_id_if_empty()
206 206
     {
207
-        if (! $this->_html_id) {
207
+        if ( ! $this->_html_id) {
208 208
             if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
209 209
                 $this->_html_id = $this->_parent_section->html_id()
210 210
                                   . '-'
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
     public function html_id($add_pound_sign = false)
264 264
     {
265 265
         $this->_set_default_html_id_if_empty();
266
-        return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
266
+        return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id;
267 267
     }
268 268
 
269 269
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
      */
347 347
     public function name()
348 348
     {
349
-        if (! $this->_construction_finalized) {
349
+        if ( ! $this->_construction_finalized) {
350 350
             throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
351 351
                 'event_espresso'), get_class($this)));
352 352
         }
@@ -377,18 +377,18 @@  discard block
 block discarded – undo
377 377
      */
378 378
     public function form_open($action = '', $method = '', $other_attributes = '')
379 379
     {
380
-        if (! empty($action)) {
380
+        if ( ! empty($action)) {
381 381
             $this->set_action($action);
382 382
         }
383
-        if (! empty($method)) {
383
+        if ( ! empty($method)) {
384 384
             $this->set_method($method);
385 385
         }
386
-        $html = EEH_HTML::nl(1, 'form') . '<form';
387
-        $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
388
-        $html .= ' action="' . $this->action() . '"';
389
-        $html .= ' method="' . $this->method() . '"';
390
-        $html .= ' name="' . $this->name() . '"';
391
-        $html .= $other_attributes . '>';
386
+        $html = EEH_HTML::nl(1, 'form').'<form';
387
+        $html .= $this->html_id() !== '' ? ' id="'.$this->get_html_id_for_form($this->html_id()).'"' : '';
388
+        $html .= ' action="'.$this->action().'"';
389
+        $html .= ' method="'.$this->method().'"';
390
+        $html .= ' name="'.$this->name().'"';
391
+        $html .= $other_attributes.'>';
392 392
         return $html;
393 393
     }
394 394
 
@@ -404,9 +404,9 @@  discard block
 block discarded – undo
404 404
     protected function get_html_id_for_form($html_id)
405 405
     {
406 406
         $strlen = strlen($html_id);
407
-        $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4
407
+        $html_id = strpos($html_id, '-form') === $strlen - 5 || strpos($html_id, '-frm') === $strlen - 4
408 408
             ? $html_id
409
-            : $html_id . '-frm';
409
+            : $html_id.'-frm';
410 410
         return $html_id;
411 411
     }
412 412
 
Please login to merge, or discard this patch.
core/EE_Module_Request_Router.core.php 1 patch
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -17,256 +17,256 @@
 block discarded – undo
17 17
 final class EE_Module_Request_Router implements InterminableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var EE_Request $request
22
-     */
23
-    private $request;
20
+	/**
21
+	 * @var EE_Request $request
22
+	 */
23
+	private $request;
24 24
 
25
-    /**
26
-     * @var array $_previous_routes
27
-     */
28
-    private static $_previous_routes = array();
25
+	/**
26
+	 * @var array $_previous_routes
27
+	 */
28
+	private static $_previous_routes = array();
29 29
 
30
-    /**
31
-     * @var WP_Query $WP_Query
32
-     */
33
-    public $WP_Query;
30
+	/**
31
+	 * @var WP_Query $WP_Query
32
+	 */
33
+	public $WP_Query;
34 34
 
35 35
 
36 36
 
37
-    /**
38
-     * EE_Module_Request_Router constructor.
39
-     *
40
-     * @param EE_Request $request
41
-     */
42
-    public function __construct(EE_Request $request)
43
-    {
44
-        $this->request = $request;
45
-    }
37
+	/**
38
+	 * EE_Module_Request_Router constructor.
39
+	 *
40
+	 * @param EE_Request $request
41
+	 */
42
+	public function __construct(EE_Request $request)
43
+	{
44
+		$this->request = $request;
45
+	}
46 46
 
47 47
 
48 48
 
49
-    /**
50
-     * on the first call  to this method, it checks the EE_Request_Handler for a "route"
51
-     * on subsequent calls to this method,
52
-     * instead of checking the EE_Request_Handler for a route, it checks the previous routes array,
53
-     * and checks if the last called route has any forwarding routes registered for it
54
-     *
55
-     * @param WP_Query $WP_Query
56
-     * @return NULL|string
57
-     * @throws EE_Error
58
-     * @throws ReflectionException
59
-     */
60
-    public function get_route(WP_Query $WP_Query)
61
-    {
62
-        $this->WP_Query = $WP_Query;
63
-        // assume this if first route being called
64
-        $previous_route = false;
65
-        // but is it really ???
66
-        if (! empty(self::$_previous_routes)) {
67
-            // get last run route
68
-            $previous_routes = array_values(self::$_previous_routes);
69
-            $previous_route = array_pop($previous_routes);
70
-        }
71
-        //  has another route already been run ?
72
-        if ($previous_route) {
73
-            // check if  forwarding has been set
74
-            $current_route = $this->get_forward($previous_route);
75
-            try {
76
-                //check for recursive forwarding
77
-                if (isset(self::$_previous_routes[$current_route])) {
78
-                    throw new EE_Error(
79
-                        sprintf(
80
-                            __(
81
-                                'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.',
82
-                                'event_espresso'
83
-                            ),
84
-                            $current_route
85
-                        )
86
-                    );
87
-                }
88
-            } catch (EE_Error $e) {
89
-                $e->get_error();
90
-                return null;
91
-            }
92
-        } else {
93
-            // first route called
94
-            $current_route = null;
95
-            // grab all routes
96
-            $routes = EE_Config::get_routes();
97
-            foreach ($routes as $key => $route) {
98
-                // first determine if route key uses w?ldc*rds
99
-                $uses_wildcards = strpos($key, '?') !== false
100
-                                  || strpos($key, '*') !== false;
101
-                // check request for module route
102
-                $route_found = $uses_wildcards
103
-                    ? $this->request->matches($key)
104
-                    : $this->request->is_set($key);
105
-                if ($route_found) {
106
-                    $current_route = $uses_wildcards
107
-                        ? $this->request->getMatch($key)
108
-                        : $this->request->get($key);
109
-                    $current_route = sanitize_text_field($current_route);
110
-                    if ($current_route) {
111
-                        $current_route = array($key, $current_route);
112
-                        break;
113
-                    }
114
-                }
115
-            }
116
-        }
117
-        // sorry, but I can't read what you route !
118
-        if (empty($current_route)) {
119
-            return null;
120
-        }
121
-        //add route to previous routes array
122
-        self::$_previous_routes[] = $current_route;
123
-        return $current_route;
124
-    }
49
+	/**
50
+	 * on the first call  to this method, it checks the EE_Request_Handler for a "route"
51
+	 * on subsequent calls to this method,
52
+	 * instead of checking the EE_Request_Handler for a route, it checks the previous routes array,
53
+	 * and checks if the last called route has any forwarding routes registered for it
54
+	 *
55
+	 * @param WP_Query $WP_Query
56
+	 * @return NULL|string
57
+	 * @throws EE_Error
58
+	 * @throws ReflectionException
59
+	 */
60
+	public function get_route(WP_Query $WP_Query)
61
+	{
62
+		$this->WP_Query = $WP_Query;
63
+		// assume this if first route being called
64
+		$previous_route = false;
65
+		// but is it really ???
66
+		if (! empty(self::$_previous_routes)) {
67
+			// get last run route
68
+			$previous_routes = array_values(self::$_previous_routes);
69
+			$previous_route = array_pop($previous_routes);
70
+		}
71
+		//  has another route already been run ?
72
+		if ($previous_route) {
73
+			// check if  forwarding has been set
74
+			$current_route = $this->get_forward($previous_route);
75
+			try {
76
+				//check for recursive forwarding
77
+				if (isset(self::$_previous_routes[$current_route])) {
78
+					throw new EE_Error(
79
+						sprintf(
80
+							__(
81
+								'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.',
82
+								'event_espresso'
83
+							),
84
+							$current_route
85
+						)
86
+					);
87
+				}
88
+			} catch (EE_Error $e) {
89
+				$e->get_error();
90
+				return null;
91
+			}
92
+		} else {
93
+			// first route called
94
+			$current_route = null;
95
+			// grab all routes
96
+			$routes = EE_Config::get_routes();
97
+			foreach ($routes as $key => $route) {
98
+				// first determine if route key uses w?ldc*rds
99
+				$uses_wildcards = strpos($key, '?') !== false
100
+								  || strpos($key, '*') !== false;
101
+				// check request for module route
102
+				$route_found = $uses_wildcards
103
+					? $this->request->matches($key)
104
+					: $this->request->is_set($key);
105
+				if ($route_found) {
106
+					$current_route = $uses_wildcards
107
+						? $this->request->getMatch($key)
108
+						: $this->request->get($key);
109
+					$current_route = sanitize_text_field($current_route);
110
+					if ($current_route) {
111
+						$current_route = array($key, $current_route);
112
+						break;
113
+					}
114
+				}
115
+			}
116
+		}
117
+		// sorry, but I can't read what you route !
118
+		if (empty($current_route)) {
119
+			return null;
120
+		}
121
+		//add route to previous routes array
122
+		self::$_previous_routes[] = $current_route;
123
+		return $current_route;
124
+	}
125 125
 
126 126
 
127 127
 
128
-    /**
129
-     * this method simply takes a valid route, and resolves what module class method the route points to
130
-     *
131
-     * @param string $key
132
-     * @param string $current_route
133
-     * @return mixed EED_Module | boolean
134
-     * @throws EE_Error
135
-     * @throws ReflectionException
136
-     */
137
-    public function resolve_route($key, $current_route)
138
-    {
139
-        // get module method that route has been mapped to
140
-        $module_method = EE_Config::get_route($current_route, $key);
141
-        // verify result was returned
142
-        if (empty($module_method)) {
143
-            $msg = sprintf(
144
-                __('The requested route %s could not be mapped to any registered modules.', 'event_espresso'),
145
-                $current_route
146
-            );
147
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
148
-            return false;
149
-        }
150
-        // verify that result is an array
151
-        if (! is_array($module_method)) {
152
-            $msg = sprintf(__('The %s  route has not been properly registered.', 'event_espresso'), $current_route);
153
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
154
-            return false;
155
-        }
156
-        // grab module name
157
-        $module_name = $module_method[0];
158
-        // verify that a class method was registered properly
159
-        if (! isset($module_method[1])) {
160
-            $msg = sprintf(
161
-                __('A class method for the %s  route has not been properly registered.', 'event_espresso'),
162
-                $current_route
163
-            );
164
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
165
-            return false;
166
-        }
167
-        // grab method
168
-        $method = $module_method[1];
169
-        // verify that class exists
170
-        if (! class_exists($module_name)) {
171
-            $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name);
172
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
173
-            return false;
174
-        }
175
-        // verify that method exists
176
-        if (! method_exists($module_name, $method)) {
177
-            $msg = sprintf(
178
-                __('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route
179
-            );
180
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
181
-            return false;
182
-        }
183
-        // instantiate module and call route method
184
-        return $this->_module_router($module_name, $method);
185
-    }
128
+	/**
129
+	 * this method simply takes a valid route, and resolves what module class method the route points to
130
+	 *
131
+	 * @param string $key
132
+	 * @param string $current_route
133
+	 * @return mixed EED_Module | boolean
134
+	 * @throws EE_Error
135
+	 * @throws ReflectionException
136
+	 */
137
+	public function resolve_route($key, $current_route)
138
+	{
139
+		// get module method that route has been mapped to
140
+		$module_method = EE_Config::get_route($current_route, $key);
141
+		// verify result was returned
142
+		if (empty($module_method)) {
143
+			$msg = sprintf(
144
+				__('The requested route %s could not be mapped to any registered modules.', 'event_espresso'),
145
+				$current_route
146
+			);
147
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
148
+			return false;
149
+		}
150
+		// verify that result is an array
151
+		if (! is_array($module_method)) {
152
+			$msg = sprintf(__('The %s  route has not been properly registered.', 'event_espresso'), $current_route);
153
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
154
+			return false;
155
+		}
156
+		// grab module name
157
+		$module_name = $module_method[0];
158
+		// verify that a class method was registered properly
159
+		if (! isset($module_method[1])) {
160
+			$msg = sprintf(
161
+				__('A class method for the %s  route has not been properly registered.', 'event_espresso'),
162
+				$current_route
163
+			);
164
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
165
+			return false;
166
+		}
167
+		// grab method
168
+		$method = $module_method[1];
169
+		// verify that class exists
170
+		if (! class_exists($module_name)) {
171
+			$msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name);
172
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
173
+			return false;
174
+		}
175
+		// verify that method exists
176
+		if (! method_exists($module_name, $method)) {
177
+			$msg = sprintf(
178
+				__('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route
179
+			);
180
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
181
+			return false;
182
+		}
183
+		// instantiate module and call route method
184
+		return $this->_module_router($module_name, $method);
185
+	}
186 186
 
187 187
 
188 188
 
189
-    /**
190
-     * this method instantiates modules and calls the method that was defined when the route was registered
191
-     *
192
-     * @param string $module_name
193
-     * @return EED_Module|object|null
194
-     * @throws ReflectionException
195
-     */
196
-    public static function module_factory($module_name)
197
-    {
198
-        if ($module_name === 'EED_Module') {
199
-            EE_Error::add_error(
200
-                sprintf(
201
-                    __(
202
-                        'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.',
203
-                        'event_espresso'
204
-                    ), $module_name
205
-                ), __FILE__, __FUNCTION__, __LINE__
206
-            );
207
-            return null;
208
-        }
209
-        // instantiate module class
210
-        $module = new $module_name();
211
-        // ensure that class is actually a module
212
-        if (! $module instanceof EED_Module) {
213
-            EE_Error::add_error(
214
-                sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name),
215
-                __FILE__, __FUNCTION__, __LINE__
216
-            );
217
-            return null;
218
-        }
219
-        return $module;
220
-    }
189
+	/**
190
+	 * this method instantiates modules and calls the method that was defined when the route was registered
191
+	 *
192
+	 * @param string $module_name
193
+	 * @return EED_Module|object|null
194
+	 * @throws ReflectionException
195
+	 */
196
+	public static function module_factory($module_name)
197
+	{
198
+		if ($module_name === 'EED_Module') {
199
+			EE_Error::add_error(
200
+				sprintf(
201
+					__(
202
+						'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.',
203
+						'event_espresso'
204
+					), $module_name
205
+				), __FILE__, __FUNCTION__, __LINE__
206
+			);
207
+			return null;
208
+		}
209
+		// instantiate module class
210
+		$module = new $module_name();
211
+		// ensure that class is actually a module
212
+		if (! $module instanceof EED_Module) {
213
+			EE_Error::add_error(
214
+				sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name),
215
+				__FILE__, __FUNCTION__, __LINE__
216
+			);
217
+			return null;
218
+		}
219
+		return $module;
220
+	}
221 221
 
222 222
 
223 223
 
224
-    /**
225
-     * this method instantiates modules and calls the method that was defined when the route was registered
226
-     *
227
-     * @param string $module_name
228
-     * @param string $method
229
-     * @return EED_Module|null
230
-     * @throws EE_Error
231
-     * @throws ReflectionException
232
-     */
233
-    private function _module_router($module_name, $method)
234
-    {
235
-        // instantiate module class
236
-        $module = EE_Module_Request_Router::module_factory($module_name);
237
-        if ($module instanceof EED_Module) {
238
-            // and call whatever action the route was for
239
-            try {
240
-                call_user_func(array($module, $method), $this->WP_Query);
241
-            } catch (EE_Error $e) {
242
-                $e->get_error();
243
-                return null;
244
-            }
245
-        }
246
-        return $module;
247
-    }
224
+	/**
225
+	 * this method instantiates modules and calls the method that was defined when the route was registered
226
+	 *
227
+	 * @param string $module_name
228
+	 * @param string $method
229
+	 * @return EED_Module|null
230
+	 * @throws EE_Error
231
+	 * @throws ReflectionException
232
+	 */
233
+	private function _module_router($module_name, $method)
234
+	{
235
+		// instantiate module class
236
+		$module = EE_Module_Request_Router::module_factory($module_name);
237
+		if ($module instanceof EED_Module) {
238
+			// and call whatever action the route was for
239
+			try {
240
+				call_user_func(array($module, $method), $this->WP_Query);
241
+			} catch (EE_Error $e) {
242
+				$e->get_error();
243
+				return null;
244
+			}
245
+		}
246
+		return $module;
247
+	}
248 248
 
249 249
 
250 250
 
251
-    /**
252
-     * @param $current_route
253
-     * @return string
254
-     */
255
-    public function get_forward($current_route)
256
-    {
257
-        return EE_Config::get_forward($current_route);
258
-    }
251
+	/**
252
+	 * @param $current_route
253
+	 * @return string
254
+	 */
255
+	public function get_forward($current_route)
256
+	{
257
+		return EE_Config::get_forward($current_route);
258
+	}
259 259
 
260 260
 
261 261
 
262
-    /**
263
-     * @param $current_route
264
-     * @return string
265
-     */
266
-    public function get_view($current_route)
267
-    {
268
-        return EE_Config::get_view($current_route);
269
-    }
262
+	/**
263
+	 * @param $current_route
264
+	 * @return string
265
+	 */
266
+	public function get_view($current_route)
267
+	{
268
+		return EE_Config::get_view($current_route);
269
+	}
270 270
 
271 271
 
272 272
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorIframe.php 2 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 use ReflectionException;
12 12
 
13 13
 if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
14
-    exit( 'No direct script access allowed' );
14
+	exit( 'No direct script access allowed' );
15 15
 }
16 16
 
17 17
 
@@ -28,83 +28,83 @@  discard block
 block discarded – undo
28 28
 class TicketSelectorIframe extends Iframe
29 29
 {
30 30
 
31
-    /**
32
-     * TicketSelectorIframe constructor.
33
-     *
34
-     * @throws InvalidArgumentException
35
-     * @throws InvalidInterfaceException
36
-     * @throws InvalidDataTypeException
37
-     * @throws DomainException
38
-     * @throws EE_Error
39
-     * @throws ReflectionException
40
-     */
41
-    public function __construct()
42
-    {
43
-        EE_Registry::instance()->REQ->set_espresso_page( true );
44
-        /** @type \EEM_Event $EEM_Event */
45
-        $EEM_Event = EE_Registry::instance()->load_model( 'Event' );
46
-        $event = $EEM_Event->get_one_by_ID(
47
-            EE_Registry::instance()->REQ->get( 'event', 0 )
48
-        );
49
-        $ticket_selector = new DisplayTicketSelector();
50
-        $ticket_selector->setIframe( true );
51
-        parent::__construct(
52
-            esc_html__( 'Ticket Selector', 'event_espresso' ),
53
-            $ticket_selector->display( $event )
54
-        );
55
-        $this->addStylesheets(
56
-            apply_filters(
57
-                'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
58
-                array(
59
-                    'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL
60
-                                               . 'ticket_selector_embed.css?ver='
61
-                                               . EVENT_ESPRESSO_VERSION,
62
-                    'ticket_selector'       => TICKET_SELECTOR_ASSETS_URL
63
-                                               . 'ticket_selector.css?ver='
64
-                                               . EVENT_ESPRESSO_VERSION,
65
-                ),
66
-                $this
67
-            )
68
-        );
69
-        if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) {
70
-            $this->addStylesheets( array('site_theme' => '' ) );
71
-        }
72
-        $this->addScripts(
73
-            apply_filters(
74
-                'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
75
-                array(
76
-                    'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL
77
-                                                      . 'ticket_selector_iframe_embed.js?ver='
78
-                                                      . EVENT_ESPRESSO_VERSION,
79
-                ),
80
-                $this
81
-            )
82
-        );
83
-        $js_attributes = apply_filters(
84
-            'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes',
85
-            array(),
86
-            $this
87
-        );
88
-        if(! empty($js_attributes)) {
89
-            $this->addScriptAttributes($js_attributes);
90
-        }
91
-        $this->addLocalizedVars(
92
-            apply_filters(
93
-                'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__localized_vars',
94
-                array(
95
-                    'ticket_selector_iframe' => true,
96
-                    'EEDTicketSelectorMsg'   => __(
97
-                        'Please choose at least one ticket before continuing.',
98
-                        'event_espresso'
99
-                    ),
100
-                )
101
-            )
102
-        );
103
-        do_action(
104
-            'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete',
105
-            $this
106
-        );
107
-    }
31
+	/**
32
+	 * TicketSelectorIframe constructor.
33
+	 *
34
+	 * @throws InvalidArgumentException
35
+	 * @throws InvalidInterfaceException
36
+	 * @throws InvalidDataTypeException
37
+	 * @throws DomainException
38
+	 * @throws EE_Error
39
+	 * @throws ReflectionException
40
+	 */
41
+	public function __construct()
42
+	{
43
+		EE_Registry::instance()->REQ->set_espresso_page( true );
44
+		/** @type \EEM_Event $EEM_Event */
45
+		$EEM_Event = EE_Registry::instance()->load_model( 'Event' );
46
+		$event = $EEM_Event->get_one_by_ID(
47
+			EE_Registry::instance()->REQ->get( 'event', 0 )
48
+		);
49
+		$ticket_selector = new DisplayTicketSelector();
50
+		$ticket_selector->setIframe( true );
51
+		parent::__construct(
52
+			esc_html__( 'Ticket Selector', 'event_espresso' ),
53
+			$ticket_selector->display( $event )
54
+		);
55
+		$this->addStylesheets(
56
+			apply_filters(
57
+				'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
58
+				array(
59
+					'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL
60
+											   . 'ticket_selector_embed.css?ver='
61
+											   . EVENT_ESPRESSO_VERSION,
62
+					'ticket_selector'       => TICKET_SELECTOR_ASSETS_URL
63
+											   . 'ticket_selector.css?ver='
64
+											   . EVENT_ESPRESSO_VERSION,
65
+				),
66
+				$this
67
+			)
68
+		);
69
+		if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) {
70
+			$this->addStylesheets( array('site_theme' => '' ) );
71
+		}
72
+		$this->addScripts(
73
+			apply_filters(
74
+				'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
75
+				array(
76
+					'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL
77
+													  . 'ticket_selector_iframe_embed.js?ver='
78
+													  . EVENT_ESPRESSO_VERSION,
79
+				),
80
+				$this
81
+			)
82
+		);
83
+		$js_attributes = apply_filters(
84
+			'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes',
85
+			array(),
86
+			$this
87
+		);
88
+		if(! empty($js_attributes)) {
89
+			$this->addScriptAttributes($js_attributes);
90
+		}
91
+		$this->addLocalizedVars(
92
+			apply_filters(
93
+				'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__localized_vars',
94
+				array(
95
+					'ticket_selector_iframe' => true,
96
+					'EEDTicketSelectorMsg'   => __(
97
+						'Please choose at least one ticket before continuing.',
98
+						'event_espresso'
99
+					),
100
+				)
101
+			)
102
+		);
103
+		do_action(
104
+			'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete',
105
+			$this
106
+		);
107
+	}
108 108
 
109 109
 }
110 110
 // End of file TicketSelectorIframe.php
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 use InvalidArgumentException;
11 11
 use ReflectionException;
12 12
 
13
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
14
-    exit( 'No direct script access allowed' );
13
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
14
+    exit('No direct script access allowed');
15 15
 }
16 16
 
17 17
 
@@ -40,17 +40,17 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function __construct()
42 42
     {
43
-        EE_Registry::instance()->REQ->set_espresso_page( true );
43
+        EE_Registry::instance()->REQ->set_espresso_page(true);
44 44
         /** @type \EEM_Event $EEM_Event */
45
-        $EEM_Event = EE_Registry::instance()->load_model( 'Event' );
45
+        $EEM_Event = EE_Registry::instance()->load_model('Event');
46 46
         $event = $EEM_Event->get_one_by_ID(
47
-            EE_Registry::instance()->REQ->get( 'event', 0 )
47
+            EE_Registry::instance()->REQ->get('event', 0)
48 48
         );
49 49
         $ticket_selector = new DisplayTicketSelector();
50
-        $ticket_selector->setIframe( true );
50
+        $ticket_selector->setIframe(true);
51 51
         parent::__construct(
52
-            esc_html__( 'Ticket Selector', 'event_espresso' ),
53
-            $ticket_selector->display( $event )
52
+            esc_html__('Ticket Selector', 'event_espresso'),
53
+            $ticket_selector->display($event)
54 54
         );
55 55
         $this->addStylesheets(
56 56
             apply_filters(
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             )
68 68
         );
69 69
         if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) {
70
-            $this->addStylesheets( array('site_theme' => '' ) );
70
+            $this->addStylesheets(array('site_theme' => ''));
71 71
         }
72 72
         $this->addScripts(
73 73
             apply_filters(
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             array(),
86 86
             $this
87 87
         );
88
-        if(! empty($js_attributes)) {
88
+        if ( ! empty($js_attributes)) {
89 89
             $this->addScriptAttributes($js_attributes);
90 90
         }
91 91
         $this->addLocalizedVars(
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Invisible_Recaptcha_Input.input.php 2 patches
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -19,224 +19,224 @@
 block discarded – undo
19 19
 class EE_Invisible_Recaptcha_Input extends EE_Form_Input_Base
20 20
 {
21 21
 
22
-    const SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA   = 'google_invisible_recaptcha';
23
-
24
-    const SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA = 'espresso_invisible_recaptcha';
25
-
26
-    /**
27
-     * @var EE_Registration_Config $config
28
-     */
29
-    private $config;
30
-
31
-    /**
32
-     * @var string $recaptcha_id
33
-     */
34
-    private $recaptcha_id;
35
-
36
-    /**
37
-     * @var string $submit_button_id
38
-     */
39
-    private $submit_button_id;
40
-
41
-
42
-    /**
43
-     * @param array                  $input_settings
44
-     * @param EE_Registration_Config $registration_config
45
-     * @throws InvalidArgumentException
46
-     * @throws InvalidDataTypeException
47
-     * @throws InvalidInterfaceException
48
-     * @throws DomainException
49
-     */
50
-    public function __construct(array $input_settings = array(), EE_Registration_Config $registration_config = null)
51
-    {
52
-        $this->_set_display_strategy(new EE_Invisible_Recaptcha_Display_Strategy());
53
-        parent::__construct($input_settings);
54
-        $registration_config    = $registration_config instanceof EE_Registration_Config
55
-            ? $registration_config
56
-            : EE_Registry::instance()->CFG->registration;
57
-        $this->config           = $registration_config;
58
-        $this->recaptcha_id     = isset($input_settings['recaptcha_id'])
59
-            ? $input_settings['recaptcha_id']
60
-            : substr(spl_object_hash($this), 8, 8);
61
-        $this->submit_button_id = isset($input_settings['submit_button_id'])
62
-            ? $input_settings['submit_button_id']
63
-            : '';
64
-        if(
65
-            isset($input_settings['localized_vars'])
66
-            && filter_var($input_settings['iframe'], FILTER_VALIDATE_BOOLEAN)
67
-        ) {
68
-            $this->addIframeAssets($input_settings['localized_vars']);
69
-        } else {
70
-            $this->registerScripts();
71
-        }
72
-    }
73
-
74
-
75
-    /**
76
-     * @return bool
77
-     */
78
-    public function useCaptcha()
79
-    {
80
-        return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible';
81
-    }
82
-
83
-
84
-    /**
85
-     * @return string
86
-     */
87
-    public function badge()
88
-    {
89
-        return $this->config->recaptcha_badge;
90
-    }
91
-
92
-
93
-    /**
94
-     * @return string
95
-     */
96
-    public function language()
97
-    {
98
-        return $this->config->recaptcha_language;
99
-    }
100
-
101
-
102
-    /**
103
-     * @return string
104
-     */
105
-    public function siteKey()
106
-    {
107
-        return $this->config->recaptcha_publickey;
108
-    }
109
-
110
-
111
-    /**
112
-     * @return string
113
-     */
114
-    public function secretKey()
115
-    {
116
-        return $this->config->recaptcha_privatekey;
117
-    }
118
-
119
-
120
-    /**
121
-     * @return string
122
-     */
123
-    public function recaptchaId()
124
-    {
125
-        return $this->recaptcha_id;
126
-    }
127
-
128
-
129
-    /**
130
-     * @return string
131
-     */
132
-    public function submitButtonId()
133
-    {
134
-        return $this->submit_button_id;
135
-    }
136
-
137
-
138
-    /**
139
-     * @param array $localized_vars
140
-     * @throws DomainException
141
-     */
142
-    private function addIframeAssets(array $localized_vars)
143
-    {
144
-        if (! $this->useCaptcha()) {
145
-            return;
146
-        }
147
-        add_filter(
148
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
149
-            function(array $iframe_assets) {
150
-                $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] =
151
-                    EED_Recaptcha_Invisible::assetsUrl()
152
-                    . 'espresso_invisible_recaptcha.js?ver='
153
-                    . EVENT_ESPRESSO_VERSION;
154
-                $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] =
155
-                    add_query_arg(
156
-                        array(
157
-                            'onload' => 'espressoLoadRecaptcha',
158
-                            'render' => 'explicit',
159
-                            'hl'     => $this->language(),
160
-                        ),
161
-                        'https://www.google.com/recaptcha/api.js?'
162
-                    );
163
-                return $iframe_assets;
164
-            }
165
-        );
166
-        add_filter(
167
-            'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes',
168
-            function (array $iframe_asset_attributes)
169
-            {
170
-                $iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ]
171
-                    = ' async="async" defer="defer"';
172
-                return $iframe_asset_attributes;
173
-            }
174
-        );
175
-        add_action(
176
-            'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete',
177
-            function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars)
178
-            {
179
-                $ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha');
180
-            }
181
-        );
182
-    }
183
-
184
-
185
-    /**
186
-     * @return void
187
-     */
188
-    private function registerScripts()
189
-    {
190
-        if (! $this->useCaptcha()) {
191
-            return;
192
-        }
193
-        add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2);
194
-        wp_register_script(
195
-            EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
196
-            EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js',
197
-            array('espresso_core'),
198
-            EVENT_ESPRESSO_VERSION,
199
-            true
200
-        );
201
-        wp_register_script(
202
-            EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA,
203
-            add_query_arg(
204
-                array(
205
-                    'onload' => 'espressoLoadRecaptcha',
206
-                    'render' => 'explicit',
207
-                    'hl'     => $this->language(),
208
-                ),
209
-                'https://www.google.com/recaptcha/api.js?'
210
-            ),
211
-            array(EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA),
212
-            false,
213
-            true
214
-        );
215
-    }
216
-
217
-
218
-    /**
219
-     * @param string $tag
220
-     * @param string $handle
221
-     * @return string
222
-     */
223
-    public function addScriptAttributes($tag, $handle)
224
-    {
225
-        if ($handle === EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA) {
226
-            $tag = str_replace('></script>', ' async="async" defer="defer"></script>', $tag);
227
-        }
228
-        return $tag;
229
-    }
230
-
231
-
232
-    /**
233
-     * Gets the HTML for displaying the label for this form input
234
-     * according to the form section's layout strategy
235
-     *
236
-     * @return string
237
-     */
238
-    public function get_html_for_label()
239
-    {
240
-        return '';
241
-    }
22
+	const SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA   = 'google_invisible_recaptcha';
23
+
24
+	const SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA = 'espresso_invisible_recaptcha';
25
+
26
+	/**
27
+	 * @var EE_Registration_Config $config
28
+	 */
29
+	private $config;
30
+
31
+	/**
32
+	 * @var string $recaptcha_id
33
+	 */
34
+	private $recaptcha_id;
35
+
36
+	/**
37
+	 * @var string $submit_button_id
38
+	 */
39
+	private $submit_button_id;
40
+
41
+
42
+	/**
43
+	 * @param array                  $input_settings
44
+	 * @param EE_Registration_Config $registration_config
45
+	 * @throws InvalidArgumentException
46
+	 * @throws InvalidDataTypeException
47
+	 * @throws InvalidInterfaceException
48
+	 * @throws DomainException
49
+	 */
50
+	public function __construct(array $input_settings = array(), EE_Registration_Config $registration_config = null)
51
+	{
52
+		$this->_set_display_strategy(new EE_Invisible_Recaptcha_Display_Strategy());
53
+		parent::__construct($input_settings);
54
+		$registration_config    = $registration_config instanceof EE_Registration_Config
55
+			? $registration_config
56
+			: EE_Registry::instance()->CFG->registration;
57
+		$this->config           = $registration_config;
58
+		$this->recaptcha_id     = isset($input_settings['recaptcha_id'])
59
+			? $input_settings['recaptcha_id']
60
+			: substr(spl_object_hash($this), 8, 8);
61
+		$this->submit_button_id = isset($input_settings['submit_button_id'])
62
+			? $input_settings['submit_button_id']
63
+			: '';
64
+		if(
65
+			isset($input_settings['localized_vars'])
66
+			&& filter_var($input_settings['iframe'], FILTER_VALIDATE_BOOLEAN)
67
+		) {
68
+			$this->addIframeAssets($input_settings['localized_vars']);
69
+		} else {
70
+			$this->registerScripts();
71
+		}
72
+	}
73
+
74
+
75
+	/**
76
+	 * @return bool
77
+	 */
78
+	public function useCaptcha()
79
+	{
80
+		return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible';
81
+	}
82
+
83
+
84
+	/**
85
+	 * @return string
86
+	 */
87
+	public function badge()
88
+	{
89
+		return $this->config->recaptcha_badge;
90
+	}
91
+
92
+
93
+	/**
94
+	 * @return string
95
+	 */
96
+	public function language()
97
+	{
98
+		return $this->config->recaptcha_language;
99
+	}
100
+
101
+
102
+	/**
103
+	 * @return string
104
+	 */
105
+	public function siteKey()
106
+	{
107
+		return $this->config->recaptcha_publickey;
108
+	}
109
+
110
+
111
+	/**
112
+	 * @return string
113
+	 */
114
+	public function secretKey()
115
+	{
116
+		return $this->config->recaptcha_privatekey;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @return string
122
+	 */
123
+	public function recaptchaId()
124
+	{
125
+		return $this->recaptcha_id;
126
+	}
127
+
128
+
129
+	/**
130
+	 * @return string
131
+	 */
132
+	public function submitButtonId()
133
+	{
134
+		return $this->submit_button_id;
135
+	}
136
+
137
+
138
+	/**
139
+	 * @param array $localized_vars
140
+	 * @throws DomainException
141
+	 */
142
+	private function addIframeAssets(array $localized_vars)
143
+	{
144
+		if (! $this->useCaptcha()) {
145
+			return;
146
+		}
147
+		add_filter(
148
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
149
+			function(array $iframe_assets) {
150
+				$iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] =
151
+					EED_Recaptcha_Invisible::assetsUrl()
152
+					. 'espresso_invisible_recaptcha.js?ver='
153
+					. EVENT_ESPRESSO_VERSION;
154
+				$iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] =
155
+					add_query_arg(
156
+						array(
157
+							'onload' => 'espressoLoadRecaptcha',
158
+							'render' => 'explicit',
159
+							'hl'     => $this->language(),
160
+						),
161
+						'https://www.google.com/recaptcha/api.js?'
162
+					);
163
+				return $iframe_assets;
164
+			}
165
+		);
166
+		add_filter(
167
+			'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes',
168
+			function (array $iframe_asset_attributes)
169
+			{
170
+				$iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ]
171
+					= ' async="async" defer="defer"';
172
+				return $iframe_asset_attributes;
173
+			}
174
+		);
175
+		add_action(
176
+			'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete',
177
+			function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars)
178
+			{
179
+				$ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha');
180
+			}
181
+		);
182
+	}
183
+
184
+
185
+	/**
186
+	 * @return void
187
+	 */
188
+	private function registerScripts()
189
+	{
190
+		if (! $this->useCaptcha()) {
191
+			return;
192
+		}
193
+		add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2);
194
+		wp_register_script(
195
+			EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
196
+			EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js',
197
+			array('espresso_core'),
198
+			EVENT_ESPRESSO_VERSION,
199
+			true
200
+		);
201
+		wp_register_script(
202
+			EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA,
203
+			add_query_arg(
204
+				array(
205
+					'onload' => 'espressoLoadRecaptcha',
206
+					'render' => 'explicit',
207
+					'hl'     => $this->language(),
208
+				),
209
+				'https://www.google.com/recaptcha/api.js?'
210
+			),
211
+			array(EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA),
212
+			false,
213
+			true
214
+		);
215
+	}
216
+
217
+
218
+	/**
219
+	 * @param string $tag
220
+	 * @param string $handle
221
+	 * @return string
222
+	 */
223
+	public function addScriptAttributes($tag, $handle)
224
+	{
225
+		if ($handle === EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA) {
226
+			$tag = str_replace('></script>', ' async="async" defer="defer"></script>', $tag);
227
+		}
228
+		return $tag;
229
+	}
230
+
231
+
232
+	/**
233
+	 * Gets the HTML for displaying the label for this form input
234
+	 * according to the form section's layout strategy
235
+	 *
236
+	 * @return string
237
+	 */
238
+	public function get_html_for_label()
239
+	{
240
+		return '';
241
+	}
242 242
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $this->submit_button_id = isset($input_settings['submit_button_id'])
62 62
             ? $input_settings['submit_button_id']
63 63
             : '';
64
-        if(
64
+        if (
65 65
             isset($input_settings['localized_vars'])
66 66
             && filter_var($input_settings['iframe'], FILTER_VALIDATE_BOOLEAN)
67 67
         ) {
@@ -141,17 +141,17 @@  discard block
 block discarded – undo
141 141
      */
142 142
     private function addIframeAssets(array $localized_vars)
143 143
     {
144
-        if (! $this->useCaptcha()) {
144
+        if ( ! $this->useCaptcha()) {
145 145
             return;
146 146
         }
147 147
         add_filter(
148 148
             'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
149 149
             function(array $iframe_assets) {
150
-                $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] =
150
+                $iframe_assets[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA] =
151 151
                     EED_Recaptcha_Invisible::assetsUrl()
152 152
                     . 'espresso_invisible_recaptcha.js?ver='
153 153
                     . EVENT_ESPRESSO_VERSION;
154
-                $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] =
154
+                $iframe_assets[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA] =
155 155
                     add_query_arg(
156 156
                         array(
157 157
                             'onload' => 'espressoLoadRecaptcha',
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
         );
166 166
         add_filter(
167 167
             'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes',
168
-            function (array $iframe_asset_attributes)
168
+            function(array $iframe_asset_attributes)
169 169
             {
170
-                $iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ]
170
+                $iframe_asset_attributes[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA]
171 171
                     = ' async="async" defer="defer"';
172 172
                 return $iframe_asset_attributes;
173 173
             }
174 174
         );
175 175
         add_action(
176 176
             'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete',
177
-            function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars)
177
+            function(EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars)
178 178
             {
179 179
                 $ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha');
180 180
             }
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
      */
188 188
     private function registerScripts()
189 189
     {
190
-        if (! $this->useCaptcha()) {
190
+        if ( ! $this->useCaptcha()) {
191 191
             return;
192 192
         }
193 193
         add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2);
194 194
         wp_register_script(
195 195
             EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
196
-            EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js',
196
+            EED_Recaptcha_Invisible::assetsUrl().'espresso_invisible_recaptcha.js',
197 197
             array('espresso_core'),
198 198
             EVENT_ESPRESSO_VERSION,
199 199
             true
Please login to merge, or discard this patch.
core/libraries/iframe_display/iframe_wrapper.template.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
 <html>
23 23
 <head>
24 24
 	<title><?php echo $title; ?></title>
25
-<?php if ( $enqueue_wp_assets ) : ?>
25
+<?php if ($enqueue_wp_assets) : ?>
26 26
 	<?php wp_head(); ?>
27 27
 <?php else : ?>
28
-	<?php foreach ( $css as $url ) : ?>
29
-	<link rel="stylesheet" type="text/css" href="<?php echo $url;?>">
28
+	<?php foreach ($css as $url) : ?>
29
+	<link rel="stylesheet" type="text/css" href="<?php echo $url; ?>">
30 30
 	<?php endforeach; ?>
31 31
 	<script type="text/javascript">
32 32
 		<?php echo $eei18n; ?>
33 33
 	</script>
34
-	<?php foreach ( $header_js as $key => $url ) : ?>
35
-    <?php $header_attributes = isset($header_js_attributes[ $key ]) ? $header_js_attributes[ $key ] : ''; ?>
34
+	<?php foreach ($header_js as $key => $url) : ?>
35
+    <?php $header_attributes = isset($header_js_attributes[$key]) ? $header_js_attributes[$key] : ''; ?>
36 36
     <script type="text/javascript" src="<?php echo $url; ?>"<?php echo $header_attributes; ?>></script>
37 37
 	<?php endforeach; ?>
38 38
 <?php endif; ?>
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
     <div style="padding: 1em;">
43 43
         <?php echo $content; ?>
44 44
     </div>
45
-    <?php foreach ( $footer_js as $key => $url ) : ?>
46
-        <?php $footer_attributes = isset($footer_js_attributes[$key]) ? $footer_js_attributes[ $key ] : '';  ?>
47
-		<script type="text/javascript" src="<?php echo $url; ?>"<?php echo $footer_attributes;?>></script>
45
+    <?php foreach ($footer_js as $key => $url) : ?>
46
+        <?php $footer_attributes = isset($footer_js_attributes[$key]) ? $footer_js_attributes[$key] : ''; ?>
47
+		<script type="text/javascript" src="<?php echo $url; ?>"<?php echo $footer_attributes; ?>></script>
48 48
 	<?php endforeach; ?>
49
-<?php if ( $enqueue_wp_assets ) : ?>
49
+<?php if ($enqueue_wp_assets) : ?>
50 50
 	<?php wp_footer(); ?>
51 51
 <?php endif; ?>
52 52
 </body>
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha_invisible/InvisibleRecaptcha.php 2 patches
Indentation   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -31,241 +31,241 @@
 block discarded – undo
31 31
 class InvisibleRecaptcha
32 32
 {
33 33
 
34
-    const URL_GOOGLE_RECAPTCHA_API          = 'https://www.google.com/recaptcha/api/siteverify';
35
-
36
-    const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed';
37
-
38
-    /**
39
-     * @var EE_Registration_Config $config
40
-     */
41
-    private $config;
42
-
43
-    /**
44
-     * @var EE_Session $session
45
-     */
46
-    private $session;
47
-
48
-    /**
49
-     * @var boolean $recaptcha_passed
50
-     */
51
-    private $recaptcha_passed;
52
-
53
-
54
-    /**
55
-     * InvisibleRecaptcha constructor.
56
-     *
57
-     * @param EE_Registration_Config $registration_config
58
-     * @param EE_Session             $session
59
-     */
60
-    public function __construct(EE_Registration_Config $registration_config, EE_Session $session)
61
-    {
62
-        $this->config = $registration_config;
63
-        $this->session = $session;
64
-    }
65
-
66
-
67
-    /**
68
-     * @return boolean
69
-     */
70
-    public function useInvisibleRecaptcha()
71
-    {
72
-        return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible';
73
-    }
74
-
75
-
76
-    /**
77
-     * @param array $input_settings
78
-     * @return EE_Invisible_Recaptcha_Input
79
-     * @throws InvalidDataTypeException
80
-     * @throws InvalidInterfaceException
81
-     * @throws InvalidArgumentException
82
-     * @throws DomainException
83
-     */
84
-    public function getInput(array $input_settings = array())
85
-    {
86
-        return new EE_Invisible_Recaptcha_Input(
87
-            $input_settings,
88
-            $this->config
89
-        );
90
-    }
91
-
92
-
93
-    /**
94
-     * @param array $input_settings
95
-     * @return string
96
-     * @throws EE_Error
97
-     * @throws InvalidDataTypeException
98
-     * @throws InvalidInterfaceException
99
-     * @throws InvalidArgumentException
100
-     * @throws DomainException
101
-     */
102
-    public function getInputHtml(array $input_settings = array())
103
-    {
104
-        return $this->getInput($input_settings)->get_html_for_input();
105
-    }
106
-
107
-
108
-    /**
109
-     * @param EE_Form_Section_Proper $form
110
-     * @param array                  $input_settings
111
-     * @throws EE_Error
112
-     * @throws InvalidArgumentException
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     * @throws DomainException
116
-     */
117
-    public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array())
118
-    {
119
-        $form->add_subsections(
120
-            array(
121
-                'espresso_recaptcha' => $this->getInput($input_settings),
122
-            ),
123
-            null,
124
-            false
125
-        );
126
-    }
127
-
128
-
129
-    /**
130
-     * @param EE_Request $request
131
-     * @return boolean
132
-     * @throws RuntimeException
133
-     */
134
-    public function verifyToken(EE_Request $request)
135
-    {
136
-        static $previous_recaptcha_response = array();
137
-        $grecaptcha_response = $request->get('g-recaptcha-response');
138
-        // if this token has already been verified, then return previous response
139
-        if (isset($previous_recaptcha_response[ $grecaptcha_response ])) {
140
-            return $previous_recaptcha_response[ $grecaptcha_response ];
141
-        }
142
-        // will update to true if everything passes
143
-        $previous_recaptcha_response[ $grecaptcha_response ] = false;
144
-        $response                                            = wp_safe_remote_post(
145
-            InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API,
146
-            array(
147
-                'body' => array(
148
-                    'secret'   => $this->config->recaptcha_privatekey,
149
-                    'response' => $grecaptcha_response,
150
-                    'remoteip' => $request->ip_address(),
151
-                ),
152
-            )
153
-        );
154
-        if ($response instanceof WP_Error) {
155
-            $this->generateError($response->get_error_messages());
156
-            return false;
157
-        }
158
-        $results = json_decode(wp_remote_retrieve_body($response), true);
159
-        if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) {
160
-            $errors   = array_map(
161
-                array($this, 'getErrorCode'),
162
-                $results['error-codes']
163
-            );
164
-            if(isset($results['challenge_ts'])) {
165
-                $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.';
166
-            }
167
-            $this->generateError(implode(' ', $errors));
168
-        }
169
-        $previous_recaptcha_response[ $grecaptcha_response ] = true;
170
-        add_action('shutdown', array($this, 'setSessionData'));
171
-        return true;
172
-    }
173
-
174
-
175
-    /**
176
-     * @param string $error_response
177
-     * @return void
178
-     * @throws RuntimeException
179
-     */
180
-    public function generateError($error_response = '')
181
-    {
182
-        throw new RuntimeException(
183
-            sprintf(
184
-                esc_html__(
185
-                    'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.',
186
-                    'event_espresso'
187
-                ),
188
-                '<br />',
189
-                current_user_can('manage_options') ? $error_response : ''
190
-            )
191
-        );
192
-    }
193
-
194
-
195
-    /**
196
-     * @param string $error_code
197
-     * @return string
198
-     */
199
-    public function getErrorCode(&$error_code)
200
-    {
201
-        $error_codes = array(
202
-            'missing-input-secret'   => 'The secret parameter is missing.',
203
-            'invalid-input-secret'   => 'The secret parameter is invalid or malformed.',
204
-            'missing-input-response' => 'The response parameter is missing.',
205
-            'invalid-input-response' => 'The response parameter is invalid or malformed.',
206
-            'bad-request'            => 'The request is invalid or malformed.',
207
-            'timeout-or-duplicate'   => 'The request took too long to be sent or was a duplicate of a previous request.',
208
-        );
209
-        return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : '';
210
-    }
211
-
212
-
213
-    /**
214
-     * @return array
215
-     * @throws InvalidInterfaceException
216
-     * @throws InvalidDataTypeException
217
-     * @throws InvalidArgumentException
218
-     */
219
-    public function getLocalizedVars()
220
-    {
221
-        return (array) apply_filters(
222
-            'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars',
223
-            array(
224
-                'siteKey'          => $this->config->recaptcha_publickey,
225
-                'recaptcha_passed' => $this->recaptchaPassed(),
226
-                'wp_debug'         => WP_DEBUG,
227
-                'disable_submit'   => defined('EE_EVENT_QUEUE_BASE_URL'),
228
-            )
229
-        );
230
-    }
231
-
232
-
233
-    /**
234
-     * @return boolean
235
-     * @throws InvalidInterfaceException
236
-     * @throws InvalidDataTypeException
237
-     * @throws InvalidArgumentException
238
-     */
239
-    public function recaptchaPassed()
240
-    {
241
-        if ($this->recaptcha_passed !== null) {
242
-            return $this->recaptcha_passed;
243
-        }
244
-        // logged in means you have already passed a turing test of sorts
245
-        if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) {
246
-            $this->recaptcha_passed = true;
247
-            return $this->recaptcha_passed;
248
-        }
249
-        // was test already passed?
250
-        $this->recaptcha_passed = filter_var(
251
-            $this->session->get_session_data(
252
-                InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED
253
-            ),
254
-            FILTER_VALIDATE_BOOLEAN
255
-        );
256
-        return $this->recaptcha_passed;
257
-    }
258
-
259
-
260
-    /**
261
-     * @throws InvalidArgumentException
262
-     * @throws InvalidDataTypeException
263
-     * @throws InvalidInterfaceException
264
-     */
265
-    public function setSessionData()
266
-    {
267
-        $this->session->set_session_data(
268
-            array(InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true)
269
-        );
270
-    }
34
+	const URL_GOOGLE_RECAPTCHA_API          = 'https://www.google.com/recaptcha/api/siteverify';
35
+
36
+	const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed';
37
+
38
+	/**
39
+	 * @var EE_Registration_Config $config
40
+	 */
41
+	private $config;
42
+
43
+	/**
44
+	 * @var EE_Session $session
45
+	 */
46
+	private $session;
47
+
48
+	/**
49
+	 * @var boolean $recaptcha_passed
50
+	 */
51
+	private $recaptcha_passed;
52
+
53
+
54
+	/**
55
+	 * InvisibleRecaptcha constructor.
56
+	 *
57
+	 * @param EE_Registration_Config $registration_config
58
+	 * @param EE_Session             $session
59
+	 */
60
+	public function __construct(EE_Registration_Config $registration_config, EE_Session $session)
61
+	{
62
+		$this->config = $registration_config;
63
+		$this->session = $session;
64
+	}
65
+
66
+
67
+	/**
68
+	 * @return boolean
69
+	 */
70
+	public function useInvisibleRecaptcha()
71
+	{
72
+		return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible';
73
+	}
74
+
75
+
76
+	/**
77
+	 * @param array $input_settings
78
+	 * @return EE_Invisible_Recaptcha_Input
79
+	 * @throws InvalidDataTypeException
80
+	 * @throws InvalidInterfaceException
81
+	 * @throws InvalidArgumentException
82
+	 * @throws DomainException
83
+	 */
84
+	public function getInput(array $input_settings = array())
85
+	{
86
+		return new EE_Invisible_Recaptcha_Input(
87
+			$input_settings,
88
+			$this->config
89
+		);
90
+	}
91
+
92
+
93
+	/**
94
+	 * @param array $input_settings
95
+	 * @return string
96
+	 * @throws EE_Error
97
+	 * @throws InvalidDataTypeException
98
+	 * @throws InvalidInterfaceException
99
+	 * @throws InvalidArgumentException
100
+	 * @throws DomainException
101
+	 */
102
+	public function getInputHtml(array $input_settings = array())
103
+	{
104
+		return $this->getInput($input_settings)->get_html_for_input();
105
+	}
106
+
107
+
108
+	/**
109
+	 * @param EE_Form_Section_Proper $form
110
+	 * @param array                  $input_settings
111
+	 * @throws EE_Error
112
+	 * @throws InvalidArgumentException
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws DomainException
116
+	 */
117
+	public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array())
118
+	{
119
+		$form->add_subsections(
120
+			array(
121
+				'espresso_recaptcha' => $this->getInput($input_settings),
122
+			),
123
+			null,
124
+			false
125
+		);
126
+	}
127
+
128
+
129
+	/**
130
+	 * @param EE_Request $request
131
+	 * @return boolean
132
+	 * @throws RuntimeException
133
+	 */
134
+	public function verifyToken(EE_Request $request)
135
+	{
136
+		static $previous_recaptcha_response = array();
137
+		$grecaptcha_response = $request->get('g-recaptcha-response');
138
+		// if this token has already been verified, then return previous response
139
+		if (isset($previous_recaptcha_response[ $grecaptcha_response ])) {
140
+			return $previous_recaptcha_response[ $grecaptcha_response ];
141
+		}
142
+		// will update to true if everything passes
143
+		$previous_recaptcha_response[ $grecaptcha_response ] = false;
144
+		$response                                            = wp_safe_remote_post(
145
+			InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API,
146
+			array(
147
+				'body' => array(
148
+					'secret'   => $this->config->recaptcha_privatekey,
149
+					'response' => $grecaptcha_response,
150
+					'remoteip' => $request->ip_address(),
151
+				),
152
+			)
153
+		);
154
+		if ($response instanceof WP_Error) {
155
+			$this->generateError($response->get_error_messages());
156
+			return false;
157
+		}
158
+		$results = json_decode(wp_remote_retrieve_body($response), true);
159
+		if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) {
160
+			$errors   = array_map(
161
+				array($this, 'getErrorCode'),
162
+				$results['error-codes']
163
+			);
164
+			if(isset($results['challenge_ts'])) {
165
+				$errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.';
166
+			}
167
+			$this->generateError(implode(' ', $errors));
168
+		}
169
+		$previous_recaptcha_response[ $grecaptcha_response ] = true;
170
+		add_action('shutdown', array($this, 'setSessionData'));
171
+		return true;
172
+	}
173
+
174
+
175
+	/**
176
+	 * @param string $error_response
177
+	 * @return void
178
+	 * @throws RuntimeException
179
+	 */
180
+	public function generateError($error_response = '')
181
+	{
182
+		throw new RuntimeException(
183
+			sprintf(
184
+				esc_html__(
185
+					'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.',
186
+					'event_espresso'
187
+				),
188
+				'<br />',
189
+				current_user_can('manage_options') ? $error_response : ''
190
+			)
191
+		);
192
+	}
193
+
194
+
195
+	/**
196
+	 * @param string $error_code
197
+	 * @return string
198
+	 */
199
+	public function getErrorCode(&$error_code)
200
+	{
201
+		$error_codes = array(
202
+			'missing-input-secret'   => 'The secret parameter is missing.',
203
+			'invalid-input-secret'   => 'The secret parameter is invalid or malformed.',
204
+			'missing-input-response' => 'The response parameter is missing.',
205
+			'invalid-input-response' => 'The response parameter is invalid or malformed.',
206
+			'bad-request'            => 'The request is invalid or malformed.',
207
+			'timeout-or-duplicate'   => 'The request took too long to be sent or was a duplicate of a previous request.',
208
+		);
209
+		return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : '';
210
+	}
211
+
212
+
213
+	/**
214
+	 * @return array
215
+	 * @throws InvalidInterfaceException
216
+	 * @throws InvalidDataTypeException
217
+	 * @throws InvalidArgumentException
218
+	 */
219
+	public function getLocalizedVars()
220
+	{
221
+		return (array) apply_filters(
222
+			'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars',
223
+			array(
224
+				'siteKey'          => $this->config->recaptcha_publickey,
225
+				'recaptcha_passed' => $this->recaptchaPassed(),
226
+				'wp_debug'         => WP_DEBUG,
227
+				'disable_submit'   => defined('EE_EVENT_QUEUE_BASE_URL'),
228
+			)
229
+		);
230
+	}
231
+
232
+
233
+	/**
234
+	 * @return boolean
235
+	 * @throws InvalidInterfaceException
236
+	 * @throws InvalidDataTypeException
237
+	 * @throws InvalidArgumentException
238
+	 */
239
+	public function recaptchaPassed()
240
+	{
241
+		if ($this->recaptcha_passed !== null) {
242
+			return $this->recaptcha_passed;
243
+		}
244
+		// logged in means you have already passed a turing test of sorts
245
+		if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) {
246
+			$this->recaptcha_passed = true;
247
+			return $this->recaptcha_passed;
248
+		}
249
+		// was test already passed?
250
+		$this->recaptcha_passed = filter_var(
251
+			$this->session->get_session_data(
252
+				InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED
253
+			),
254
+			FILTER_VALIDATE_BOOLEAN
255
+		);
256
+		return $this->recaptcha_passed;
257
+	}
258
+
259
+
260
+	/**
261
+	 * @throws InvalidArgumentException
262
+	 * @throws InvalidDataTypeException
263
+	 * @throws InvalidInterfaceException
264
+	 */
265
+	public function setSessionData()
266
+	{
267
+		$this->session->set_session_data(
268
+			array(InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true)
269
+		);
270
+	}
271 271
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
         static $previous_recaptcha_response = array();
137 137
         $grecaptcha_response = $request->get('g-recaptcha-response');
138 138
         // if this token has already been verified, then return previous response
139
-        if (isset($previous_recaptcha_response[ $grecaptcha_response ])) {
140
-            return $previous_recaptcha_response[ $grecaptcha_response ];
139
+        if (isset($previous_recaptcha_response[$grecaptcha_response])) {
140
+            return $previous_recaptcha_response[$grecaptcha_response];
141 141
         }
142 142
         // will update to true if everything passes
143
-        $previous_recaptcha_response[ $grecaptcha_response ] = false;
143
+        $previous_recaptcha_response[$grecaptcha_response] = false;
144 144
         $response                                            = wp_safe_remote_post(
145 145
             InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API,
146 146
             array(
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
         }
158 158
         $results = json_decode(wp_remote_retrieve_body($response), true);
159 159
         if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) {
160
-            $errors   = array_map(
160
+            $errors = array_map(
161 161
                 array($this, 'getErrorCode'),
162 162
                 $results['error-codes']
163 163
             );
164
-            if(isset($results['challenge_ts'])) {
165
-                $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.';
164
+            if (isset($results['challenge_ts'])) {
165
+                $errors[] = 'challenge timestamp: '.$results['challenge_ts'].'.';
166 166
             }
167 167
             $this->generateError(implode(' ', $errors));
168 168
         }
169
-        $previous_recaptcha_response[ $grecaptcha_response ] = true;
169
+        $previous_recaptcha_response[$grecaptcha_response] = true;
170 170
         add_action('shutdown', array($this, 'setSessionData'));
171 171
         return true;
172 172
     }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             'bad-request'            => 'The request is invalid or malformed.',
207 207
             'timeout-or-duplicate'   => 'The request took too long to be sent or was a duplicate of a previous request.',
208 208
         );
209
-        return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : '';
209
+        return isset($error_codes[$error_code]) ? $error_codes[$error_code] : '';
210 210
     }
211 211
 
212 212
 
Please login to merge, or discard this patch.