Version Description
- Warning: Possibility to decide when reCAPTCHA will be shown was removed (not bothering registered users)
- New: Including BuddyPress and WooCommerce support
- Bugfix: Incompatibility with translations
Download this release
Release Info
Developer | Minor |
Plugin | Simple Google reCAPTCHA |
Version | 2.2 |
Comparing to | |
See all releases |
Code changes from version 2.1 to 2.2
- readme.txt +19 -5
- simple-google-recaptcha.php +34 -45
readme.txt
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
=== Simple Google reCAPTCHA ===
|
2 |
Contributors: Minor
|
3 |
-
Tags: recaptcha, spam, block, captcha, bots, brute, force, protect, comments, secure, attack, registration, reset, form
|
4 |
Requires at least: 4.2.0
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 2.
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
|
|
9 |
|
10 |
Simply protect your WordPress against spam comments and brute-force attacks, thanks to reCAPTCHA!
|
11 |
|
@@ -13,13 +14,18 @@ Simply protect your WordPress against spam comments and brute-force attacks, tha
|
|
13 |
Simple Google reCAPTCHA will protect your WordPress! No more spam comments and brute-force attacks against user accounts. Really lightweight plugin - just few KBs to download!
|
14 |
|
15 |
= What is protected with reCAPTCHA? =
|
16 |
-
* Comment form
|
17 |
* New password form
|
18 |
* Registration form
|
19 |
* Login form
|
20 |
* Reset password form
|
|
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
23 |
|
24 |
|
25 |
== Installation ==
|
@@ -33,6 +39,9 @@ You can choose where reCAPTCHA will be required.
|
|
33 |
= Why to install this plugin? =
|
34 |
Just pure protection - no ads and any other unnecessary changes.
|
35 |
|
|
|
|
|
|
|
36 |
== Screenshots ==
|
37 |
1. Simple Google reCAPTCHA - Add new comment form
|
38 |
2. Simple Google reCAPTCHA - New password form
|
@@ -41,6 +50,11 @@ Just pure protection - no ads and any other unnecessary changes.
|
|
41 |
5. Simple Google reCAPTCHA - Settings
|
42 |
|
43 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
44 |
= 2.1 =
|
45 |
* Bugfix: No more unnecessary loading reCAPTCHA on the other pages
|
46 |
* Bugfix: No more reCAPTCHA window over Clef waves (if you are using Clef plugin) on the login page
|
1 |
=== Simple Google reCAPTCHA ===
|
2 |
Contributors: Minor
|
3 |
+
Tags: recaptcha, spam, block, captcha, bots, brute, force, protect, comments, secure, attack, registration, reset, form, buddypress, woocommerce
|
4 |
Requires at least: 4.2.0
|
5 |
+
Tested up to: 4.8
|
6 |
+
Stable tag: 2.2
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
+
Donate link: https://www.paypal.me/NovaMi
|
10 |
|
11 |
Simply protect your WordPress against spam comments and brute-force attacks, thanks to reCAPTCHA!
|
12 |
|
14 |
Simple Google reCAPTCHA will protect your WordPress! No more spam comments and brute-force attacks against user accounts. Really lightweight plugin - just few KBs to download!
|
15 |
|
16 |
= What is protected with reCAPTCHA? =
|
17 |
+
* Comment form
|
18 |
* New password form
|
19 |
* Registration form
|
20 |
* Login form
|
21 |
* Reset password form
|
22 |
+
* BuddyPress and WooCommerce support
|
23 |
|
24 |
+
reCaptcha verification will be required just for not registered users!
|
25 |
+
|
26 |
+
--
|
27 |
+
Thanks all of you, who are using this plugin I really appreciate it! WordPress is amazing open-source software which I'm using for free (for business too) so this plugin is my way how to say thank you!
|
28 |
+
If you write to me (on support center etc.) and expect an answer, be patient, please. I'm working on this plugin only in my free time, it's my hobby.
|
29 |
|
30 |
|
31 |
== Installation ==
|
39 |
= Why to install this plugin? =
|
40 |
Just pure protection - no ads and any other unnecessary changes.
|
41 |
|
42 |
+
= How to disable this plugin? =
|
43 |
+
Just use standard Plugin overview page in WordPress admin section and deactivate it or rename plugin folder /wp-content/plugins/simple-google-recaptcha over FTP access.
|
44 |
+
|
45 |
== Screenshots ==
|
46 |
1. Simple Google reCAPTCHA - Add new comment form
|
47 |
2. Simple Google reCAPTCHA - New password form
|
50 |
5. Simple Google reCAPTCHA - Settings
|
51 |
|
52 |
== Changelog ==
|
53 |
+
= 2.2 =
|
54 |
+
* Warning: Possibility to decide when reCAPTCHA will be shown was removed (not bothering registered users)
|
55 |
+
* New: Including BuddyPress and WooCommerce support
|
56 |
+
* Bugfix: Incompatibility with translations
|
57 |
+
|
58 |
= 2.1 =
|
59 |
* Bugfix: No more unnecessary loading reCAPTCHA on the other pages
|
60 |
* Bugfix: No more reCAPTCHA window over Clef waves (if you are using Clef plugin) on the login page
|
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: 2.
|
6 |
* Author: Michal Novák
|
7 |
* Author URI: https://www.novami.cz
|
8 |
* License: GPL3
|
@@ -43,42 +43,41 @@ function sgr_display_secret_key_element() {
|
|
43 |
echo "<input type=\"text\" name=\"sgr_secret_key\" class=\"regular-text\" id=\"sgr_secret_key\" value=\"".get_option("sgr_secret_key")."\" />";
|
44 |
}
|
45 |
|
46 |
-
function sgr_display_comments_disable() {
|
47 |
-
echo "<input type=\"checkbox\" name=\"sgr_comments_disable\" id=\"sgr_comments_disable\" value=\"1\" ".checked(1, get_option("sgr_comments_disable"), false)." />";
|
48 |
-
}
|
49 |
-
|
50 |
-
function sgr_display_forms_disable() {
|
51 |
-
echo "<input type=\"checkbox\" name=\"sgr_forms_disable\" id=\"sgr_forms_disable\" value=\"1\" ".checked(1, get_option("sgr_forms_disable"), false)." />";
|
52 |
-
}
|
53 |
-
|
54 |
function sgr_display_options() {
|
55 |
add_settings_section("sgr_header_section", __("What first?", "simple-google-recaptcha"), "sgr_display_content", "sgr-options");
|
56 |
-
|
57 |
add_settings_field("sgr_site_key", __("Site Key", "simple-google-recaptcha"), "sgr_display_site_key_element", "sgr-options", "sgr_header_section");
|
58 |
add_settings_field("sgr_secret_key", __("Secret Key", "simple-google-recaptcha"), "sgr_display_secret_key_element", "sgr-options", "sgr_header_section");
|
59 |
-
add_settings_field("sgr_comments_disable", __("Disable reCAPTCHA for comments", "simple-google-recaptcha"), "sgr_display_comments_disable", "sgr-options", "sgr_header_section");
|
60 |
-
add_settings_field("sgr_forms_disable", __("Disable reCAPTCHA for basic forms", "simple-google-recaptcha"), "sgr_display_forms_disable", "sgr-options", "sgr_header_section");
|
61 |
|
62 |
register_setting("sgr_header_section", "sgr_site_key");
|
63 |
register_setting("sgr_header_section", "sgr_secret_key");
|
64 |
-
register_setting("sgr_header_section", "sgr_comments_disable");
|
65 |
-
register_setting("sgr_header_section", "sgr_forms_disable");
|
66 |
}
|
67 |
add_action("admin_init", "sgr_display_options");
|
68 |
|
69 |
function load_language_sgr() {
|
70 |
-
load_plugin_textdomain("
|
71 |
}
|
72 |
add_action("plugins_loaded", "load_language_sgr");
|
73 |
|
74 |
function frontend_sgr_script() {
|
75 |
-
if (
|
76 |
wp_register_script("sgr_recaptcha", "https://www.google.com/recaptcha/api.js?hl=".get_locale());
|
77 |
wp_enqueue_script("sgr_recaptcha");
|
78 |
wp_register_script("sgr_recaptcha_check", plugin_dir_url(__FILE__)."check.js");
|
79 |
wp_enqueue_script("sgr_recaptcha_check");
|
80 |
wp_localize_script("sgr_recaptcha_check", "sgr_recaptcha_trans", array("title" => __("Are you a Robot?", "simple-google-recaptcha")));
|
81 |
wp_enqueue_style("style", plugin_dir_url(__FILE__)."style.css");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
}
|
84 |
|
@@ -87,23 +86,21 @@ function sgr_display() {
|
|
87 |
}
|
88 |
|
89 |
function sgr_verify($input) {
|
90 |
-
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
return $input;
|
99 |
-
} else {
|
100 |
-
wp_die("<p><strong>".__("ERROR:", "simple-google-recaptcha")."</strong> ".__("Google reCAPTCHA verification failed.", "simple-google-recaptcha")."</p>\n\n<p><a href=".wp_get_referer().">« ".__("Back", "simple-google-recaptcha")."</a>");
|
101 |
-
return null;
|
102 |
-
}
|
103 |
} else {
|
104 |
-
wp_die("<p><strong>".__("ERROR:", "simple-google-recaptcha")."</strong> ".__("Google reCAPTCHA verification failed.", "simple-google-recaptcha")."
|
105 |
return null;
|
106 |
}
|
|
|
|
|
|
|
107 |
}
|
108 |
}
|
109 |
|
@@ -113,24 +110,16 @@ function sgr_check() {
|
|
113 |
add_action("login_enqueue_scripts", "frontend_sgr_script");
|
114 |
add_action("wp_enqueue_scripts", "frontend_sgr_script");
|
115 |
|
116 |
-
if (
|
117 |
-
add_action("comment_form_after_fields", "sgr_display");
|
118 |
add_action("preprocess_comment", "sgr_verify");
|
119 |
}
|
120 |
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
add_action("registration_errors", "sgr_verify");
|
127 |
-
|
128 |
-
add_action("lostpassword_form", "sgr_display");
|
129 |
-
add_action("lostpassword_post", "sgr_verify");
|
130 |
-
|
131 |
-
add_action("resetpass_form", "sgr_display");
|
132 |
-
add_action("resetpass_post", "sgr_verify");
|
133 |
-
}
|
134 |
}
|
135 |
}
|
|
|
136 |
add_action("init", "sgr_check");
|
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: 2.2
|
6 |
* Author: Michal Novák
|
7 |
* Author URI: https://www.novami.cz
|
8 |
* License: GPL3
|
43 |
echo "<input type=\"text\" name=\"sgr_secret_key\" class=\"regular-text\" id=\"sgr_secret_key\" value=\"".get_option("sgr_secret_key")."\" />";
|
44 |
}
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
function sgr_display_options() {
|
47 |
add_settings_section("sgr_header_section", __("What first?", "simple-google-recaptcha"), "sgr_display_content", "sgr-options");
|
48 |
+
|
49 |
add_settings_field("sgr_site_key", __("Site Key", "simple-google-recaptcha"), "sgr_display_site_key_element", "sgr-options", "sgr_header_section");
|
50 |
add_settings_field("sgr_secret_key", __("Secret Key", "simple-google-recaptcha"), "sgr_display_secret_key_element", "sgr-options", "sgr_header_section");
|
|
|
|
|
51 |
|
52 |
register_setting("sgr_header_section", "sgr_site_key");
|
53 |
register_setting("sgr_header_section", "sgr_secret_key");
|
|
|
|
|
54 |
}
|
55 |
add_action("admin_init", "sgr_display_options");
|
56 |
|
57 |
function load_language_sgr() {
|
58 |
+
load_plugin_textdomain("simple-google-recaptcha", false, dirname(plugin_basename(__FILE__))."/languages/");
|
59 |
}
|
60 |
add_action("plugins_loaded", "load_language_sgr");
|
61 |
|
62 |
function frontend_sgr_script() {
|
63 |
+
if (did_action("login_init") > 0 || function_exists(is_account_page) || function_exists(bp_get_signup_page) || (is_single() && comments_open()) && !is_user_logged_in()) {
|
64 |
wp_register_script("sgr_recaptcha", "https://www.google.com/recaptcha/api.js?hl=".get_locale());
|
65 |
wp_enqueue_script("sgr_recaptcha");
|
66 |
wp_register_script("sgr_recaptcha_check", plugin_dir_url(__FILE__)."check.js");
|
67 |
wp_enqueue_script("sgr_recaptcha_check");
|
68 |
wp_localize_script("sgr_recaptcha_check", "sgr_recaptcha_trans", array("title" => __("Are you a Robot?", "simple-google-recaptcha")));
|
69 |
wp_enqueue_style("style", plugin_dir_url(__FILE__)."style.css");
|
70 |
+
|
71 |
+
add_action("comment_form_after_fields", "sgr_display");
|
72 |
+
add_action("login_form", "sgr_display");
|
73 |
+
add_action("register_form", "sgr_display");
|
74 |
+
add_action("lost_password", "sgr_display");
|
75 |
+
add_action("lostpassword_form", "sgr_display");
|
76 |
+
add_action("retrieve_password", "sgr_display");
|
77 |
+
add_action("resetpass_form", "sgr_display");
|
78 |
+
add_action("woocommerce_login_form", "sgr_display");
|
79 |
+
add_action("woocommerce_lostpassword_form", "sgr_display");
|
80 |
+
add_action("bp_after_signup_profile_fields", "sgr_display");
|
81 |
}
|
82 |
}
|
83 |
|
86 |
}
|
87 |
|
88 |
function sgr_verify($input) {
|
89 |
+
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["g-recaptcha-response"])) {
|
90 |
+
$recaptcha_response = sanitize_text_field($_POST["g-recaptcha-response"]);
|
91 |
+
$recaptcha_secret = get_option("sgr_secret_key");
|
92 |
+
$response = wp_remote_get("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secret."&response=".$recaptcha_response);
|
93 |
+
$response = json_decode($response["body"], true);
|
94 |
+
|
95 |
+
if ($response["success"] == true) {
|
96 |
+
return $input;
|
|
|
|
|
|
|
|
|
|
|
97 |
} else {
|
98 |
+
wp_die("<p><strong>".__("ERROR:", "simple-google-recaptcha")."</strong> ".__("Google reCAPTCHA verification failed.", "simple-google-recaptcha")."</p>\n\n<p><a href=".wp_get_referer().">« ".__("Back", "simple-google-recaptcha")."</a>");
|
99 |
return null;
|
100 |
}
|
101 |
+
} else {
|
102 |
+
wp_die("<p><strong>".__("ERROR:", "simple-google-recaptcha")."</strong> ".__("Google reCAPTCHA verification failed.", "simple-google-recaptcha")." ".__("Do you have JavaScript enabled?", "simple-google-recaptcha")."</p>\n\n<p><a href=".wp_get_referer().">« ".__("Back", "simple-google-recaptcha")."</a>");
|
103 |
+
return null;
|
104 |
}
|
105 |
}
|
106 |
|
110 |
add_action("login_enqueue_scripts", "frontend_sgr_script");
|
111 |
add_action("wp_enqueue_scripts", "frontend_sgr_script");
|
112 |
|
113 |
+
if (!is_user_logged_in()) {
|
|
|
114 |
add_action("preprocess_comment", "sgr_verify");
|
115 |
}
|
116 |
|
117 |
+
add_action("wp_authenticate_user", "sgr_verify");
|
118 |
+
add_action("registration_errors", "sgr_verify");
|
119 |
+
add_action("lostpassword_post", "sgr_verify");
|
120 |
+
add_action("resetpass_post", "sgr_verify");
|
121 |
+
add_action("bp_signup_validate", "sgr_verify");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
}
|
123 |
}
|
124 |
+
|
125 |
add_action("init", "sgr_check");
|