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