PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/model/setting/class-captcha.php +22 -50 5.9.0 → 6.3.0 View file →
@@ -185,25 +185,29 @@
185 185 $this->provider = 'recaptcha';
186 186 $this->message = $default_values['message'];
187 187 $this->language = 'automatic';
188 188 $this->data_v2_checkbox = array(
189 - 'key' => '',
190 - 'secret' => '',
191 - 'size' => 'normal',
192 - 'style' => 'light',
189 + 'key' => '',
190 + 'secret' => '',
191 + 'verified' => false,
192 + 'size' => 'normal',
193 + 'style' => 'light',
193 194 );
194 195 $this->data_v2_invisible = array(
195 - 'key' => '',
196 - 'secret' => '',
196 + 'key' => '',
197 + 'secret' => '',
198 + 'verified' => false,
197 199 );
198 200 $this->data_v3_recaptcha = array(
199 201 'key' => '',
200 202 'secret' => '',
203 + 'verified' => false,
201 204 'threshold' => '0.5',
202 205 );
203 206 $this->data_turnstile = array(
204 207 'key' => '',
205 208 'secret' => '',
209 + 'verified' => false,
206 210 'size' => 'normal',
207 211 'style' => 'auto',
208 212 'message' => $default_values['turnstile_message'],
209 213 'language' => 'auto',
@@ -210,8 +214,20 @@
210 214 );
211 215 }
212 216
213 217 /**
218 + * Backfill new keys (e.g. 'verified') into data arrays loaded from settings saved by an older version.
219 + *
220 + * @return void
221 + */
222 + protected function after_load(): void {
223 + $this->data_v2_checkbox = wp_parse_args( $this->data_v2_checkbox, array( 'verified' => false ) );
224 + $this->data_v2_invisible = wp_parse_args( $this->data_v2_invisible, array( 'verified' => false ) );
225 + $this->data_v3_recaptcha = wp_parse_args( $this->data_v3_recaptcha, array( 'verified' => false ) );
226 + $this->data_turnstile = wp_parse_args( $this->data_turnstile, array( 'verified' => false ) );
227 + }
228 +
229 + /**
214 230 * Checks if the given Captcha type is valid and has all the necessary data.
215 231 *
216 232 * @param string $active_type The Captcha type to check.
217 233 *
@@ -361,57 +377,13 @@
361 377 );
362 378 }
363 379
364 380 /**
365 - * Validates the form after submission.
366 - *
367 - * @return void
368 - */
369 - protected function after_validate(): void {
370 - $provider_label = self::TURNSTILE === $this->provider ? __( 'Turnstile', 'defender-security' ) : __( 'reCAPTCHA', 'defender-security' );
371 - // Case with multi errors.
372 - if ( $this->is_unchecked_woo_locations() && $this->is_unchecked_buddypress_locations() ) {
373 - // The text of the notation is only in the first key, but we add the number of keys depending on the disabled locations of the plugins.
374 - /* translators: Provider label. */
375 - $message = esc_html__(
376 - 'You have enabled %s for more than one plugin. Please select at least one form location for each plugin and click Save Changes again.',
377 - 'defender-security'
378 - );
379 -
380 - $this->errors['enable_woo'] = sprintf( $message, $provider_label );
381 - $this->errors['enable_buddypress'] = '';
382 - } else {
383 - // Individual cases with plugins.
384 - if ( $this->is_unchecked_woo_locations() ) {
385 - /* translators: Provider label. */
386 - $message = esc_html__(
387 - '%s for WooCommerce is enabled, but no WooCommerce forms are selected. Please select at least one WooCommerce form location and then click Save Changes again.',
388 - 'defender-security'
389 - );
390 -
391 - $this->errors['enable_woo'] = sprintf( $message, $provider_label );
392 - }
393 - if ( $this->is_unchecked_buddypress_locations() ) {
394 - /* translators: Provider label. */
395 - $message = esc_html__(
396 - '%s for BuddyPress is enabled, but no BuddyPress forms are selected. Please select at least one BuddyPress form location and then click Save Changes again.',
397 - 'defender-security'
398 - );
399 -
400 - $this->errors['enable_buddypress'] = sprintf( $message, $provider_label );
401 - }
402 - }
403 - }
404 -
405 - /**
406 381 * Disable for logged in users or enable.
407 382 *
408 383 * @return bool
409 384 */
410 385 public function display_for_known_users(): bool {
411 - if ( self::TURNSTILE === $this->provider ) {
412 - return true;
413 - }
414 386 return ! ( $this->disable_for_known_users && is_user_logged_in() );
415 387 }
416 388
417 389 /**