Advanced noCaptcha & invisible Captcha - Version 5.6

Version Description

  • Return last verify incase of duplicate checking.
  • Add google scripts src filters.
  • Custom hook and captcha shortcode now support logged in setup.
Download this release

Release Info

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

Code changes from version 5.5 to 5.6

admin/settings.php CHANGED
@@ -510,7 +510,7 @@ class ANR_Settings {
510
  <h3><?php _e( 'If you want to implement noCaptcha in any other custom form', 'advanced-nocaptcha-recaptcha' ); ?></h3>
511
  <div><?php printf( __( 'To show noCaptcha in a form use %1$s OR %2$s', 'advanced-nocaptcha-recaptcha' ), "<code>do_action( 'anr_captcha_form_field' )</code>", '<code>[anr-captcha]</code>' ); ?></div>
512
  <div><?php printf( __( 'To verify use %s. It will return true on success otherwise false.', 'advanced-nocaptcha-recaptcha' ), '<code>anr_verify_captcha()</code>' ); ?></div>
513
- <div><?php printf( __( 'For paid support pleasse visit <a href="%s" target="_blank">Advanced noCaptcha reCaptcha</a>', 'advanced-nocaptcha-recaptcha' ), esc_url( 'https://www.shamimsplugins.com/contact-us/' ) ); ?></div>
514
  </div>
515
  </div>
516
  <div><a class="button" href="<?php echo esc_url( admin_url( 'options-general.php?page=anr-admin-settings' ) ); ?>"><?php esc_html_e( 'Back to Settings', 'advanced-nocaptcha-recaptcha' ); ?></a></div>
510
  <h3><?php _e( 'If you want to implement noCaptcha in any other custom form', 'advanced-nocaptcha-recaptcha' ); ?></h3>
511
  <div><?php printf( __( 'To show noCaptcha in a form use %1$s OR %2$s', 'advanced-nocaptcha-recaptcha' ), "<code>do_action( 'anr_captcha_form_field' )</code>", '<code>[anr-captcha]</code>' ); ?></div>
512
  <div><?php printf( __( 'To verify use %s. It will return true on success otherwise false.', 'advanced-nocaptcha-recaptcha' ), '<code>anr_verify_captcha()</code>' ); ?></div>
513
+ <div><?php printf( __( 'For paid support pleasse visit <a href="%s" target="_blank">Advanced noCaptcha reCaptcha</a>', 'advanced-nocaptcha-recaptcha' ), esc_url( 'https://www.shamimsplugins.com/hire/' ) ); ?></div>
514
  </div>
515
  </div>
516
  <div><a class="button" href="<?php echo esc_url( admin_url( 'options-general.php?page=anr-admin-settings' ) ); ?>"><?php esc_html_e( 'Back to Settings', 'advanced-nocaptcha-recaptcha' ); ?></a></div>
advanced-nocaptcha-recaptcha.php CHANGED
@@ -3,7 +3,7 @@
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: 5.5
7
  Author: Shamim Hasan
8
  Author URI: https://www.shamimsplugins.com/contact-us/
9
  Text Domain: advanced-nocaptcha-recaptcha
@@ -40,7 +40,7 @@ class ANR {
40
  }
41
 
42
  private function constants() {
43
- define( 'ANR_PLUGIN_VERSION', '5.5' );
44
  define( 'ANR_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
45
  define( 'ANR_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
46
  define( 'ANR_PLUGIN_FILE', __FILE__ );
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: 5.6
7
  Author: Shamim Hasan
8
  Author URI: https://www.shamimsplugins.com/contact-us/
9
  Text Domain: advanced-nocaptcha-recaptcha
40
  }
41
 
42
  private function constants() {
43
+ define( 'ANR_PLUGIN_VERSION', '5.6' );
44
  define( 'ANR_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
45
  define( 'ANR_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
46
  define( 'ANR_PLUGIN_FILE', __FILE__ );
anr-captcha-class.php CHANGED
@@ -16,8 +16,8 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
16
 
17
  function actions_filters() {
18
  if ( anr_is_form_enabled( 'fep_contact_form' ) ) {
19
- add_action( 'fepcf_message_form_after_content', array( $this, 'form_field' ), 99 );
20
- add_action( 'fepcf_action_message_before_send', array( $this, 'fepcf_verify' ) );
21
  }
22
 
23
  if ( anr_is_form_enabled( 'login' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
@@ -50,10 +50,10 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
50
  if ( anr_is_form_enabled( 'ms_user_signup' ) && is_multisite() ) {
51
  add_action( 'signup_extra_fields', array( $this, 'ms_form_field' ), 99 );
52
  add_filter( 'wpmu_validate_user_signup', array( $this, 'ms_form_field_verify' ) );
53
-
54
  add_action( 'signup_blogform', array( $this, 'ms_form_field' ), 99 );
55
  add_filter( 'wpmu_validate_blog_signup', array( $this, 'ms_blog_verify' ) );
56
-
57
  }
58
 
59
  if ( anr_is_form_enabled( 'lost_password' ) ) {
@@ -73,7 +73,7 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
73
  if ( ! is_user_logged_in() ) {
74
  add_action( 'comment_form_after_fields', array( $this, 'form_field' ), 99 );
75
  } else {
76
- add_filter( 'comment_form_field_comment', array( $this, 'comment_form_field' ), 99 );
77
  }
78
  if ( version_compare( get_bloginfo( 'version' ), '4.9.0', '>=' ) ) {
79
  add_filter( 'pre_comment_approved', array( $this, 'comment_verify_490' ), 99 );
@@ -157,7 +157,7 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
157
 
158
  function footer_script() {
159
  static $included = false;
160
-
161
  $number = $this->total_captcha();
162
  $version = anr_get_option( 'captcha_version', 'v2_checkbox' );
163
 
@@ -191,7 +191,7 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
191
  if ( null === captcha_div )
192
  continue;
193
  captcha_div.innerHTML = '';
194
- ( function( form ) {
195
  var anr_captcha = grecaptcha.render( captcha_div,{
196
  'sitekey' : '<?php echo esc_js( trim( anr_get_option( 'site_key' ) ) ); ?>',
197
  'size' : '<?php echo esc_js( anr_get_option( 'size', 'normal' ) ); ?>',
@@ -218,10 +218,10 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
218
  if ( $language ) {
219
  $lang = '&hl=' . $language;
220
  }
221
- $google_url = 'https://www.google.com/recaptcha/api.js?onload=anr_onloadCallback&render=explicit' . $lang;
222
  ?>
223
  <script src="<?php echo esc_url( $google_url ); ?>"
224
- async defer>
225
  </script>
226
  <?php
227
  }
@@ -237,7 +237,7 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
237
  if ( null === captcha_div )
238
  continue;
239
  captcha_div.innerHTML = '';
240
- ( function( form ) {
241
  var anr_captcha = grecaptcha.render( captcha_div,{
242
  'sitekey' : '<?php echo esc_js( trim( anr_get_option( 'site_key' ) ) ); ?>',
243
  'size' : 'invisible',
@@ -256,7 +256,7 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
256
  }
257
  });
258
  var cf7_submit = form.querySelector( '.wpcf7-submit' );
259
-
260
  if( null !== cf7_submit && ( typeof jQuery !== 'undefined' ) ){
261
  jQuery( cf7_submit ).off('click').on('click', function( e ){
262
  e.preventDefault();
@@ -280,10 +280,10 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
280
  if ( $language ) {
281
  $lang = '&hl=' . $language;
282
  }
283
- $google_url = 'https://www.google.com/recaptcha/api.js?onload=anr_onloadCallback&render=explicit' . $lang;
284
  ?>
285
  <script src="<?php echo esc_url( $google_url ); ?>"
286
- async defer>
287
  </script>
288
  <?php
289
  }
@@ -291,7 +291,7 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
291
  function v3_script() {
292
  // v3 support v2 script. So use it
293
  // $this->v2_invisible_script();
294
-
295
  $language = trim( anr_get_option( 'language' ) );
296
  $site_key = trim( anr_get_option( 'site_key' ) );
297
 
@@ -300,50 +300,50 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
300
  $lang = '&hl=' . $language;
301
  }
302
 
303
- $google_url = 'https://www.google.com/recaptcha/api.js?render=' . $site_key . $lang;
304
  ?>
305
  <script src="<?php echo esc_url( $google_url ); ?>"></script>
306
  <script type="text/javascript">
307
- ( function( grecaptcha ) {
308
-
309
- var anr_onloadCallback = function() {
310
- grecaptcha.execute(
311
- '<?php echo esc_js( $site_key ); ?>',
312
- { action: 'advanced_nocaptcha_recaptcha' }
313
- ).then( function( token ) {
314
- for ( var i = 0; i < document.forms.length; i++ ) {
315
- var form = document.forms[i];
316
- var captcha = form.querySelector( 'input[name="g-recaptcha-response"]' );
317
- if ( null === captcha )
318
- continue;
319
-
320
- captcha.value = token;
321
- }
322
- });
323
- };
324
 
325
- grecaptcha.ready( anr_onloadCallback );
326
 
327
- document.addEventListener( 'wpcf7submit', anr_onloadCallback, false );
328
- if ( typeof wc_checkout_params !== 'undefined' ) {
329
- jQuery( document.body ).on( 'checkout_error', anr_onloadCallback );
330
- }
331
 
332
- } )( grecaptcha );
333
  </script>
334
  <?php
335
  }
336
 
337
 
338
  function form_field() {
339
- $loggedin_hide = anr_get_option( 'loggedin_hide' );
340
-
341
- if ( is_user_logged_in() && $loggedin_hide ) {
342
- return;
343
  }
344
 
345
- anr_captcha_form_field( true );
346
-
 
 
 
347
  }
348
 
349
  function post_id() {
@@ -394,13 +394,8 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
394
 
395
  function login_form_return( $field = '' ) {
396
  if ( $this->show_login_captcha() ) {
397
-
398
- if ( is_user_logged_in() && anr_get_option( 'loggedin_hide' ) ) {
399
- return $field;
400
  }
401
-
402
- $field = $field . anr_captcha_form_field( false );
403
- }
404
  return $field;
405
  }
406
 
@@ -415,41 +410,78 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
415
  }
416
 
417
  function ms_form_field( $errors ) {
418
- $loggedin_hide = anr_get_option( 'loggedin_hide' );
419
-
420
- if ( is_user_logged_in() && $loggedin_hide ) {
421
- return;
422
- }
423
-
424
  if ( $errmsg = $errors->get_error_message( 'anr_error' ) ) {
425
  echo '<p class="error">' . $errmsg . '</p>';
426
  }
427
-
428
- anr_captcha_form_field( true );
429
-
430
  }
431
 
432
- function comment_form_field( $defaults ) {
433
- $loggedin_hide = anr_get_option( 'loggedin_hide' );
434
 
435
- if ( is_user_logged_in() && $loggedin_hide ) {
436
- return $defaults;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
437
  }
438
 
439
- $defaults = $defaults . anr_captcha_form_field( false );
440
- return $defaults;
441
-
442
- }
443
-
444
- function verify() {
445
- $loggedin_hide = anr_get_option( 'loggedin_hide' );
446
-
447
- if ( is_user_logged_in() && $loggedin_hide ) {
448
  return true;
449
  }
450
 
451
- return anr_verify_captcha();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
 
 
453
  }
454
 
455
  function fepcf_verify( $errors ) {
@@ -476,10 +508,10 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
476
  }
477
  $wpdb->insert(
478
  $wpdb->postmeta, array(
479
- 'post_id' => $post_id,
480
- 'meta_key' => md5( $_SERVER['REMOTE_ADDR'] ),
481
- 'meta_value' => $username,
482
- ), array( '%d', '%s', '%s' )
483
  );
484
  }
485
  // return $user;
@@ -519,15 +551,9 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
519
  }
520
 
521
  function bp_form_field() {
522
- $loggedin_hide = anr_get_option( 'loggedin_hide' );
523
-
524
- if ( is_user_logged_in() && $loggedin_hide ) {
525
- return;
526
- }
527
-
528
  do_action( 'bp_anr_error_errors' );
529
 
530
- anr_captcha_form_field( true );
531
  }
532
 
533
  function bp_registration_verify() {
@@ -543,7 +569,7 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
543
 
544
  return $result;
545
  }
546
-
547
  function ms_blog_verify( $result ) {
548
  if ( ! $this->verify() ) {
549
  $result['errors']->add( 'anr_error', anr_get_option( 'error_message' ) );
@@ -600,7 +626,7 @@ if ( ! class_exists( 'anr_captcha_class' ) ) {
600
  return '';
601
  }
602
 
603
- return anr_captcha_form_field( false ) . sprintf( '<span class="wpcf7-form-control-wrap %s"></span>', $tag->name );
604
  }
605
 
606
  function wpcf7_verify( $result, $tag ) {
16
 
17
  function actions_filters() {
18
  if ( anr_is_form_enabled( 'fep_contact_form' ) ) {
19
+ add_action( 'fepcf_message_form_after_content', array( $this, 'form_field' ), 99 );
20
+ add_action( 'fepcf_action_message_before_send', array( $this, 'fepcf_verify' ) );
21
  }
22
 
23
  if ( anr_is_form_enabled( 'login' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
50
  if ( anr_is_form_enabled( 'ms_user_signup' ) && is_multisite() ) {
51
  add_action( 'signup_extra_fields', array( $this, 'ms_form_field' ), 99 );
52
  add_filter( 'wpmu_validate_user_signup', array( $this, 'ms_form_field_verify' ) );
53
+
54
  add_action( 'signup_blogform', array( $this, 'ms_form_field' ), 99 );
55
  add_filter( 'wpmu_validate_blog_signup', array( $this, 'ms_blog_verify' ) );
56
+
57
  }
58
 
59
  if ( anr_is_form_enabled( 'lost_password' ) ) {
73
  if ( ! is_user_logged_in() ) {
74
  add_action( 'comment_form_after_fields', array( $this, 'form_field' ), 99 );
75
  } else {
76
+ add_filter( 'comment_form_field_comment', array( $this, 'form_field_return' ), 99 );
77
  }
78
  if ( version_compare( get_bloginfo( 'version' ), '4.9.0', '>=' ) ) {
79
  add_filter( 'pre_comment_approved', array( $this, 'comment_verify_490' ), 99 );
157
 
158
  function footer_script() {
159
  static $included = false;
160
+
161
  $number = $this->total_captcha();
162
  $version = anr_get_option( 'captcha_version', 'v2_checkbox' );
163
 
191
  if ( null === captcha_div )
192
  continue;
193
  captcha_div.innerHTML = '';
194
+ ( function( form ) {
195
  var anr_captcha = grecaptcha.render( captcha_div,{
196
  'sitekey' : '<?php echo esc_js( trim( anr_get_option( 'site_key' ) ) ); ?>',
197
  'size' : '<?php echo esc_js( anr_get_option( 'size', 'normal' ) ); ?>',
218
  if ( $language ) {
219
  $lang = '&hl=' . $language;
220
  }
221
+ $google_url = apply_filters( 'anr_v2_checkbox_script_api_src', 'https://www.google.com/recaptcha/api.js?onload=anr_onloadCallback&render=explicit' . $lang, $lang );
222
  ?>
223
  <script src="<?php echo esc_url( $google_url ); ?>"
224
+ async defer>
225
  </script>
226
  <?php
227
  }
237
  if ( null === captcha_div )
238
  continue;
239
  captcha_div.innerHTML = '';
240
+ ( function( form ) {
241
  var anr_captcha = grecaptcha.render( captcha_div,{
242
  'sitekey' : '<?php echo esc_js( trim( anr_get_option( 'site_key' ) ) ); ?>',
243
  'size' : 'invisible',
256
  }
257
  });
258
  var cf7_submit = form.querySelector( '.wpcf7-submit' );
259
+
260
  if( null !== cf7_submit && ( typeof jQuery !== 'undefined' ) ){
261
  jQuery( cf7_submit ).off('click').on('click', function( e ){
262
  e.preventDefault();
280
  if ( $language ) {
281
  $lang = '&hl=' . $language;
282
  }
283
+ $google_url = apply_filters( 'anr_v2_invisible_script_api_src', 'https://www.google.com/recaptcha/api.js?onload=anr_onloadCallback&render=explicit' . $lang, $lang );
284
  ?>
285
  <script src="<?php echo esc_url( $google_url ); ?>"
286
+ async defer>
287
  </script>
288
  <?php
289
  }
291
  function v3_script() {
292
  // v3 support v2 script. So use it
293
  // $this->v2_invisible_script();
294
+
295
  $language = trim( anr_get_option( 'language' ) );
296
  $site_key = trim( anr_get_option( 'site_key' ) );
297
 
300
  $lang = '&hl=' . $language;
301
  }
302
 
303
+ $google_url = apply_filters( 'anr_v3_script_api_src', 'https://www.google.com/recaptcha/api.js?render=' . $site_key . $lang, $site_key, $lang );
304
  ?>
305
  <script src="<?php echo esc_url( $google_url ); ?>"></script>
306
  <script type="text/javascript">
307
+ ( function( grecaptcha ) {
308
+
309
+ var anr_onloadCallback = function() {
310
+ grecaptcha.execute(
311
+ '<?php echo esc_js( $site_key ); ?>',
312
+ { action: 'advanced_nocaptcha_recaptcha' }
313
+ ).then( function( token ) {
314
+ for ( var i = 0; i < document.forms.length; i++ ) {
315
+ var form = document.forms[i];
316
+ var captcha = form.querySelector( 'input[name="g-recaptcha-response"]' );
317
+ if ( null === captcha )
318
+ continue;
319
+
320
+ captcha.value = token;
321
+ }
322
+ });
323
+ };
324
 
325
+ grecaptcha.ready( anr_onloadCallback );
326
 
327
+ document.addEventListener( 'wpcf7submit', anr_onloadCallback, false );
328
+ if ( typeof wc_checkout_params !== 'undefined' ) {
329
+ jQuery( document.body ).on( 'checkout_error', anr_onloadCallback );
330
+ }
331
 
332
+ } )( grecaptcha );
333
  </script>
334
  <?php
335
  }
336
 
337
 
338
  function form_field() {
339
+ echo $this->form_field_return();
 
 
 
340
  }
341
 
342
+ function form_field_return( $return = '' ) {
343
+ if ( is_user_logged_in() && anr_get_option( 'loggedin_hide' ) ) {
344
+ return $return;
345
+ }
346
+ return $return . $this->captcha_form_field();
347
  }
348
 
349
  function post_id() {
394
 
395
  function login_form_return( $field = '' ) {
396
  if ( $this->show_login_captcha() ) {
397
+ $field = $this->form_field_return( $field );
 
 
398
  }
 
 
 
399
  return $field;
400
  }
401
 
410
  }
411
 
412
  function ms_form_field( $errors ) {
 
 
 
 
 
 
413
  if ( $errmsg = $errors->get_error_message( 'anr_error' ) ) {
414
  echo '<p class="error">' . $errmsg . '</p>';
415
  }
416
+ $this->form_field();
 
 
417
  }
418
 
419
+ function verify( $response = false ) {
420
+ static $last_verify = null;
421
 
422
+ if ( is_user_logged_in() && anr_get_option( 'loggedin_hide' ) ) {
423
+ return true;
424
+ }
425
+
426
+ $secre_key = trim( anr_get_option( 'secret_key' ) );
427
+ $remoteip = $_SERVER['REMOTE_ADDR'];
428
+ $verify = false;
429
+
430
+ if ( false === $response ) {
431
+ $response = isset( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response'] : '';
432
+ }
433
+
434
+ $pre_check = apply_filters( 'anr_verify_captcha_pre', null, $response );
435
+
436
+ if ( null !== $pre_check ) {
437
+ return $pre_check;
438
  }
439
 
440
+ if ( ! $secre_key ) { // if $secre_key is not set
 
 
 
 
 
 
 
 
441
  return true;
442
  }
443
 
444
+ if ( ! $response || ! $remoteip ) {
445
+ return $verify;
446
+ }
447
+
448
+ if ( null !== $last_verify ) {
449
+ return $last_verify;
450
+ }
451
+
452
+ $url = apply_filters( 'anr_google_verify_url', 'https://www.google.com/recaptcha/api/siteverify' );
453
+
454
+ // make a POST request to the Google reCAPTCHA Server
455
+ $request = wp_remote_post(
456
+ $url, array(
457
+ 'timeout' => 10,
458
+ 'body' => array(
459
+ 'secret' => $secre_key,
460
+ 'response' => $response,
461
+ 'remoteip' => $remoteip,
462
+ ),
463
+ )
464
+ );
465
+
466
+ // get the request response body
467
+ $request_body = wp_remote_retrieve_body( $request );
468
+ if ( ! $request_body ) {
469
+ return $verify;
470
+ }
471
+
472
+ $result = json_decode( $request_body, true );
473
+ if ( isset( $result['success'] ) && true == $result['success'] ) {
474
+ if ( 'v3' === anr_get_option( 'captcha_version' ) ) {
475
+ $score = isset( $result['score'] ) ? $result['score'] : 0;
476
+ $verify = anr_get_option( 'score', '0.5' ) <= $score;
477
+ } else {
478
+ $verify = true;
479
+ }
480
+ }
481
+ $verify = apply_filters( 'anr_verify_captcha', $verify, $result, $response );
482
+ $last_verify = $verify;
483
 
484
+ return $verify;
485
  }
486
 
487
  function fepcf_verify( $errors ) {
508
  }
509
  $wpdb->insert(
510
  $wpdb->postmeta, array(
511
+ 'post_id' => $post_id,
512
+ 'meta_key' => md5( $_SERVER['REMOTE_ADDR'] ),
513
+ 'meta_value' => $username,
514
+ ), array( '%d', '%s', '%s' )
515
  );
516
  }
517
  // return $user;
551
  }
552
 
553
  function bp_form_field() {
 
 
 
 
 
 
554
  do_action( 'bp_anr_error_errors' );
555
 
556
+ $this->form_field();
557
  }
558
 
559
  function bp_registration_verify() {
569
 
570
  return $result;
571
  }
572
+
573
  function ms_blog_verify( $result ) {
574
  if ( ! $this->verify() ) {
575
  $result['errors']->add( 'anr_error', anr_get_option( 'error_message' ) );
626
  return '';
627
  }
628
 
629
+ return $this->form_field_return() . sprintf( '<span class="wpcf7-form-control-wrap %s"></span>', $tag->name );
630
  }
631
 
632
  function wpcf7_verify( $result, $tag ) {
functions.php CHANGED
@@ -181,67 +181,15 @@ add_shortcode( 'anr-captcha', 'anr_captcha_form_field' );
181
 
182
  function anr_captcha_form_field( $echo = false ) {
183
  if ( $echo ) {
184
- echo anr_captcha_class::init()->captcha_form_field();
185
  } else {
186
- return anr_captcha_class::init()->captcha_form_field();
187
  }
188
 
189
  }
190
 
191
  function anr_verify_captcha( $response = false ) {
192
- $secre_key = trim( anr_get_option( 'secret_key' ) );
193
- $remoteip = $_SERVER['REMOTE_ADDR'];
194
- $verify = false;
195
-
196
- if ( false === $response ) {
197
- $response = isset( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response'] : '';
198
- }
199
-
200
- $pre_check = apply_filters( 'anr_verify_captcha_pre', null, $response );
201
-
202
- if ( null !== $pre_check ) {
203
- return $pre_check;
204
- }
205
-
206
- if ( ! $secre_key ) { // if $secre_key is not set
207
- return true;
208
- }
209
-
210
- if ( ! $response || ! $remoteip ) {
211
- return $verify;
212
- }
213
-
214
- $url = 'https://www.google.com/recaptcha/api/siteverify';
215
-
216
- // make a POST request to the Google reCAPTCHA Server
217
- $request = wp_remote_post(
218
- $url, array(
219
- 'timeout' => 10,
220
- 'body' => array(
221
- 'secret' => $secre_key,
222
- 'response' => $response,
223
- 'remoteip' => $remoteip,
224
- ),
225
- )
226
- );
227
-
228
- // get the request response body
229
- $request_body = wp_remote_retrieve_body( $request );
230
- if ( ! $request_body ) {
231
- return $verify;
232
- }
233
-
234
- $result = json_decode( $request_body, true );
235
- if ( isset( $result['success'] ) && true == $result['success'] ) {
236
- if ( 'v3' === anr_get_option( 'captcha_version' ) ) {
237
- $score = isset( $result['score'] ) ? $result['score'] : 0;
238
- $verify = anr_get_option( 'score', '0.5' ) <= $score;
239
- } else {
240
- $verify = true;
241
- }
242
- }
243
-
244
- return apply_filters( 'anr_verify_captcha', $verify, $result, $response );
245
  }
246
 
247
  add_filter( 'shake_error_codes', 'anr_add_shake_error_codes' );
181
 
182
  function anr_captcha_form_field( $echo = false ) {
183
  if ( $echo ) {
184
+ anr_captcha_class::init()->form_field();
185
  } else {
186
+ return anr_captcha_class::init()->form_field_return();
187
  }
188
 
189
  }
190
 
191
  function anr_verify_captcha( $response = false ) {
192
+ return anr_captcha_class::init()->verify( $response );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  }
194
 
195
  add_filter( 'shake_error_codes', 'anr_add_shake_error_codes' );
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: shamim51
3
  Tags: recaptcha,nocaptcha,invisible,no captcha,bot,spam,captcha,woocommerce captcha,woocommerce nocaptcha, woocommerce,widget,plugin,sidebar,shortcode,page,posts,comments,google,bbpress,multisite,multiple,v2,v3
4
  Donate link: https://www.shamimsplugins.com/products/advanced-nocaptcha-and-invisible-captcha-pro/
5
  Requires at least: 4.4
6
- Tested up to: 5.2
7
- Stable tag: 5.5
8
  Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -88,6 +88,12 @@ You can access your file via FTP or file manager and rename "advanced-nocaptcha-
88
 
89
  == Changelog ==
90
 
 
 
 
 
 
 
91
  = 5.5 =
92
 
93
  * Fix: Multisite site signup during registration failed due to double verification.
3
  Tags: recaptcha,nocaptcha,invisible,no captcha,bot,spam,captcha,woocommerce captcha,woocommerce nocaptcha, woocommerce,widget,plugin,sidebar,shortcode,page,posts,comments,google,bbpress,multisite,multiple,v2,v3
4
  Donate link: https://www.shamimsplugins.com/products/advanced-nocaptcha-and-invisible-captcha-pro/
5
  Requires at least: 4.4
6
+ Tested up to: 5.3
7
+ Stable tag: 5.6
8
  Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
88
 
89
  == Changelog ==
90
 
91
+ = 5.6 =
92
+
93
+ * Return last verify incase of duplicate checking.
94
+ * Add google scripts src filters.
95
+ * Custom hook and captcha shortcode now support logged in setup.
96
+
97
  = 5.5 =
98
 
99
  * Fix: Multisite site signup during registration failed due to double verification.