@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | static $previous_recaptcha_response = array(); |
136 | 136 | $grecaptcha_response = $request->getRequestParam('g-recaptcha-response'); |
137 | 137 | // if this token has already been verified, then return previous response |
138 | - if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
139 | - return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
138 | + if (isset($previous_recaptcha_response[$grecaptcha_response])) { |
|
139 | + return $previous_recaptcha_response[$grecaptcha_response]; |
|
140 | 140 | } |
141 | 141 | // still here but no g-recaptcha-response ? - verification failed |
142 | - if (! $grecaptcha_response) { |
|
142 | + if ( ! $grecaptcha_response) { |
|
143 | 143 | EE_Error::add_error( |
144 | 144 | sprintf( |
145 | 145 | /* translators: 1: missing parameter */ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | // will update to true if everything passes |
161 | - $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
161 | + $previous_recaptcha_response[$grecaptcha_response] = false; |
|
162 | 162 | $response = wp_safe_remote_post( |
163 | 163 | InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
164 | 164 | array( |
@@ -175,16 +175,16 @@ discard block |
||
175 | 175 | } |
176 | 176 | $results = json_decode(wp_remote_retrieve_body($response), true); |
177 | 177 | if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
178 | - $errors = array_map( |
|
178 | + $errors = array_map( |
|
179 | 179 | array($this, 'getErrorCode'), |
180 | 180 | $results['error-codes'] |
181 | 181 | ); |
182 | 182 | if (isset($results['challenge_ts'])) { |
183 | - $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
183 | + $errors[] = 'challenge timestamp: '.$results['challenge_ts'].'.'; |
|
184 | 184 | } |
185 | 185 | $this->generateError(implode(' ', $errors), true); |
186 | 186 | } |
187 | - $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
187 | + $previous_recaptcha_response[$grecaptcha_response] = true; |
|
188 | 188 | add_action('shutdown', array($this, 'setSessionData')); |
189 | 189 | return true; |
190 | 190 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | 'bad-request' => 'The request is invalid or malformed.', |
226 | 226 | 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
227 | 227 | ); |
228 | - return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
228 | + return isset($error_codes[$error_code]) ? $error_codes[$error_code] : ''; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 |
@@ -27,270 +27,270 @@ |
||
27 | 27 | class InvisibleRecaptcha |
28 | 28 | { |
29 | 29 | |
30 | - const URL_GOOGLE_RECAPTCHA_API = 'https://www.google.com/recaptcha/api/siteverify'; |
|
30 | + const URL_GOOGLE_RECAPTCHA_API = 'https://www.google.com/recaptcha/api/siteverify'; |
|
31 | 31 | |
32 | - const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed'; |
|
32 | + const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed'; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var EE_Registration_Config $config |
|
36 | - */ |
|
37 | - private $config; |
|
34 | + /** |
|
35 | + * @var EE_Registration_Config $config |
|
36 | + */ |
|
37 | + private $config; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var EE_Session $session |
|
41 | - */ |
|
42 | - private $session; |
|
39 | + /** |
|
40 | + * @var EE_Session $session |
|
41 | + */ |
|
42 | + private $session; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var boolean $recaptcha_passed |
|
46 | - */ |
|
47 | - private $recaptcha_passed; |
|
44 | + /** |
|
45 | + * @var boolean $recaptcha_passed |
|
46 | + */ |
|
47 | + private $recaptcha_passed; |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * InvisibleRecaptcha constructor. |
|
52 | - * |
|
53 | - * @param EE_Registration_Config $registration_config |
|
54 | - * @param EE_Session $session |
|
55 | - */ |
|
56 | - public function __construct(EE_Registration_Config $registration_config, EE_Session $session) |
|
57 | - { |
|
58 | - $this->config = $registration_config; |
|
59 | - $this->session = $session; |
|
60 | - } |
|
50 | + /** |
|
51 | + * InvisibleRecaptcha constructor. |
|
52 | + * |
|
53 | + * @param EE_Registration_Config $registration_config |
|
54 | + * @param EE_Session $session |
|
55 | + */ |
|
56 | + public function __construct(EE_Registration_Config $registration_config, EE_Session $session) |
|
57 | + { |
|
58 | + $this->config = $registration_config; |
|
59 | + $this->session = $session; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return boolean |
|
65 | - */ |
|
66 | - public function useInvisibleRecaptcha() |
|
67 | - { |
|
68 | - return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible'; |
|
69 | - } |
|
63 | + /** |
|
64 | + * @return boolean |
|
65 | + */ |
|
66 | + public function useInvisibleRecaptcha() |
|
67 | + { |
|
68 | + return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible'; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * @param array $input_settings |
|
74 | - * @return EE_Invisible_Recaptcha_Input |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - * @throws InvalidArgumentException |
|
78 | - * @throws DomainException |
|
79 | - */ |
|
80 | - public function getInput(array $input_settings = array()) |
|
81 | - { |
|
82 | - return new EE_Invisible_Recaptcha_Input( |
|
83 | - $input_settings, |
|
84 | - $this->config |
|
85 | - ); |
|
86 | - } |
|
72 | + /** |
|
73 | + * @param array $input_settings |
|
74 | + * @return EE_Invisible_Recaptcha_Input |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + * @throws InvalidArgumentException |
|
78 | + * @throws DomainException |
|
79 | + */ |
|
80 | + public function getInput(array $input_settings = array()) |
|
81 | + { |
|
82 | + return new EE_Invisible_Recaptcha_Input( |
|
83 | + $input_settings, |
|
84 | + $this->config |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * @param array $input_settings |
|
91 | - * @return string |
|
92 | - * @throws EE_Error |
|
93 | - * @throws InvalidDataTypeException |
|
94 | - * @throws InvalidInterfaceException |
|
95 | - * @throws InvalidArgumentException |
|
96 | - * @throws DomainException |
|
97 | - */ |
|
98 | - public function getInputHtml(array $input_settings = array()) |
|
99 | - { |
|
100 | - return $this->getInput($input_settings)->get_html_for_input(); |
|
101 | - } |
|
89 | + /** |
|
90 | + * @param array $input_settings |
|
91 | + * @return string |
|
92 | + * @throws EE_Error |
|
93 | + * @throws InvalidDataTypeException |
|
94 | + * @throws InvalidInterfaceException |
|
95 | + * @throws InvalidArgumentException |
|
96 | + * @throws DomainException |
|
97 | + */ |
|
98 | + public function getInputHtml(array $input_settings = array()) |
|
99 | + { |
|
100 | + return $this->getInput($input_settings)->get_html_for_input(); |
|
101 | + } |
|
102 | 102 | |
103 | 103 | |
104 | - /** |
|
105 | - * @param EE_Form_Section_Proper $form |
|
106 | - * @param array $input_settings |
|
107 | - * @throws EE_Error |
|
108 | - * @throws InvalidArgumentException |
|
109 | - * @throws InvalidDataTypeException |
|
110 | - * @throws InvalidInterfaceException |
|
111 | - * @throws DomainException |
|
112 | - */ |
|
113 | - public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array()) |
|
114 | - { |
|
115 | - $form->add_subsections( |
|
116 | - array( |
|
117 | - 'espresso_recaptcha' => $this->getInput($input_settings), |
|
118 | - ), |
|
119 | - null, |
|
120 | - false |
|
121 | - ); |
|
122 | - } |
|
104 | + /** |
|
105 | + * @param EE_Form_Section_Proper $form |
|
106 | + * @param array $input_settings |
|
107 | + * @throws EE_Error |
|
108 | + * @throws InvalidArgumentException |
|
109 | + * @throws InvalidDataTypeException |
|
110 | + * @throws InvalidInterfaceException |
|
111 | + * @throws DomainException |
|
112 | + */ |
|
113 | + public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array()) |
|
114 | + { |
|
115 | + $form->add_subsections( |
|
116 | + array( |
|
117 | + 'espresso_recaptcha' => $this->getInput($input_settings), |
|
118 | + ), |
|
119 | + null, |
|
120 | + false |
|
121 | + ); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * @param RequestInterface $request |
|
127 | - * @return boolean |
|
128 | - * @throws InvalidArgumentException |
|
129 | - * @throws InvalidDataTypeException |
|
130 | - * @throws InvalidInterfaceException |
|
131 | - * @throws RuntimeException |
|
132 | - */ |
|
133 | - public function verifyToken(RequestInterface $request) |
|
134 | - { |
|
135 | - static $previous_recaptcha_response = array(); |
|
136 | - $grecaptcha_response = $request->getRequestParam('g-recaptcha-response'); |
|
137 | - // if this token has already been verified, then return previous response |
|
138 | - if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
139 | - return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
140 | - } |
|
141 | - // still here but no g-recaptcha-response ? - verification failed |
|
142 | - if (! $grecaptcha_response) { |
|
143 | - EE_Error::add_error( |
|
144 | - sprintf( |
|
145 | - /* translators: 1: missing parameter */ |
|
146 | - esc_html__( |
|
147 | - // @codingStandardsIgnoreStart |
|
148 | - 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.', |
|
149 | - // @codingStandardsIgnoreEnd |
|
150 | - 'event_espresso' |
|
151 | - ), |
|
152 | - 'g-recaptcha-response' |
|
153 | - ), |
|
154 | - __FILE__, |
|
155 | - __FUNCTION__, |
|
156 | - __LINE__ |
|
157 | - ); |
|
158 | - return false; |
|
159 | - } |
|
160 | - // will update to true if everything passes |
|
161 | - $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
162 | - $response = wp_safe_remote_post( |
|
163 | - InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
|
164 | - array( |
|
165 | - 'body' => array( |
|
166 | - 'secret' => $this->config->recaptcha_privatekey, |
|
167 | - 'response' => $grecaptcha_response, |
|
168 | - 'remoteip' => $request->ipAddress(), |
|
169 | - ), |
|
170 | - ) |
|
171 | - ); |
|
172 | - if ($response instanceof WP_Error) { |
|
173 | - $this->generateError($response->get_error_messages()); |
|
174 | - return false; |
|
175 | - } |
|
176 | - $results = json_decode(wp_remote_retrieve_body($response), true); |
|
177 | - if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
|
178 | - $errors = array_map( |
|
179 | - array($this, 'getErrorCode'), |
|
180 | - $results['error-codes'] |
|
181 | - ); |
|
182 | - if (isset($results['challenge_ts'])) { |
|
183 | - $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
184 | - } |
|
185 | - $this->generateError(implode(' ', $errors), true); |
|
186 | - } |
|
187 | - $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
188 | - add_action('shutdown', array($this, 'setSessionData')); |
|
189 | - return true; |
|
190 | - } |
|
125 | + /** |
|
126 | + * @param RequestInterface $request |
|
127 | + * @return boolean |
|
128 | + * @throws InvalidArgumentException |
|
129 | + * @throws InvalidDataTypeException |
|
130 | + * @throws InvalidInterfaceException |
|
131 | + * @throws RuntimeException |
|
132 | + */ |
|
133 | + public function verifyToken(RequestInterface $request) |
|
134 | + { |
|
135 | + static $previous_recaptcha_response = array(); |
|
136 | + $grecaptcha_response = $request->getRequestParam('g-recaptcha-response'); |
|
137 | + // if this token has already been verified, then return previous response |
|
138 | + if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
139 | + return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
140 | + } |
|
141 | + // still here but no g-recaptcha-response ? - verification failed |
|
142 | + if (! $grecaptcha_response) { |
|
143 | + EE_Error::add_error( |
|
144 | + sprintf( |
|
145 | + /* translators: 1: missing parameter */ |
|
146 | + esc_html__( |
|
147 | + // @codingStandardsIgnoreStart |
|
148 | + 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.', |
|
149 | + // @codingStandardsIgnoreEnd |
|
150 | + 'event_espresso' |
|
151 | + ), |
|
152 | + 'g-recaptcha-response' |
|
153 | + ), |
|
154 | + __FILE__, |
|
155 | + __FUNCTION__, |
|
156 | + __LINE__ |
|
157 | + ); |
|
158 | + return false; |
|
159 | + } |
|
160 | + // will update to true if everything passes |
|
161 | + $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
162 | + $response = wp_safe_remote_post( |
|
163 | + InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
|
164 | + array( |
|
165 | + 'body' => array( |
|
166 | + 'secret' => $this->config->recaptcha_privatekey, |
|
167 | + 'response' => $grecaptcha_response, |
|
168 | + 'remoteip' => $request->ipAddress(), |
|
169 | + ), |
|
170 | + ) |
|
171 | + ); |
|
172 | + if ($response instanceof WP_Error) { |
|
173 | + $this->generateError($response->get_error_messages()); |
|
174 | + return false; |
|
175 | + } |
|
176 | + $results = json_decode(wp_remote_retrieve_body($response), true); |
|
177 | + if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
|
178 | + $errors = array_map( |
|
179 | + array($this, 'getErrorCode'), |
|
180 | + $results['error-codes'] |
|
181 | + ); |
|
182 | + if (isset($results['challenge_ts'])) { |
|
183 | + $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
184 | + } |
|
185 | + $this->generateError(implode(' ', $errors), true); |
|
186 | + } |
|
187 | + $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
188 | + add_action('shutdown', array($this, 'setSessionData')); |
|
189 | + return true; |
|
190 | + } |
|
191 | 191 | |
192 | 192 | |
193 | - /** |
|
194 | - * @param string $error_response |
|
195 | - * @param bool $show_errors |
|
196 | - * @return void |
|
197 | - * @throws RuntimeException |
|
198 | - */ |
|
199 | - public function generateError($error_response = '', $show_errors = false) |
|
200 | - { |
|
201 | - throw new RuntimeException( |
|
202 | - sprintf( |
|
203 | - esc_html__( |
|
204 | - 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.', |
|
205 | - 'event_espresso' |
|
206 | - ), |
|
207 | - '<br />', |
|
208 | - $show_errors || current_user_can('manage_options') ? $error_response : '' |
|
209 | - ) |
|
210 | - ); |
|
211 | - } |
|
193 | + /** |
|
194 | + * @param string $error_response |
|
195 | + * @param bool $show_errors |
|
196 | + * @return void |
|
197 | + * @throws RuntimeException |
|
198 | + */ |
|
199 | + public function generateError($error_response = '', $show_errors = false) |
|
200 | + { |
|
201 | + throw new RuntimeException( |
|
202 | + sprintf( |
|
203 | + esc_html__( |
|
204 | + 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.', |
|
205 | + 'event_espresso' |
|
206 | + ), |
|
207 | + '<br />', |
|
208 | + $show_errors || current_user_can('manage_options') ? $error_response : '' |
|
209 | + ) |
|
210 | + ); |
|
211 | + } |
|
212 | 212 | |
213 | 213 | |
214 | - /** |
|
215 | - * @param string $error_code |
|
216 | - * @return string |
|
217 | - */ |
|
218 | - public function getErrorCode(&$error_code) |
|
219 | - { |
|
220 | - $error_codes = array( |
|
221 | - 'missing-input-secret' => 'The secret parameter is missing.', |
|
222 | - 'invalid-input-secret' => 'The secret parameter is invalid or malformed.', |
|
223 | - 'missing-input-response' => 'The response parameter is missing.', |
|
224 | - 'invalid-input-response' => 'The response parameter is invalid or malformed.', |
|
225 | - 'bad-request' => 'The request is invalid or malformed.', |
|
226 | - 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
|
227 | - ); |
|
228 | - return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
229 | - } |
|
214 | + /** |
|
215 | + * @param string $error_code |
|
216 | + * @return string |
|
217 | + */ |
|
218 | + public function getErrorCode(&$error_code) |
|
219 | + { |
|
220 | + $error_codes = array( |
|
221 | + 'missing-input-secret' => 'The secret parameter is missing.', |
|
222 | + 'invalid-input-secret' => 'The secret parameter is invalid or malformed.', |
|
223 | + 'missing-input-response' => 'The response parameter is missing.', |
|
224 | + 'invalid-input-response' => 'The response parameter is invalid or malformed.', |
|
225 | + 'bad-request' => 'The request is invalid or malformed.', |
|
226 | + 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
|
227 | + ); |
|
228 | + return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
229 | + } |
|
230 | 230 | |
231 | 231 | |
232 | - /** |
|
233 | - * @return array |
|
234 | - * @throws InvalidInterfaceException |
|
235 | - * @throws InvalidDataTypeException |
|
236 | - * @throws InvalidArgumentException |
|
237 | - */ |
|
238 | - public function getLocalizedVars() |
|
239 | - { |
|
240 | - return (array) apply_filters( |
|
241 | - 'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars', |
|
242 | - array( |
|
243 | - 'siteKey' => $this->config->recaptcha_publickey, |
|
244 | - 'recaptcha_passed' => $this->recaptchaPassed(), |
|
245 | - 'wp_debug' => WP_DEBUG, |
|
246 | - 'disable_submit' => defined('EE_EVENT_QUEUE_BASE_URL'), |
|
247 | - 'failed_message' => wp_strip_all_tags( |
|
248 | - __( |
|
249 | - 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Please try again.', |
|
250 | - 'event_espresso' |
|
251 | - ) |
|
252 | - ) |
|
253 | - ) |
|
254 | - ); |
|
255 | - } |
|
232 | + /** |
|
233 | + * @return array |
|
234 | + * @throws InvalidInterfaceException |
|
235 | + * @throws InvalidDataTypeException |
|
236 | + * @throws InvalidArgumentException |
|
237 | + */ |
|
238 | + public function getLocalizedVars() |
|
239 | + { |
|
240 | + return (array) apply_filters( |
|
241 | + 'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars', |
|
242 | + array( |
|
243 | + 'siteKey' => $this->config->recaptcha_publickey, |
|
244 | + 'recaptcha_passed' => $this->recaptchaPassed(), |
|
245 | + 'wp_debug' => WP_DEBUG, |
|
246 | + 'disable_submit' => defined('EE_EVENT_QUEUE_BASE_URL'), |
|
247 | + 'failed_message' => wp_strip_all_tags( |
|
248 | + __( |
|
249 | + 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Please try again.', |
|
250 | + 'event_espresso' |
|
251 | + ) |
|
252 | + ) |
|
253 | + ) |
|
254 | + ); |
|
255 | + } |
|
256 | 256 | |
257 | 257 | |
258 | - /** |
|
259 | - * @return boolean |
|
260 | - * @throws InvalidInterfaceException |
|
261 | - * @throws InvalidDataTypeException |
|
262 | - * @throws InvalidArgumentException |
|
263 | - */ |
|
264 | - public function recaptchaPassed() |
|
265 | - { |
|
266 | - if ($this->recaptcha_passed !== null) { |
|
267 | - return $this->recaptcha_passed; |
|
268 | - } |
|
269 | - // logged in means you have already passed a turing test of sorts |
|
270 | - if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) { |
|
271 | - $this->recaptcha_passed = true; |
|
272 | - return $this->recaptcha_passed; |
|
273 | - } |
|
274 | - // was test already passed? |
|
275 | - $this->recaptcha_passed = filter_var( |
|
276 | - $this->session->get_session_data( |
|
277 | - InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED |
|
278 | - ), |
|
279 | - FILTER_VALIDATE_BOOLEAN |
|
280 | - ); |
|
281 | - return $this->recaptcha_passed; |
|
282 | - } |
|
258 | + /** |
|
259 | + * @return boolean |
|
260 | + * @throws InvalidInterfaceException |
|
261 | + * @throws InvalidDataTypeException |
|
262 | + * @throws InvalidArgumentException |
|
263 | + */ |
|
264 | + public function recaptchaPassed() |
|
265 | + { |
|
266 | + if ($this->recaptcha_passed !== null) { |
|
267 | + return $this->recaptcha_passed; |
|
268 | + } |
|
269 | + // logged in means you have already passed a turing test of sorts |
|
270 | + if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) { |
|
271 | + $this->recaptcha_passed = true; |
|
272 | + return $this->recaptcha_passed; |
|
273 | + } |
|
274 | + // was test already passed? |
|
275 | + $this->recaptcha_passed = filter_var( |
|
276 | + $this->session->get_session_data( |
|
277 | + InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED |
|
278 | + ), |
|
279 | + FILTER_VALIDATE_BOOLEAN |
|
280 | + ); |
|
281 | + return $this->recaptcha_passed; |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | - /** |
|
286 | - * @throws InvalidArgumentException |
|
287 | - * @throws InvalidDataTypeException |
|
288 | - * @throws InvalidInterfaceException |
|
289 | - */ |
|
290 | - public function setSessionData() |
|
291 | - { |
|
292 | - $this->session->set_session_data( |
|
293 | - array(InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true) |
|
294 | - ); |
|
295 | - } |
|
285 | + /** |
|
286 | + * @throws InvalidArgumentException |
|
287 | + * @throws InvalidDataTypeException |
|
288 | + * @throws InvalidInterfaceException |
|
289 | + */ |
|
290 | + public function setSessionData() |
|
291 | + { |
|
292 | + $this->session->set_session_data( |
|
293 | + array(InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true) |
|
294 | + ); |
|
295 | + } |
|
296 | 296 | } |
@@ -8,24 +8,24 @@ |
||
8 | 8 | */ |
9 | 9 | interface CommandHandlerInterface |
10 | 10 | { |
11 | - /** |
|
12 | - * verifies that the supplied command is the correct class for the handler. |
|
13 | - * |
|
14 | - * !!! IMPORTANT !!! |
|
15 | - * Must return $this (ie: the handler itself) |
|
16 | - * as the CommandBus utilizes method chaining |
|
17 | - * |
|
18 | - * @param CommandInterface $command |
|
19 | - * @return CommandHandlerInterface |
|
20 | - * @since 4.9.80.p |
|
21 | - */ |
|
22 | - public function verify(CommandInterface $command); |
|
11 | + /** |
|
12 | + * verifies that the supplied command is the correct class for the handler. |
|
13 | + * |
|
14 | + * !!! IMPORTANT !!! |
|
15 | + * Must return $this (ie: the handler itself) |
|
16 | + * as the CommandBus utilizes method chaining |
|
17 | + * |
|
18 | + * @param CommandInterface $command |
|
19 | + * @return CommandHandlerInterface |
|
20 | + * @since 4.9.80.p |
|
21 | + */ |
|
22 | + public function verify(CommandInterface $command); |
|
23 | 23 | |
24 | - /** |
|
25 | - * Performs the command handler's logic. |
|
26 | - * |
|
27 | - * @param CommandInterface $command |
|
28 | - * @return mixed |
|
29 | - */ |
|
30 | - public function handle(CommandInterface $command); |
|
24 | + /** |
|
25 | + * Performs the command handler's logic. |
|
26 | + * |
|
27 | + * @param CommandInterface $command |
|
28 | + * @return mixed |
|
29 | + */ |
|
30 | + public function handle(CommandInterface $command); |
|
31 | 31 | } |
@@ -15,21 +15,21 @@ |
||
15 | 15 | */ |
16 | 16 | interface JsonSerializableAndUnserializable |
17 | 17 | { |
18 | - /** |
|
19 | - * Creates a simple PHP array or stdClass from this object's properties, which can be easily serialized using |
|
20 | - * wp_json_serialize(). |
|
21 | - * @since 4.9.80.p |
|
22 | - * @return mixed |
|
23 | - */ |
|
24 | - public function toJsonSerializableData(); |
|
18 | + /** |
|
19 | + * Creates a simple PHP array or stdClass from this object's properties, which can be easily serialized using |
|
20 | + * wp_json_serialize(). |
|
21 | + * @since 4.9.80.p |
|
22 | + * @return mixed |
|
23 | + */ |
|
24 | + public function toJsonSerializableData(); |
|
25 | 25 | |
26 | - /** |
|
27 | - * Initializes this object from data |
|
28 | - * @since 4.9.80.p |
|
29 | - * @param mixed $data |
|
30 | - * @return boolean success |
|
31 | - */ |
|
32 | - public function fromJsonSerializedData($data); |
|
26 | + /** |
|
27 | + * Initializes this object from data |
|
28 | + * @since 4.9.80.p |
|
29 | + * @param mixed $data |
|
30 | + * @return boolean success |
|
31 | + */ |
|
32 | + public function fromJsonSerializedData($data); |
|
33 | 33 | } |
34 | 34 | // End of file JsonSerializableAndUnserializable.php |
35 | 35 | // Location: EventEspresso\core\services\json/JsonSerializableAndUnserializable.php |
@@ -15,37 +15,37 @@ |
||
15 | 15 | interface FileSubmissionInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function getName(); |
|
22 | - |
|
23 | - /** |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function getType(); |
|
27 | - |
|
28 | - /** |
|
29 | - * @return int |
|
30 | - */ |
|
31 | - public function getSize(); |
|
32 | - |
|
33 | - /** |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public function getTmpFile(); |
|
37 | - |
|
38 | - /** |
|
39 | - * Should just return the filename. |
|
40 | - * @since 4.9.80.p |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function __toString(); |
|
44 | - |
|
45 | - /** |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function getErrorCode(); |
|
18 | + /** |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function getName(); |
|
22 | + |
|
23 | + /** |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function getType(); |
|
27 | + |
|
28 | + /** |
|
29 | + * @return int |
|
30 | + */ |
|
31 | + public function getSize(); |
|
32 | + |
|
33 | + /** |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public function getTmpFile(); |
|
37 | + |
|
38 | + /** |
|
39 | + * Should just return the filename. |
|
40 | + * @since 4.9.80.p |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function __toString(); |
|
44 | + |
|
45 | + /** |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function getErrorCode(); |
|
49 | 49 | } |
50 | 50 | // End of file FileSubmissionInterface.php |
51 | 51 | // Location: EventEspresso\core\services\request\files/FileSubmissionInterface.php |
@@ -16,39 +16,39 @@ |
||
16 | 16 | */ |
17 | 17 | class JsonWpOptionManager |
18 | 18 | { |
19 | - /** |
|
20 | - * Updates the object with what's in the DB (specifically, the wp_options table). If nothing is in the DB, leaves |
|
21 | - * the object alone and returns false. |
|
22 | - * @since 4.9.80.p |
|
23 | - * @param JsonWpOptionSerializableInterface $obj |
|
24 | - * @return bool |
|
25 | - */ |
|
26 | - public function populateFromDb(JsonWpOptionSerializableInterface $obj) |
|
27 | - { |
|
28 | - $option = get_option($obj->getWpOptionName()); |
|
29 | - if ($option) { |
|
30 | - $json = json_decode($option); |
|
31 | - if (is_array($json) || $json instanceof stdClass) { |
|
32 | - return $obj->fromJsonSerializedData($json); |
|
33 | - } |
|
34 | - } |
|
35 | - return false; |
|
36 | - } |
|
19 | + /** |
|
20 | + * Updates the object with what's in the DB (specifically, the wp_options table). If nothing is in the DB, leaves |
|
21 | + * the object alone and returns false. |
|
22 | + * @since 4.9.80.p |
|
23 | + * @param JsonWpOptionSerializableInterface $obj |
|
24 | + * @return bool |
|
25 | + */ |
|
26 | + public function populateFromDb(JsonWpOptionSerializableInterface $obj) |
|
27 | + { |
|
28 | + $option = get_option($obj->getWpOptionName()); |
|
29 | + if ($option) { |
|
30 | + $json = json_decode($option); |
|
31 | + if (is_array($json) || $json instanceof stdClass) { |
|
32 | + return $obj->fromJsonSerializedData($json); |
|
33 | + } |
|
34 | + } |
|
35 | + return false; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Saves the object's data to the wp_options table for later use. |
|
40 | - * @since 4.9.80.p |
|
41 | - * @param JsonWpOptionSerializableInterface $obj |
|
42 | - * @return bool |
|
43 | - */ |
|
44 | - public function saveToDb(JsonWpOptionSerializableInterface $obj) |
|
45 | - { |
|
46 | - return update_option( |
|
47 | - $obj->getWpOptionName(), |
|
48 | - wp_json_encode($obj->toJsonSerializableData()), |
|
49 | - false |
|
50 | - ); |
|
51 | - } |
|
38 | + /** |
|
39 | + * Saves the object's data to the wp_options table for later use. |
|
40 | + * @since 4.9.80.p |
|
41 | + * @param JsonWpOptionSerializableInterface $obj |
|
42 | + * @return bool |
|
43 | + */ |
|
44 | + public function saveToDb(JsonWpOptionSerializableInterface $obj) |
|
45 | + { |
|
46 | + return update_option( |
|
47 | + $obj->getWpOptionName(), |
|
48 | + wp_json_encode($obj->toJsonSerializableData()), |
|
49 | + false |
|
50 | + ); |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | // End of file JsonWpOptionManager.php |
54 | 54 | // Location: EventEspresso\core\services\options/JsonWpOptionManager.php |
@@ -17,13 +17,13 @@ |
||
17 | 17 | */ |
18 | 18 | interface JsonWpOptionSerializableInterface extends JsonSerializableAndUnserializable |
19 | 19 | { |
20 | - /** |
|
21 | - * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to |
|
22 | - * determine what option name to use. |
|
23 | - * @since 4.9.80.p |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function getWpOptionName(); |
|
20 | + /** |
|
21 | + * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to |
|
22 | + * determine what option name to use. |
|
23 | + * @since 4.9.80.p |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function getWpOptionName(); |
|
27 | 27 | } |
28 | 28 | // End of file JsonWpOptionSerializableInterface.php |
29 | 29 | // Location: EventEspresso\core\services\options/JsonWpOptionSerializableInterface.php |
@@ -63,8 +63,8 @@ |
||
63 | 63 | */ |
64 | 64 | private function setCaffeinated() |
65 | 65 | { |
66 | - $this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true) |
|
67 | - && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php'); |
|
66 | + $this->caffeinated = ( ! defined('EE_DECAF') || EE_DECAF !== true) |
|
67 | + && is_readable($this->pluginPath().'caffeinated/brewing_regular.php'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 |
@@ -15,66 +15,66 @@ |
||
15 | 15 | */ |
16 | 16 | class Domain extends DomainBase implements CaffeinatedInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * URL path component used to denote an API request |
|
20 | - */ |
|
21 | - const API_NAMESPACE = 'ee/v'; |
|
18 | + /** |
|
19 | + * URL path component used to denote an API request |
|
20 | + */ |
|
21 | + const API_NAMESPACE = 'ee/v'; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin |
|
25 | - * Page ui. |
|
26 | - */ |
|
27 | - const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN |
|
28 | - = 'manual_registration_status_change_from_registration_admin'; |
|
23 | + /** |
|
24 | + * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin |
|
25 | + * Page ui. |
|
26 | + */ |
|
27 | + const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN |
|
28 | + = 'manual_registration_status_change_from_registration_admin'; |
|
29 | 29 | |
30 | - const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY |
|
31 | - = 'manual_registration_status_change_from_registration_admin_and_notify'; |
|
30 | + const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY |
|
31 | + = 'manual_registration_status_change_from_registration_admin_and_notify'; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Whether or not EE core is the full premium version. |
|
36 | - * @since 4.9.59.p |
|
37 | - * @var bool |
|
38 | - */ |
|
39 | - private $caffeinated; |
|
34 | + /** |
|
35 | + * Whether or not EE core is the full premium version. |
|
36 | + * @since 4.9.59.p |
|
37 | + * @var bool |
|
38 | + */ |
|
39 | + private $caffeinated; |
|
40 | 40 | |
41 | 41 | |
42 | - public function __construct(FilePath $plugin_file, Version $version) |
|
43 | - { |
|
44 | - parent::__construct($plugin_file, $version); |
|
45 | - $this->setCaffeinated(); |
|
46 | - } |
|
42 | + public function __construct(FilePath $plugin_file, Version $version) |
|
43 | + { |
|
44 | + parent::__construct($plugin_file, $version); |
|
45 | + $this->setCaffeinated(); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Whether or not EE core is the full premium version. |
|
50 | - * @since 4.9.59.p |
|
51 | - * @return bool |
|
52 | - */ |
|
53 | - public function isCaffeinated() |
|
54 | - { |
|
55 | - return $this->caffeinated; |
|
56 | - } |
|
48 | + /** |
|
49 | + * Whether or not EE core is the full premium version. |
|
50 | + * @since 4.9.59.p |
|
51 | + * @return bool |
|
52 | + */ |
|
53 | + public function isCaffeinated() |
|
54 | + { |
|
55 | + return $this->caffeinated; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Setter for $is_caffeinated property. |
|
61 | - * @since 4.9.59.p |
|
62 | - */ |
|
63 | - private function setCaffeinated() |
|
64 | - { |
|
65 | - $this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true) |
|
66 | - && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php'); |
|
67 | - } |
|
59 | + /** |
|
60 | + * Setter for $is_caffeinated property. |
|
61 | + * @since 4.9.59.p |
|
62 | + */ |
|
63 | + private function setCaffeinated() |
|
64 | + { |
|
65 | + $this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true) |
|
66 | + && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php'); |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * This should be used everywhere the Event Espresso brand name is referenced in public facing interfaces |
|
72 | - * to allow for filtering the brand. |
|
73 | - * |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public static function brandName() |
|
77 | - { |
|
78 | - return (string) apply_filters('FHEE__EventEspresso_core_domain_Domain__brandName', 'Event Espresso'); |
|
79 | - } |
|
70 | + /** |
|
71 | + * This should be used everywhere the Event Espresso brand name is referenced in public facing interfaces |
|
72 | + * to allow for filtering the brand. |
|
73 | + * |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public static function brandName() |
|
77 | + { |
|
78 | + return (string) apply_filters('FHEE__EventEspresso_core_domain_Domain__brandName', 'Event Espresso'); |
|
79 | + } |
|
80 | 80 | } |
@@ -4,8 +4,8 @@ |
||
4 | 4 | <p><strong><?php esc_html_e('Add New Price Type', 'event_espresso'); ?></strong></p> |
5 | 5 | <p> |
6 | 6 | <?php printf( |
7 | - esc_html__('This page allows you to create a new price type for %s.', 'event_espresso'), |
|
8 | - Domain::brandName() |
|
7 | + esc_html__('This page allows you to create a new price type for %s.', 'event_espresso'), |
|
8 | + Domain::brandName() |
|
9 | 9 | ); ?> |
10 | 10 | </p> |
11 | 11 | <ul> |
@@ -4,8 +4,8 @@ |
||
4 | 4 | <p><strong><?php esc_html_e('Edit Default Price', 'event_espresso'); ?></strong></p> |
5 | 5 | <p> |
6 | 6 | <?php printf( |
7 | - esc_html__('This page allows you to edit a default price for %s.', 'event_espresso'), |
|
8 | - Domain::brandName() |
|
7 | + esc_html__('This page allows you to edit a default price for %s.', 'event_espresso'), |
|
8 | + Domain::brandName() |
|
9 | 9 | ); ?> |
10 | 10 | </p> |
11 | 11 | <ul> |