@@ -16,69 +16,69 @@ |
||
16 | 16 | class GutenbergEditor extends AdminRoute |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * returns true if the current request matches this route |
|
21 | - * |
|
22 | - * @return bool |
|
23 | - */ |
|
24 | - public function matchesCurrentRequest(): bool |
|
25 | - { |
|
26 | - global $pagenow; |
|
27 | - return parent::matchesCurrentRequest() |
|
28 | - && $pagenow |
|
29 | - && ( |
|
30 | - $pagenow === 'post-new.php' |
|
31 | - || ( |
|
32 | - $pagenow === 'post.php' |
|
33 | - && $this->request->getRequestParam('action') === 'edit' |
|
34 | - ) |
|
35 | - ) |
|
36 | - && apply_filters('FHEE__EE_System__canLoadBlocks', true); |
|
37 | - } |
|
19 | + /** |
|
20 | + * returns true if the current request matches this route |
|
21 | + * |
|
22 | + * @return bool |
|
23 | + */ |
|
24 | + public function matchesCurrentRequest(): bool |
|
25 | + { |
|
26 | + global $pagenow; |
|
27 | + return parent::matchesCurrentRequest() |
|
28 | + && $pagenow |
|
29 | + && ( |
|
30 | + $pagenow === 'post-new.php' |
|
31 | + || ( |
|
32 | + $pagenow === 'post.php' |
|
33 | + && $this->request->getRequestParam('action') === 'edit' |
|
34 | + ) |
|
35 | + ) |
|
36 | + && apply_filters('FHEE__EE_System__canLoadBlocks', true); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - protected function registerDependencies() |
|
44 | - { |
|
45 | - $this->dependency_map->registerDependencies( |
|
46 | - 'EventEspresso\core\domain\entities\routing\data_nodes\domains\GutenbergEditorData', |
|
47 | - [ |
|
48 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
49 | - ] |
|
50 | - ); |
|
51 | - $this->dependency_map->registerDependencies( |
|
52 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager', |
|
53 | - [ |
|
54 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
55 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
56 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
57 | - ] |
|
58 | - ); |
|
59 | - } |
|
40 | + /** |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + protected function registerDependencies() |
|
44 | + { |
|
45 | + $this->dependency_map->registerDependencies( |
|
46 | + 'EventEspresso\core\domain\entities\routing\data_nodes\domains\GutenbergEditorData', |
|
47 | + [ |
|
48 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
49 | + ] |
|
50 | + ); |
|
51 | + $this->dependency_map->registerDependencies( |
|
52 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager', |
|
53 | + [ |
|
54 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
55 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
56 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
57 | + ] |
|
58 | + ); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - protected function dataNodeClass(): string |
|
66 | - { |
|
67 | - return GutenbergEditorData::class; |
|
68 | - } |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + protected function dataNodeClass(): string |
|
66 | + { |
|
67 | + return GutenbergEditorData::class; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * implements logic required to run during request |
|
73 | - * |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - protected function requestHandler(): bool |
|
77 | - { |
|
78 | - $this->asset_manager = $this->loader->getShared( |
|
79 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' |
|
80 | - ); |
|
81 | - add_action('admin_enqueue_scripts', [$this->asset_manager, 'enqueueBrowserAssets'], 100); |
|
82 | - return true; |
|
83 | - } |
|
71 | + /** |
|
72 | + * implements logic required to run during request |
|
73 | + * |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + protected function requestHandler(): bool |
|
77 | + { |
|
78 | + $this->asset_manager = $this->loader->getShared( |
|
79 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' |
|
80 | + ); |
|
81 | + add_action('admin_enqueue_scripts', [$this->asset_manager, 'enqueueBrowserAssets'], 100); |
|
82 | + return true; |
|
83 | + } |
|
84 | 84 | } |
@@ -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 = null) |
|
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 = null) |
|
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->session instanceof EE_Session |
|
69 | - && $this->config->use_captcha |
|
70 | - && $this->config->recaptcha_theme === 'invisible'; |
|
71 | - } |
|
63 | + /** |
|
64 | + * @return boolean |
|
65 | + */ |
|
66 | + public function useInvisibleRecaptcha() |
|
67 | + { |
|
68 | + return $this->session instanceof EE_Session |
|
69 | + && $this->config->use_captcha |
|
70 | + && $this->config->recaptcha_theme === 'invisible'; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * @param array $input_settings |
|
76 | - * @return EE_Invisible_Recaptcha_Input |
|
77 | - * @throws InvalidDataTypeException |
|
78 | - * @throws InvalidInterfaceException |
|
79 | - * @throws InvalidArgumentException |
|
80 | - * @throws DomainException |
|
81 | - */ |
|
82 | - public function getInput(array $input_settings = array()) |
|
83 | - { |
|
84 | - return new EE_Invisible_Recaptcha_Input( |
|
85 | - $input_settings, |
|
86 | - $this->config |
|
87 | - ); |
|
88 | - } |
|
74 | + /** |
|
75 | + * @param array $input_settings |
|
76 | + * @return EE_Invisible_Recaptcha_Input |
|
77 | + * @throws InvalidDataTypeException |
|
78 | + * @throws InvalidInterfaceException |
|
79 | + * @throws InvalidArgumentException |
|
80 | + * @throws DomainException |
|
81 | + */ |
|
82 | + public function getInput(array $input_settings = array()) |
|
83 | + { |
|
84 | + return new EE_Invisible_Recaptcha_Input( |
|
85 | + $input_settings, |
|
86 | + $this->config |
|
87 | + ); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * @param array $input_settings |
|
93 | - * @return string |
|
94 | - * @throws EE_Error |
|
95 | - * @throws InvalidDataTypeException |
|
96 | - * @throws InvalidInterfaceException |
|
97 | - * @throws InvalidArgumentException |
|
98 | - * @throws DomainException |
|
99 | - */ |
|
100 | - public function getInputHtml(array $input_settings = array()) |
|
101 | - { |
|
102 | - return $this->getInput($input_settings)->get_html_for_input(); |
|
103 | - } |
|
91 | + /** |
|
92 | + * @param array $input_settings |
|
93 | + * @return string |
|
94 | + * @throws EE_Error |
|
95 | + * @throws InvalidDataTypeException |
|
96 | + * @throws InvalidInterfaceException |
|
97 | + * @throws InvalidArgumentException |
|
98 | + * @throws DomainException |
|
99 | + */ |
|
100 | + public function getInputHtml(array $input_settings = array()) |
|
101 | + { |
|
102 | + return $this->getInput($input_settings)->get_html_for_input(); |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * @param EE_Form_Section_Proper $form |
|
108 | - * @param array $input_settings |
|
109 | - * @throws EE_Error |
|
110 | - * @throws InvalidArgumentException |
|
111 | - * @throws InvalidDataTypeException |
|
112 | - * @throws InvalidInterfaceException |
|
113 | - * @throws DomainException |
|
114 | - */ |
|
115 | - public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array()) |
|
116 | - { |
|
117 | - $form->add_subsections( |
|
118 | - array( |
|
119 | - 'espresso_recaptcha' => $this->getInput($input_settings), |
|
120 | - ), |
|
121 | - null, |
|
122 | - false |
|
123 | - ); |
|
124 | - } |
|
106 | + /** |
|
107 | + * @param EE_Form_Section_Proper $form |
|
108 | + * @param array $input_settings |
|
109 | + * @throws EE_Error |
|
110 | + * @throws InvalidArgumentException |
|
111 | + * @throws InvalidDataTypeException |
|
112 | + * @throws InvalidInterfaceException |
|
113 | + * @throws DomainException |
|
114 | + */ |
|
115 | + public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array()) |
|
116 | + { |
|
117 | + $form->add_subsections( |
|
118 | + array( |
|
119 | + 'espresso_recaptcha' => $this->getInput($input_settings), |
|
120 | + ), |
|
121 | + null, |
|
122 | + false |
|
123 | + ); |
|
124 | + } |
|
125 | 125 | |
126 | 126 | |
127 | - /** |
|
128 | - * @param RequestInterface $request |
|
129 | - * @return boolean |
|
130 | - * @throws InvalidArgumentException |
|
131 | - * @throws InvalidDataTypeException |
|
132 | - * @throws InvalidInterfaceException |
|
133 | - * @throws RuntimeException |
|
134 | - */ |
|
135 | - public function verifyToken(RequestInterface $request) |
|
136 | - { |
|
137 | - static $previous_recaptcha_response = array(); |
|
138 | - $grecaptcha_response = $request->getRequestParam('g-recaptcha-response'); |
|
139 | - // if this token has already been verified, then return previous response |
|
140 | - if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
141 | - return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
142 | - } |
|
143 | - // still here but no g-recaptcha-response ? - verification failed |
|
144 | - if (! $grecaptcha_response) { |
|
145 | - EE_Error::add_error( |
|
146 | - sprintf( |
|
147 | - /* translators: 1: missing parameter */ |
|
148 | - esc_html__( |
|
149 | - // @codingStandardsIgnoreStart |
|
150 | - 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.', |
|
151 | - // @codingStandardsIgnoreEnd |
|
152 | - 'event_espresso' |
|
153 | - ), |
|
154 | - 'g-recaptcha-response' |
|
155 | - ), |
|
156 | - __FILE__, |
|
157 | - __FUNCTION__, |
|
158 | - __LINE__ |
|
159 | - ); |
|
160 | - return false; |
|
161 | - } |
|
162 | - // will update to true if everything passes |
|
163 | - $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
164 | - $response = wp_safe_remote_post( |
|
165 | - InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
|
166 | - array( |
|
167 | - 'body' => array( |
|
168 | - 'secret' => $this->config->recaptcha_privatekey, |
|
169 | - 'response' => $grecaptcha_response, |
|
170 | - 'remoteip' => $request->ipAddress(), |
|
171 | - ), |
|
172 | - ) |
|
173 | - ); |
|
174 | - if ($response instanceof WP_Error) { |
|
175 | - $this->generateError($response->get_error_messages()); |
|
176 | - return false; |
|
177 | - } |
|
178 | - $results = json_decode(wp_remote_retrieve_body($response), true); |
|
179 | - if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
|
180 | - $errors = array_map( |
|
181 | - array($this, 'getErrorCode'), |
|
182 | - $results['error-codes'] |
|
183 | - ); |
|
184 | - if (isset($results['challenge_ts'])) { |
|
185 | - $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
186 | - } |
|
187 | - $this->generateError(implode(' ', $errors), true); |
|
188 | - } |
|
189 | - $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
190 | - add_action('shutdown', array($this, 'setSessionData')); |
|
191 | - return true; |
|
192 | - } |
|
127 | + /** |
|
128 | + * @param RequestInterface $request |
|
129 | + * @return boolean |
|
130 | + * @throws InvalidArgumentException |
|
131 | + * @throws InvalidDataTypeException |
|
132 | + * @throws InvalidInterfaceException |
|
133 | + * @throws RuntimeException |
|
134 | + */ |
|
135 | + public function verifyToken(RequestInterface $request) |
|
136 | + { |
|
137 | + static $previous_recaptcha_response = array(); |
|
138 | + $grecaptcha_response = $request->getRequestParam('g-recaptcha-response'); |
|
139 | + // if this token has already been verified, then return previous response |
|
140 | + if (isset($previous_recaptcha_response[ $grecaptcha_response ])) { |
|
141 | + return $previous_recaptcha_response[ $grecaptcha_response ]; |
|
142 | + } |
|
143 | + // still here but no g-recaptcha-response ? - verification failed |
|
144 | + if (! $grecaptcha_response) { |
|
145 | + EE_Error::add_error( |
|
146 | + sprintf( |
|
147 | + /* translators: 1: missing parameter */ |
|
148 | + esc_html__( |
|
149 | + // @codingStandardsIgnoreStart |
|
150 | + 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.', |
|
151 | + // @codingStandardsIgnoreEnd |
|
152 | + 'event_espresso' |
|
153 | + ), |
|
154 | + 'g-recaptcha-response' |
|
155 | + ), |
|
156 | + __FILE__, |
|
157 | + __FUNCTION__, |
|
158 | + __LINE__ |
|
159 | + ); |
|
160 | + return false; |
|
161 | + } |
|
162 | + // will update to true if everything passes |
|
163 | + $previous_recaptcha_response[ $grecaptcha_response ] = false; |
|
164 | + $response = wp_safe_remote_post( |
|
165 | + InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API, |
|
166 | + array( |
|
167 | + 'body' => array( |
|
168 | + 'secret' => $this->config->recaptcha_privatekey, |
|
169 | + 'response' => $grecaptcha_response, |
|
170 | + 'remoteip' => $request->ipAddress(), |
|
171 | + ), |
|
172 | + ) |
|
173 | + ); |
|
174 | + if ($response instanceof WP_Error) { |
|
175 | + $this->generateError($response->get_error_messages()); |
|
176 | + return false; |
|
177 | + } |
|
178 | + $results = json_decode(wp_remote_retrieve_body($response), true); |
|
179 | + if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) { |
|
180 | + $errors = array_map( |
|
181 | + array($this, 'getErrorCode'), |
|
182 | + $results['error-codes'] |
|
183 | + ); |
|
184 | + if (isset($results['challenge_ts'])) { |
|
185 | + $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.'; |
|
186 | + } |
|
187 | + $this->generateError(implode(' ', $errors), true); |
|
188 | + } |
|
189 | + $previous_recaptcha_response[ $grecaptcha_response ] = true; |
|
190 | + add_action('shutdown', array($this, 'setSessionData')); |
|
191 | + return true; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | |
195 | - /** |
|
196 | - * @param string $error_response |
|
197 | - * @param bool $show_errors |
|
198 | - * @return void |
|
199 | - * @throws RuntimeException |
|
200 | - */ |
|
201 | - public function generateError($error_response = '', $show_errors = false) |
|
202 | - { |
|
203 | - throw new RuntimeException( |
|
204 | - sprintf( |
|
205 | - esc_html__( |
|
206 | - 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.', |
|
207 | - 'event_espresso' |
|
208 | - ), |
|
209 | - '<br />', |
|
210 | - $show_errors || current_user_can('manage_options') ? $error_response : '' |
|
211 | - ) |
|
212 | - ); |
|
213 | - } |
|
195 | + /** |
|
196 | + * @param string $error_response |
|
197 | + * @param bool $show_errors |
|
198 | + * @return void |
|
199 | + * @throws RuntimeException |
|
200 | + */ |
|
201 | + public function generateError($error_response = '', $show_errors = false) |
|
202 | + { |
|
203 | + throw new RuntimeException( |
|
204 | + sprintf( |
|
205 | + esc_html__( |
|
206 | + 'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.', |
|
207 | + 'event_espresso' |
|
208 | + ), |
|
209 | + '<br />', |
|
210 | + $show_errors || current_user_can('manage_options') ? $error_response : '' |
|
211 | + ) |
|
212 | + ); |
|
213 | + } |
|
214 | 214 | |
215 | 215 | |
216 | - /** |
|
217 | - * @param string $error_code |
|
218 | - * @return string |
|
219 | - */ |
|
220 | - public function getErrorCode(&$error_code) |
|
221 | - { |
|
222 | - $error_codes = array( |
|
223 | - 'missing-input-secret' => 'The secret parameter is missing.', |
|
224 | - 'invalid-input-secret' => 'The secret parameter is invalid or malformed.', |
|
225 | - 'missing-input-response' => 'The response parameter is missing.', |
|
226 | - 'invalid-input-response' => 'The response parameter is invalid or malformed.', |
|
227 | - 'bad-request' => 'The request is invalid or malformed.', |
|
228 | - 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
|
229 | - ); |
|
230 | - return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
231 | - } |
|
216 | + /** |
|
217 | + * @param string $error_code |
|
218 | + * @return string |
|
219 | + */ |
|
220 | + public function getErrorCode(&$error_code) |
|
221 | + { |
|
222 | + $error_codes = array( |
|
223 | + 'missing-input-secret' => 'The secret parameter is missing.', |
|
224 | + 'invalid-input-secret' => 'The secret parameter is invalid or malformed.', |
|
225 | + 'missing-input-response' => 'The response parameter is missing.', |
|
226 | + 'invalid-input-response' => 'The response parameter is invalid or malformed.', |
|
227 | + 'bad-request' => 'The request is invalid or malformed.', |
|
228 | + 'timeout-or-duplicate' => 'The request took too long to be sent or was a duplicate of a previous request.', |
|
229 | + ); |
|
230 | + return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : ''; |
|
231 | + } |
|
232 | 232 | |
233 | 233 | |
234 | - /** |
|
235 | - * @return array |
|
236 | - * @throws InvalidInterfaceException |
|
237 | - * @throws InvalidDataTypeException |
|
238 | - * @throws InvalidArgumentException |
|
239 | - */ |
|
240 | - public function getLocalizedVars() |
|
241 | - { |
|
242 | - return (array) apply_filters( |
|
243 | - 'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars', |
|
244 | - array( |
|
245 | - 'siteKey' => $this->config->recaptcha_publickey, |
|
246 | - 'recaptcha_passed' => $this->recaptchaPassed(), |
|
247 | - 'wp_debug' => WP_DEBUG, |
|
248 | - 'disable_submit' => defined('EE_EVENT_QUEUE_BASE_URL'), |
|
249 | - 'failed_message' => esc_html__( |
|
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 | - } |
|
234 | + /** |
|
235 | + * @return array |
|
236 | + * @throws InvalidInterfaceException |
|
237 | + * @throws InvalidDataTypeException |
|
238 | + * @throws InvalidArgumentException |
|
239 | + */ |
|
240 | + public function getLocalizedVars() |
|
241 | + { |
|
242 | + return (array) apply_filters( |
|
243 | + 'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars', |
|
244 | + array( |
|
245 | + 'siteKey' => $this->config->recaptcha_publickey, |
|
246 | + 'recaptcha_passed' => $this->recaptchaPassed(), |
|
247 | + 'wp_debug' => WP_DEBUG, |
|
248 | + 'disable_submit' => defined('EE_EVENT_QUEUE_BASE_URL'), |
|
249 | + 'failed_message' => esc_html__( |
|
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 | 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 | - if ($this->session instanceof EE_Session) { |
|
293 | - $this->session->set_session_data([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 | + if ($this->session instanceof EE_Session) { |
|
293 | + $this->session->set_session_data([InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true]); |
|
294 | + } |
|
295 | + } |
|
296 | 296 | } |