Simple Google reCAPTCHA - Version 3.5

Version Description

  • Bugfix: More reliable reCAPTCHA injection (init action)
  • New: Dynamic action name to see stats in Google reCAPTCHA admin console for each page
Download this release

Release Info

Developer Minor
Plugin Icon 128x128 Simple Google reCAPTCHA
Version 3.5
Comparing to
See all releases

Code changes from version 3.4 to 3.5

Files changed (3) hide show
  1. readme.txt +5 -1
  2. sgr.js +5 -3
  3. simple-google-recaptcha.php +4 -3
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Minor
3
  Tags: recaptcha, spam, captcha, protect, secure, registration, login, form, google, invisible, checkbox
4
  Requires at least: 4.6
5
  Tested up to: 5.4
6
- Stable tag: 3.4
7
  Requires PHP: 7.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -57,6 +57,10 @@ Use standard WordPress Plugins page. In emergency case, rename plugin folder und
57
  6. reCAPTCHA v3 text instead of badge
58
 
59
  == Changelog ==
 
 
 
 
60
  = 3.4 =
61
  * Bugfix: Translations works again correctly
62
  * New: Works in countries where Google domain is blocked
3
  Tags: recaptcha, spam, captcha, protect, secure, registration, login, form, google, invisible, checkbox
4
  Requires at least: 4.6
5
  Tested up to: 5.4
6
+ Stable tag: 3.5
7
  Requires PHP: 7.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
57
  6. reCAPTCHA v3 text instead of badge
58
 
59
  == Changelog ==
60
+ = 3.5 =
61
+ * Bugfix: More reliable reCAPTCHA injection (init action)
62
+ * New: Dynamic action name to see stats in Google reCAPTCHA admin console for each page
63
+
64
  = 3.4 =
65
  * Bugfix: Translations works again correctly
66
  * New: Works in countries where Google domain is blocked
sgr.js CHANGED
@@ -1,16 +1,18 @@
1
  function sgr_2() {
2
  console.log('SGR_2 loaded!');
3
  let recaptcha = document.getElementsByClassName('sgr-recaptcha');
4
- for (var i = 0; i < recaptcha.length; i++) {
5
  grecaptcha.render(recaptcha.item(i), {'sitekey': sgr_recaptcha.site_key});
6
  }
7
  }
8
 
9
  function sgr_3() {
10
  console.log('SGR_3 loaded!');
11
- grecaptcha.execute(sgr_recaptcha.site_key, {action: 'sgr_global'}).then(function (token) {
 
 
12
  let recaptcha = document.getElementsByClassName('sgr-recaptcha');
13
- for (var i = 0; i < recaptcha.length; i++) {
14
  recaptcha.item(i).value = token;
15
  }
16
  });
1
  function sgr_2() {
2
  console.log('SGR_2 loaded!');
3
  let recaptcha = document.getElementsByClassName('sgr-recaptcha');
4
+ for (let i = 0; i < recaptcha.length; i++) {
5
  grecaptcha.render(recaptcha.item(i), {'sitekey': sgr_recaptcha.site_key});
6
  }
7
  }
8
 
9
  function sgr_3() {
10
  console.log('SGR_3 loaded!');
11
+ let actionName = window.location.pathname + window.location.search;
12
+ actionName = actionName.replace(/[^a-zA-Z0-9 ]/g, '_');
13
+ grecaptcha.execute(sgr_recaptcha.site_key, {action: 'sgr_' + actionName}).then(function (token) {
14
  let recaptcha = document.getElementsByClassName('sgr-recaptcha');
15
+ for (let i = 0; i < recaptcha.length; i++) {
16
  recaptcha.item(i).value = token;
17
  }
18
  });
simple-google-recaptcha.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Plugin Name: Simple Google reCAPTCHA
4
  * Description: Simply protect your WordPress against spam comments and brute-force attacks, thanks to Google reCAPTCHA!
5
- * Version: 3.4
6
  * Author: Michal Novák
7
  * Author URI: https://www.novami.cz
8
  * License: GPL3
@@ -48,8 +48,8 @@ class SimpleGoogleRecaptcha
48
 
49
  add_action('activated_plugin', [$this, 'activation']);
50
  add_action('admin_menu', [$this, 'menu']);
51
- add_action('admin_init', [$this, 'display_options']);
52
- add_action('wp_loaded', [$this, 'check']);
53
  }
54
 
55
  /**
@@ -84,6 +84,7 @@ class SimpleGoogleRecaptcha
84
  {
85
  $this->enqueue_main();
86
  add_submenu_page('options-general.php', $this->pluginName, 'Google reCAPTCHA', 'manage_options', 'sgr_options', [$this, 'options_page']);
 
87
  }
88
 
89
  public function display_sgr_site_key()
2
  /*
3
  * Plugin Name: Simple Google reCAPTCHA
4
  * Description: Simply protect your WordPress against spam comments and brute-force attacks, thanks to Google reCAPTCHA!
5
+ * Version: 3.5
6
  * Author: Michal Novák
7
  * Author URI: https://www.novami.cz
8
  * License: GPL3
48
 
49
  add_action('activated_plugin', [$this, 'activation']);
50
  add_action('admin_menu', [$this, 'menu']);
51
+
52
+ add_action('init', [$this, 'check']);
53
  }
54
 
55
  /**
84
  {
85
  $this->enqueue_main();
86
  add_submenu_page('options-general.php', $this->pluginName, 'Google reCAPTCHA', 'manage_options', 'sgr_options', [$this, 'options_page']);
87
+ add_action('admin_init', [$this, 'display_options']);
88
  }
89
 
90
  public function display_sgr_site_key()