Advanced noCaptcha & invisible Captcha - Version 4.4

Version Description

  • PRO version released
  • anr_verify_captcha_pre filter added
  • anr_get_option filter added
Download this release

Release Info

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

Code changes from version 4.3 to 4.4

Files changed (5) hide show
  1. admin/settings.php +49 -13
  2. advanced-nocaptcha-recaptcha.php +47 -11
  3. functions.php +16 -7
  4. readme.txt +10 -2
  5. uninstall.php +27 -0
admin/settings.php CHANGED
@@ -13,7 +13,7 @@ class ANR_Settings {
13
 
14
  function actions_filters() {
15
  add_action( 'admin_init', array( $this, 'admin_init' ) );
16
- add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
17
 
18
  if ( is_multisite() ) {
19
  $same_settings = apply_filters( 'anr_same_settings_for_all_sites', false );
@@ -227,6 +227,16 @@ class ANR_Settings {
227
  'desc' => __( 'If JavaScript is a requirement for your site, we advise that you do NOT check this.', 'advanced-nocaptcha-recaptcha' ),
228
  ),
229
  );
 
 
 
 
 
 
 
 
 
 
230
  return apply_filters( 'anr_settings_fields', $fields );
231
  }
232
 
@@ -268,6 +278,16 @@ class ANR_Settings {
268
  $attrib
269
  );
270
  break;
 
 
 
 
 
 
 
 
 
 
271
  case 'checkbox':
272
  printf( '<input type="hidden" name="anr_admin_options[%s]" value="" />', esc_attr( $field['id'] ) );
273
  printf(
@@ -313,6 +333,9 @@ class ANR_Settings {
313
  }
314
  printf( '</select>' );
315
  break;
 
 
 
316
 
317
  default:
318
  printf( __( 'No hook defined for %s', 'advanced-nocaptcha-recaptcha' ), esc_html( $field['type'] ) );
@@ -353,9 +376,8 @@ class ANR_Settings {
353
  }
354
  anr_update_option( $value );
355
 
356
- if ( ! count( get_settings_errors() ) ) {
357
- add_settings_error( 'anr_admin_options', 'settings_updated', __( 'Settings saved.' ), 'updated' );
358
- }
359
  }
360
  ?>
361
  <div class="wrap">
@@ -364,8 +386,8 @@ class ANR_Settings {
364
  <div id="post-body" class="metabox-holder columns-2">
365
  <div id="post-body-content">
366
  <div id="tab_container">
367
- <?php settings_errors(); ?>
368
- <form method="post" action="<?php echo esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ); ?>">
369
  <?php
370
  settings_fields( 'anr_admin_options' );
371
  do_settings_sections( 'anr_admin_options' );
@@ -386,7 +408,7 @@ class ANR_Settings {
386
  }
387
 
388
  function anr_admin_sidebar() {
389
- return '<div class="postbox">
390
  <h3 class="hndle" style="text-align: center;">
391
  <span>' . __( 'Plugin Author', 'advanced-nocaptcha-recaptcha' ) . '</span>
392
  </h3>
@@ -401,6 +423,23 @@ class ANR_Settings {
401
  </div>
402
  </div>
403
  </div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  }
405
 
406
  function instruction_page() {
@@ -441,13 +480,10 @@ class ANR_Settings {
441
  }
442
 
443
 
444
- function add_settings_link( $links, $file ) {
445
  // add settings link in plugins page
446
- $plugin_file = 'advanced-nocaptcha-recaptcha/advanced-nocaptcha-recaptcha.php';
447
- if ( $file == $plugin_file ) {
448
- $settings_link = '<a href="' . admin_url( 'options-general.php?page=anr-admin-settings' ) . '">' . __( 'Settings', 'advanced-nocaptcha-recaptcha' ) . '</a>';
449
- array_unshift( $links, $settings_link );
450
- }
451
  return $links;
452
  }
453
 
13
 
14
  function actions_filters() {
15
  add_action( 'admin_init', array( $this, 'admin_init' ) );
16
+ add_filter( 'plugin_action_links_' . plugin_basename( ANR_PLUGIN_FILE ), array( $this, 'add_settings_link' ) );
17
 
18
  if ( is_multisite() ) {
19
  $same_settings = apply_filters( 'anr_same_settings_for_all_sites', false );
227
  'desc' => __( 'If JavaScript is a requirement for your site, we advise that you do NOT check this.', 'advanced-nocaptcha-recaptcha' ),
228
  ),
229
  );
230
+ if ( ! class_exists( 'ANR_Pro' ) ) :
231
+ $fields['pro_notice'] = array(
232
+ 'section_id' => 'forms',
233
+ 'type' => 'html',
234
+ 'std' => '<div class="notice notice-success inline">
235
+ <p>To support development of "Advanced noCaptcha & invisible Captcha" plugin please purchase PRO version. <a class="button button-secondary" href="https://www.shamimsplugins.com/products/advanced-nocaptcha-and-invisible-captcha-pro/">View Details</a></p>
236
+ </div>',
237
+ );
238
+ endif;
239
+
240
  return apply_filters( 'anr_settings_fields', $fields );
241
  }
242
 
278
  $attrib
279
  );
280
  break;
281
+ case 'textarea':
282
+ printf( '<textarea id="%1$s" class="%2$s" name="anr_admin_options[%3$s]" placeholder="%4$s" %5$s >%6$s</textarea>',
283
+ esc_attr( $field['id'] ),
284
+ esc_attr( $field['class'] ),
285
+ esc_attr( $field['id'] ),
286
+ isset( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '',
287
+ $attrib,
288
+ esc_textarea( $value )
289
+ );
290
+ break;
291
  case 'checkbox':
292
  printf( '<input type="hidden" name="anr_admin_options[%s]" value="" />', esc_attr( $field['id'] ) );
293
  printf(
333
  }
334
  printf( '</select>' );
335
  break;
336
+ case 'html':
337
+ echo $field['std'];
338
+ break;
339
 
340
  default:
341
  printf( __( 'No hook defined for %s', 'advanced-nocaptcha-recaptcha' ), esc_html( $field['type'] ) );
376
  }
377
  anr_update_option( $value );
378
 
379
+ wp_safe_redirect( admin_url( 'options-general.php?page=anr-admin-settings&updated=true' ) );
380
+ exit;
 
381
  }
382
  ?>
383
  <div class="wrap">
386
  <div id="post-body" class="metabox-holder columns-2">
387
  <div id="post-body-content">
388
  <div id="tab_container">
389
+ <?php settings_errors( 'anr_admin_options' ); ?>
390
+ <form method="post" action="<?php echo esc_attr( admin_url( 'options-general.php?page=anr-admin-settings' ) ); ?>">
391
  <?php
392
  settings_fields( 'anr_admin_options' );
393
  do_settings_sections( 'anr_admin_options' );
408
  }
409
 
410
  function anr_admin_sidebar() {
411
+ $return = '<div class="postbox">
412
  <h3 class="hndle" style="text-align: center;">
413
  <span>' . __( 'Plugin Author', 'advanced-nocaptcha-recaptcha' ) . '</span>
414
  </h3>
423
  </div>
424
  </div>
425
  </div>';
426
+ if ( ! class_exists( 'ANR_Pro' ) ) :
427
+ $return .= '<div class="postbox">
428
+ <h3 class="hndle" style="text-align: center;">
429
+ <span>' . __( 'Support Development', 'advanced-nocaptcha-recaptcha' ) . '</span>
430
+ </h3>
431
+
432
+ <div class="inside">
433
+ <div style="text-align: center; margin: auto">
434
+ <a style="text-decoration:none;" href="https://www.shamimsplugins.com/products/advanced-nocaptcha-and-invisible-captcha-pro/">To support development of "Advanced noCaptcha & invisible Captcha" plugin please purchase
435
+ <div style="font-size:24px;color:red;margin:10px;">PRO</div>
436
+ version only for USD 10</a>
437
+ <p><a class="button button-secondary" href="https://www.shamimsplugins.com/products/advanced-nocaptcha-and-invisible-captcha-pro/">View Details</a></p>
438
+ </div>
439
+ </div>
440
+ </div>';
441
+ endif;
442
+ return $return;
443
  }
444
 
445
  function instruction_page() {
480
  }
481
 
482
 
483
+ function add_settings_link( $links ) {
484
  // add settings link in plugins page
485
+ $settings_link = '<a href="' . admin_url( 'options-general.php?page=anr-admin-settings' ) . '">' . __( 'Settings', 'advanced-nocaptcha-recaptcha' ) . '</a>';
486
+ array_unshift( $links, $settings_link );
 
 
 
487
  return $links;
488
  }
489
 
advanced-nocaptcha-recaptcha.php CHANGED
@@ -3,22 +3,58 @@
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.3
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.3' );
14
- define( 'ANR_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
15
- define( 'ANR_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
16
 
17
- require_once 'functions.php';
 
 
18
 
19
- // ADD ACTIONS
20
- add_action( 'after_setup_theme', 'anr_include_require_files' );
21
- add_action( 'plugins_loaded', 'anr_translation' );
22
- // add_action( 'wp_enqueue_scripts', 'anr_enqueue_scripts' );
23
- add_action( 'login_enqueue_scripts', 'anr_login_enqueue_scripts' );
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.4
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
 
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit; // Exit if accessed directly.
15
+ }
16
 
17
+ class ANR {
 
 
 
 
18
 
19
+ private static $instance;
20
+
21
+ private function __construct() {
22
+ if ( function_exists( 'anr_get_option' ) ) {
23
+ if ( ! function_exists( 'deactivate_plugins' ) ) {
24
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
25
+ }
26
+ deactivate_plugins( 'advanced-nocaptcha-recaptcha/advanced-nocaptcha-recaptcha.php' );
27
+ return;
28
+ }
29
+ $this->constants();
30
+ $this->includes();
31
+ $this->actions();
32
+ // $this->filters();
33
+ }
34
+
35
+ public static function init() {
36
+ if ( ! self::$instance instanceof self ) {
37
+ self::$instance = new self();
38
+ }
39
+ return self::$instance;
40
+ }
41
+
42
+ private function constants() {
43
+ define( 'ANR_PLUGIN_VERSION', '4.4' );
44
+ define( 'ANR_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
45
+ define( 'ANR_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
46
+ define( 'ANR_PLUGIN_FILE', __FILE__ );
47
+ }
48
+
49
+ private function includes() {
50
+ require_once ANR_PLUGIN_DIR . 'functions.php';
51
+ }
52
+
53
+ private function actions() {
54
+ add_action( 'after_setup_theme', 'anr_include_require_files' );
55
+ add_action( 'init', 'anr_translation' );
56
+ add_action( 'login_enqueue_scripts', 'anr_login_enqueue_scripts' );
57
+ }
58
+ } //END Class
59
+
60
+ ANR::init();
functions.php CHANGED
@@ -80,10 +80,13 @@ function anr_get_option( $option, $default = '', $section = 'anr_admin_options'
80
  }
81
 
82
  if ( isset( $options[ $option ] ) ) {
83
- return $options[ $option ];
 
 
 
 
84
  }
85
-
86
- return $default;
87
  }
88
 
89
  function anr_update_option( $options, $value = '', $section = 'anr_admin_options' ) {
@@ -174,15 +177,21 @@ function anr_captcha_form_field( $echo = false ) {
174
  function anr_verify_captcha( $response = false ) {
175
  $secre_key = trim( anr_get_option( 'secret_key' ) );
176
  $remoteip = $_SERVER['REMOTE_ADDR'];
 
 
 
 
 
 
 
 
 
 
177
 
178
  if ( ! $secre_key ) { // if $secre_key is not set
179
  return true;
180
  }
181
 
182
- if ( false === $response ) {
183
- $response = isset( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response'] : '';
184
- }
185
-
186
  if ( ! $response || ! $remoteip ) {
187
  return false;
188
  }
80
  }
81
 
82
  if ( isset( $options[ $option ] ) ) {
83
+ $value = $options[ $option ];
84
+ $is_default = false;
85
+ } else {
86
+ $value = $default;
87
+ $is_default = true;
88
  }
89
+ return apply_filters( 'anr_get_option', $value, $option, $default, $is_default );
 
90
  }
91
 
92
  function anr_update_option( $options, $value = '', $section = 'anr_admin_options' ) {
177
  function anr_verify_captcha( $response = false ) {
178
  $secre_key = trim( anr_get_option( 'secret_key' ) );
179
  $remoteip = $_SERVER['REMOTE_ADDR'];
180
+
181
+ if ( false === $response ) {
182
+ $response = isset( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response'] : '';
183
+ }
184
+
185
+ $pre_check = apply_filters( 'anr_verify_captcha_pre', null, $response );
186
+
187
+ if ( null !== $pre_check ) {
188
+ return $pre_check;
189
+ }
190
 
191
  if ( ! $secre_key ) { // if $secre_key is not set
192
  return true;
193
  }
194
 
 
 
 
 
195
  if ( ! $response || ! $remoteip ) {
196
  return false;
197
  }
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
4
  Donate link: https://www.paypal.me/hasanshamim
5
  Requires at least: 4.4
6
- Tested up to: 5.1
7
- Stable tag: 4.3
8
  Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -18,6 +18,8 @@ Show noCaptcha or invisible captcha in Comment Form (after Comment textarea befo
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)
20
 
 
 
21
  = Show noCaptcha on =
22
 
23
  * Comment Form (after Comment textarea before submit button)
@@ -82,6 +84,12 @@ To show noCaptcha use [anr_nocaptcha g-recaptcha-response]
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
 
85
  = 4.3 =
86
 
87
  * Reset captcha if CF7 validation error occur
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
4
  Donate link: https://www.paypal.me/hasanshamim
5
  Requires at least: 4.4
6
+ Tested up to: 5.1.1
7
+ Stable tag: 4.4
8
  Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
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)
20
 
21
+ > [For **Advanced noCaptcha & invisible Captcha PRO** click here](https://www.shamimsplugins.com/products/advanced-nocaptcha-and-invisible-captcha-pro/?utm_campaign=wordpress&utm_source=readme_pro&utm_medium=description)
22
+
23
  = Show noCaptcha on =
24
 
25
  * Comment Form (after Comment textarea before submit button)
84
 
85
  == Changelog ==
86
 
87
+ = 4.4 =
88
+
89
+ * PRO version released
90
+ * anr_verify_captcha_pre filter added
91
+ * anr_get_option filter added
92
+
93
  = 4.3 =
94
 
95
  * Reset captcha if CF7 validation error occur
uninstall.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uninstall
4
+ *
5
+ * Deletes all the plugin data
6
+ */
7
+
8
+ // Exit if accessed directly.
9
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
10
+ exit;
11
+ }
12
+
13
+ function anr_uninstall_plugin() {
14
+ global $wpdb;
15
+
16
+ $post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_type = 'anr-post' LIMIT 1" );
17
+
18
+ if ( $post_id ) {
19
+ // There may have too many post meta. delete them first in one query.
20
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d", $post_id ) );
21
+
22
+ wp_delete_post( $post_id, true );
23
+ }
24
+ }
25
+
26
+ anr_uninstall_plugin();
27
+