Advanced noCaptcha & invisible Captcha - Version 4.2

Version Description

  • BuddyPress mentioned in readme
  • WooCommerce checkout captcha sometimes did not verify
  • Reset captcha if WooCommerce checkout error occur
  • If WordPress version is 4.9.0 or greater then pre_comment_approved filter used for comment which we can now return WP_Error
Download this release

Release Info

Developer shamim51
Plugin Icon 128x128 Advanced noCaptcha & invisible Captcha
Version 4.2
Comparing to
See all releases

Code changes from version 4.1 to 4.2

advanced-nocaptcha-recaptcha.php CHANGED
@@ -2,15 +2,15 @@
2
  /*
3
  Plugin Name: Advanced noCaptcha & invisible Captcha
4
  Plugin URI: https://www.shamimsplugins.com/contact-us/
5
- Description: Show noCaptcha or invisible captcha in Comment Form (after Comment textarea before submit button), bbPress, Login, Register, Lost Password, Reset Password. Also can implement in any other form easily.
6
- Version: 4.1
7
  Author: Shamim Hasan
8
  Author URI: https://www.shamimsplugins.com/contact-us/
9
  Text Domain: advanced-nocaptcha-recaptcha
10
  License: GPLv2 or later
11
  */
12
  // DEFINE
13
- define( 'ANR_PLUGIN_VERSION', '4.1' );
14
  define( 'ANR_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
15
  define( 'ANR_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
16
 
2
  /*
3
  Plugin Name: Advanced noCaptcha & invisible Captcha
4
  Plugin URI: https://www.shamimsplugins.com/contact-us/
5
+ Description: Show noCaptcha or invisible captcha in Comment Form, bbPress, BuddyPress, WooCommerce, CF7, Login, Register, Lost Password, Reset Password. Also can implement in any other form easily.
6
+ Version: 4.2
7
  Author: Shamim Hasan
8
  Author URI: https://www.shamimsplugins.com/contact-us/
9
  Text Domain: advanced-nocaptcha-recaptcha
10
  License: GPLv2 or later
11
  */
12
  // DEFINE
13
+ define( 'ANR_PLUGIN_VERSION', '4.2' );
14
  define( 'ANR_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
15
  define( 'ANR_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
16
 
anr-captcha-class.php CHANGED
@@ -30,7 +30,7 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
30
  }
31
 
32
  if ( anr_is_form_enabled( 'wc_checkout' ) ) {
33
- add_action( 'woocommerce_after_checkout_validation', array( $this, 'wc_checkout_verify' ) );
34
  add_action( 'woocommerce_checkout_after_order_review', array( $this, 'wc_form_field' ) );
35
  }
36
 
@@ -71,7 +71,11 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
71
  } else {
72
  add_filter( 'comment_form_field_comment', array( $this, 'comment_form_field' ), 99 );
73
  }
74
- add_filter( 'preprocess_comment', array( $this, 'comment_verify' ) );
 
 
 
 
75
  }
76
 
77
  if ( function_exists( 'wpcf7_add_form_tag' ) ) {
@@ -194,6 +198,11 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
194
  <?php } ?>
195
 
196
  anr_captcha_<?php echo $num; ?> = grecaptcha.render('anr_captcha_field_<?php echo $num; ?>', anr_obj );
 
 
 
 
 
197
  <?php } ?>
198
  };
199
  </script>
@@ -438,12 +447,24 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
438
 
439
  function comment_verify( $commentdata ) {
440
  if ( ! $this->verify() ) {
441
- wp_die( $this->add_error_to_mgs(), 200 );
 
 
 
 
 
442
  }
443
 
444
  return $commentdata;
445
  }
446
 
 
 
 
 
 
 
 
447
  function wpcf7_form_field( $tag ) {
448
  $loggedin_hide = anr_get_option( 'loggedin_hide' );
449
 
@@ -474,13 +495,14 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
474
  }
475
  }
476
 
477
- function wc_checkout_verify() {
478
  $is_reg_enable = apply_filters( 'woocommerce_checkout_registration_enabled', 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) );
 
479
 
480
- if ( ! is_user_logged_in() && $is_reg_enable && anr_is_form_enabled( 'registration' ) ) {
481
  // verification done during ragistration, So no need any more verification
482
  } elseif ( ! $this->verify() ) {
483
- wc_add_notice( $this->add_error_to_mgs(), 'error' );
484
  }
485
  }
486
 
30
  }
31
 
32
  if ( anr_is_form_enabled( 'wc_checkout' ) ) {
33
+ add_action( 'woocommerce_after_checkout_validation', array( $this, 'wc_checkout_verify' ), 10, 2 );
34
  add_action( 'woocommerce_checkout_after_order_review', array( $this, 'wc_form_field' ) );
35
  }
36
 
71
  } else {
72
  add_filter( 'comment_form_field_comment', array( $this, 'comment_form_field' ), 99 );
73
  }
74
+ if ( version_compare( get_bloginfo( 'version' ), '4.9.0', '>=' ) ) {
75
+ add_filter( 'pre_comment_approved', array( $this, 'comment_verify_490' ), 99 );
76
+ } else {
77
+ add_filter( 'preprocess_comment', array( $this, 'comment_verify' ) );
78
+ }
79
  }
80
 
81
  if ( function_exists( 'wpcf7_add_form_tag' ) ) {
198
  <?php } ?>
199
 
200
  anr_captcha_<?php echo $num; ?> = grecaptcha.render('anr_captcha_field_<?php echo $num; ?>', anr_obj );
201
+ if ( typeof wc_checkout_params !== 'undefined' ) {
202
+ jQuery( document.body ).on( 'checkout_error', function(){
203
+ grecaptcha.reset(anr_captcha_<?php echo $num; ?>);
204
+ });
205
+ }
206
  <?php } ?>
207
  };
208
  </script>
447
 
448
  function comment_verify( $commentdata ) {
449
  if ( ! $this->verify() ) {
450
+ wp_die(
451
+ '<p>' . $this->add_error_to_mgs() . '</p>', __( 'Comment Submission Failure' ), array(
452
+ 'response' => 403,
453
+ 'back_link' => true,
454
+ )
455
+ );
456
  }
457
 
458
  return $commentdata;
459
  }
460
 
461
+ function comment_verify_490( $approved ) {
462
+ if ( ! $this->verify() ) {
463
+ return new WP_Error( 'anr_error', $this->add_error_to_mgs(), 403 );
464
+ }
465
+ return $approved;
466
+ }
467
+
468
  function wpcf7_form_field( $tag ) {
469
  $loggedin_hide = anr_get_option( 'loggedin_hide' );
470
 
495
  }
496
  }
497
 
498
+ function wc_checkout_verify( $data, $errors ) {
499
  $is_reg_enable = apply_filters( 'woocommerce_checkout_registration_enabled', 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) );
500
+ $is_reg_required = apply_filters( 'woocommerce_checkout_registration_required', 'yes' !== get_option( 'woocommerce_enable_guest_checkout' ) );
501
 
502
+ if ( ! is_user_logged_in() && $is_reg_enable && anr_is_form_enabled( 'registration' ) && ( $is_reg_required || ! empty( $data['createaccount'] ) ) ) {
503
  // verification done during ragistration, So no need any more verification
504
  } elseif ( ! $this->verify() ) {
505
+ $errors->add( 'anr_error', anr_get_option( 'error_message' ) );
506
  }
507
  }
508
 
languages/advanced-nocaptcha-recaptcha.pot CHANGED
@@ -1,8 +1,8 @@
1
  #, fuzzy
2
  msgid ""
3
  msgstr ""
4
- "Project-Id-Version: Advanced noCaptcha reCaptcha 4.1\n"
5
- "POT-Creation-Date: 2018-12-27 02:29+0600\n"
6
  "PO-Revision-Date: 2018-04-12 17:20+0600\n"
7
  "Last-Translator: \n"
8
  "Language-Team: Shamim\n"
@@ -10,7 +10,7 @@ msgstr ""
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 2.0.6\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
  "X-Poedit-KeywordsList: __;_e\n"
1
  #, fuzzy
2
  msgid ""
3
  msgstr ""
4
+ "Project-Id-Version: Advanced noCaptcha reCaptcha 4.2\n"
5
+ "POT-Creation-Date: 2019-01-06 02:31+0600\n"
6
  "PO-Revision-Date: 2018-04-12 17:20+0600\n"
7
  "Last-Translator: \n"
8
  "Language-Team: Shamim\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 2.1.1\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
  "X-Poedit-KeywordsList: __;_e\n"
readme.txt CHANGED
@@ -4,16 +4,16 @@ Tags: recaptcha,nocaptcha,invisible,no captcha,bot,spam,captcha,woocommerce capt
4
  Donate link: https://www.paypal.me/hasanshamim
5
  Requires at least: 4.4
6
  Tested up to: 5.0.2
7
- Stable tag: 4.1
8
  Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
- Show noCaptchan or invisible captcha in Comment (after Comment textarea before submit button), CF7, bbpress, woocommerce, Login, Register, Lost & Reset Password.
13
 
14
  == Description ==
15
 
16
- Show noCaptcha or invisible captcha in Comment Form (after Comment textarea before submit button), Contact Form 7, bbPress, woocommerce, Login, Register, Lost Password, Reset Password. Also can implement in any other form easily.
17
 
18
  * **Allow multiple captcha in same page.**
19
  * **Allow conditional login captcha** (you can set after how many failed login attempts login captcha will show)
@@ -31,6 +31,7 @@ Show noCaptcha or invisible captcha in Comment Form (after Comment textarea befo
31
  * FEP Contact Form
32
  * bbPress New topic
33
  * bbPress reply to topic
 
34
 
35
  = Options =
36
 
@@ -81,6 +82,13 @@ To show noCaptcha use [anr_nocaptcha g-recaptcha-response]
81
 
82
  == Changelog ==
83
 
 
 
 
 
 
 
 
84
  = 4.1 =
85
 
86
  * Settings page redesigned.
4
  Donate link: https://www.paypal.me/hasanshamim
5
  Requires at least: 4.4
6
  Tested up to: 5.0.2
7
+ Stable tag: 4.2
8
  Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
+ Show noCaptcha or invisible captcha in Comment (after Comment textarea before submit button), CF7, bbpress, BuddyPress, woocommerce, Login, Register, Lost & Reset Password.
13
 
14
  == Description ==
15
 
16
+ Show noCaptcha or invisible captcha in Comment Form (after Comment textarea before submit button), Contact Form 7, bbPress, BuddyPress, woocommerce, Login, Register, Lost Password, Reset Password. Also can implement in any other form easily.
17
 
18
  * **Allow multiple captcha in same page.**
19
  * **Allow conditional login captcha** (you can set after how many failed login attempts login captcha will show)
31
  * FEP Contact Form
32
  * bbPress New topic
33
  * bbPress reply to topic
34
+ * BuddyPress register
35
 
36
  = Options =
37
 
82
 
83
  == Changelog ==
84
 
85
+ = 4.2 =
86
+
87
+ * BuddyPress mentioned in readme
88
+ * WooCommerce checkout captcha sometimes did not verify
89
+ * Reset captcha if WooCommerce checkout error occur
90
+ * If WordPress version is 4.9.0 or greater then pre_comment_approved filter used for comment which we can now return WP_Error
91
+
92
  = 4.1 =
93
 
94
  * Settings page redesigned.